Skip to content

Commit

Permalink
Remove the usage of assert in the SPARQLConnector
Browse files Browse the repository at this point in the history
  • Loading branch information
white-gecko committed Oct 8, 2020
1 parent 7a53c61 commit b42e5a5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions rdflib/plugins/stores/sparqlconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ def __init__(
self.kwargs = kwargs
self.method = method
if auth is not None:
assert type(auth) == tuple, "auth must be a tuple"
assert len(auth) == 2, "auth must be a tuple (user, password)"
if type(auth) != tuple:
raise SPARQLConnectorException("auth must be a tuple")
if len(auth) != 2:
raise SPARQLConnectorException("auth must be a tuple (user, password)")
base64string = base64.b64encode(bytes('%s:%s' % auth, 'ascii'))
self.kwargs.setdefault("headers", {})
self.kwargs["headers"].update({"Authorization": "Basic %s" % base64string.decode('utf-8')})
Expand Down

0 comments on commit b42e5a5

Please sign in to comment.