Change package name to webfinger. Closes #4.

pull/9/head
Jeremy Carbaugh 2012-07-30 17:47:25 -04:00
rodzic c57f388b20
commit ad53da5dce
3 zmienionych plików z 21 dodań i 15 usunięć

Wyświetl plik

@ -1,13 +1,13 @@
================ =========
python-webfinger webfinger
================ =========
Usage Usage
===== =====
Example:: Example::
from pywebfinger import finger from webfinger import finger
wf = finger('user@host.com') wf = finger('user@host.com')
print wf.profile print wf.profile

Wyświetl plik

@ -1,16 +1,16 @@
from distutils.core import setup from distutils.core import setup
from pywebfinger import __version__ from webfinger import __version__
long_description = open('README.rst').read() long_description = open('README.rst').read()
setup(name="python-webfinger", setup(name="webfinger",
version=str(__version__), version=str(__version__),
py_modules=["pywebfinger"], py_modules=["webfinger"],
description="Simple Python implementation of webfinger client protocol", description="Simple Python implementation of webfinger client protocol",
author="Jeremy Carbaugh", author="Jeremy Carbaugh",
author_email="jcarbaugh@gmail.com", author_email="jcarbaugh@gmail.com",
license='BSD', license='BSD',
url="http://github.com/jcarbaugh/python-webfinger/", url="http://github.com/jcarbaugh/webfinger/",
long_description=long_description, long_description=long_description,
install_requires=["python-xrd"], install_requires=["python-xrd"],
platforms=["any"], platforms=["any"],

Wyświetl plik

@ -1,6 +1,7 @@
import urllib, urllib2 import urllib
import urllib2
__version__ = '0.1' __version__ = '0.2'
RELS = { RELS = {
'activity_streams': 'http://activitystrea.ms/spec/1.0', 'activity_streams': 'http://activitystrea.ms/spec/1.0',
@ -25,9 +26,11 @@ UNOFFICIAL_ENDPOINTS = {
'twitter.com': 'twitter-webfinger.appspot.com', 'twitter.com': 'twitter-webfinger.appspot.com',
} }
class WebFingerException(Exception): class WebFingerException(Exception):
pass pass
class WebFingerResponse(object): class WebFingerResponse(object):
def __init__(self, xrd, insecure): def __init__(self, xrd, insecure):
@ -39,13 +42,14 @@ class WebFingerResponse(object):
return self._xrd.find_link(RELS[name], attr='href') return self._xrd.find_link(RELS[name], attr='href')
return getattr(self._xrd, name) return getattr(self._xrd, name)
class WebFingerClient(object): class WebFingerClient(object):
def __init__(self, host, timeout=None, official=False): def __init__(self, host, timeout=None, official=False):
self._host = host self._host = host
self._official = official self._official = official
self._opener = urllib2.build_opener(urllib2.HTTPRedirectHandler()) self._opener = urllib2.build_opener(urllib2.HTTPRedirectHandler())
self._opener.addheaders = [('User-agent', 'python-webfinger')] self._opener.addheaders = [('User-agent', 'github.com/jcarbaugh/webfinger')]
self._timeout = timeout self._timeout = timeout
@ -95,6 +99,7 @@ class WebFingerClient(object):
data = self.xrd(xrd_url) data = self.xrd(xrd_url)
return WebFingerResponse(data, insecure) return WebFingerResponse(data, insecure)
def finger(identifier, timeout=None, official=False): def finger(identifier, timeout=None, official=False):
if identifier.startswith('acct:'): if identifier.startswith('acct:'):
(acct, identifier) = identifier.split(':', 1) (acct, identifier) = identifier.split(':', 1)
@ -102,6 +107,7 @@ def finger(identifier, timeout=None, official=False):
client = WebFingerClient(host, timeout=timeout, official=official) client = WebFingerClient(host, timeout=timeout, official=official)
return client.finger(username) return client.finger(username)
if __name__ == '__main__': if __name__ == '__main__':
# example usage # example usage