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,14 +1,14 @@
================
python-webfinger
================
=========
webfinger
=========
Usage
=====
Example::
from pywebfinger import finger
from webfinger import finger
wf = finger('user@host.com')
print wf.profile
print wf.hcard
@ -23,7 +23,7 @@ The following relation types are supported:
* portable_contacts: http://portablecontacts.net/spec/1.0
* profile: http://webfinger.net/rel/profile-page
* xfn: http://gmpg.org/xfn/11
Other relation types can be accessed directly from the XRD document.::
print wf.find_link('http://example.com/example/spec', attr='href')

Wyświetl plik

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

Wyświetl plik

@ -1,6 +1,7 @@
import urllib, urllib2
import urllib
import urllib2
__version__ = '0.1'
__version__ = '0.2'
RELS = {
'activity_streams': 'http://activitystrea.ms/spec/1.0',
@ -25,9 +26,11 @@ UNOFFICIAL_ENDPOINTS = {
'twitter.com': 'twitter-webfinger.appspot.com',
}
class WebFingerException(Exception):
pass
class WebFingerResponse(object):
def __init__(self, xrd, insecure):
@ -39,13 +42,14 @@ class WebFingerResponse(object):
return self._xrd.find_link(RELS[name], attr='href')
return getattr(self._xrd, name)
class WebFingerClient(object):
def __init__(self, host, timeout=None, official=False):
self._host = host
self._official = official
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
@ -62,7 +66,7 @@ class WebFingerClient(object):
conn = self._opener.open(url, timeout=self._timeout)
response = conn.read()
conn.close()
return response if raw else XRD.parse(response)
def hostmeta(self, protocol):
@ -95,6 +99,7 @@ class WebFingerClient(object):
data = self.xrd(xrd_url)
return WebFingerResponse(data, insecure)
def finger(identifier, timeout=None, official=False):
if identifier.startswith('acct:'):
(acct, identifier) = identifier.split(':', 1)
@ -102,6 +107,7 @@ def finger(identifier, timeout=None, official=False):
client = WebFingerClient(host, timeout=timeout, official=official)
return client.finger(username)
if __name__ == '__main__':
# example usage