Skip to content
Snippets Groups Projects
Commit 52ec0560 authored by Dan Michael O. Heggø's avatar Dan Michael O. Heggø
Browse files

PEP8, code cleanup, add docstring

parent 442e39c3
No related merge requests found
......@@ -58,8 +58,7 @@ class Site(object):
self.ext = ext
self.credentials = None
self.compress = compress
if httpauth:
self.httpauth = httpauth
self.httpauth = httpauth
self.retry_timeout = retry_timeout
self.max_retries = max_retries
self.wait_callback = wait_callback
......@@ -222,9 +221,9 @@ class Site(object):
headers['Content-Type'] = 'application/x-www-form-urlencoded'
if self.compress and gzip:
headers['Accept-Encoding'] = 'gzip'
if self.httpauth:
if self.httpauth is not None:
credentials = base64.encodestring('%s:%s' % self.httpauth).replace('\n', '')
headers['Authorization'] = "Basic %s" % credentials
headers['Authorization'] = 'Basic %s' % credentials
token = self.wait_token((script, data))
while True:
try:
......@@ -624,8 +623,10 @@ class Site(object):
else:
return result['expandtemplates']['*']
def ask(self, query, title = None):
def ask(self, query, title=None):
"""Ask a query against Semantic MediaWiki."""
kwargs = {}
if title is None: kwargs['title'] = title
result = self.raw_api('ask', query = query, **kwargs)
if title is None:
kwargs['title'] = title
result = self.raw_api('ask', query=query, **kwargs)
return result['query']['results']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment