remove whitespace

pull/1/head
Leberwurscht 2012-04-04 01:34:45 +02:00
rodzic 142bba7a6d
commit aa748195bf
1 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -21,36 +21,36 @@ class WebFingerExpection(Exception):
pass
class WebFingerResponse(object):
def __init__(self, xrd, insecure):
self.insecure = insecure
self._xrd = xrd
def __getattr__(self, name):
if name in RELS:
return self._xrd.find_link(RELS[name], attr='href')
return getattr(self._xrd, name)
class WebFingerClient(object):
def __init__(self, host):
self._host = host
self._opener = urllib2.build_opener(urllib2.HTTPRedirectHandler())
self._opener.addheaders = [('User-agent', 'python-webfinger')]
def _hm_hosts(self, xrd):
return [e.value for e in xrd.elements if e.name == 'hm:Host']
def xrd(self, url, raw=False):
conn = self._opener.open(url)
response = conn.read()
conn.close()
return response if raw else XRD.parse(response)
def hostmeta(self, protocol):
hostmeta_url = "%s://%s/.well-known/host-meta" % (protocol, self._host)
return self.xrd(hostmeta_url)
def finger(self, username):
try:
hm = self.hostmeta('https')
@ -60,16 +60,16 @@ class WebFingerClient(object):
insecure = True
hm_hosts = self._hm_hosts(hm)
if self._host not in hm_hosts:
raise WebFingerExpection("hostmeta host did not match account host")
template = hm.find_link(WEBFINGER_TYPES, attr='template')
if not template.startswith('https://'):
insecure = True
xrd_url = template.replace('{uri}',
urllib.quote_plus('acct:%s@%s' % (username, self._host)))
data = self.xrd(xrd_url)
return WebFingerResponse(data, insecure)