def profile(identifier): """ Given a webfinger address, find the profile page, and fetch that. """ links = finger(identifier) profile_data = None for link in links: if link['rel'] == PROFILE: profile_data = fetch(link['href']) break if not profile_data: raise ProfileError('no links found to get profile') else: return profile_data
def status(identifier): """ Get the latest update from a webfinger address. """ links = finger(identifier) feed = None for link in links: if link['rel'] == UPDATES_FROM: feed = fetch(link['href']) break if not feed: raise StatusError('no links found to get status') else: entries = parse_feed(feed) if entries: return entries[0] else: raise StatusError('no data for %s' % identifier)
def hcard(identifier): """ Find the first hcard in a URI and parse it to usefulness. """ links = finger(identifier) hcard_uri = None for link in links: if link['rel'] == HCARD: data = fetch(link['href']) break if not data: raise HcardError('no links to get data') body = (minidom.parseString(data).documentElement.getElementsByTagName( 'body')[0]) vcard = _traverse_for_class(body, 'vcard', None) data = _traverse_for_data(vcard, HCARD_ELEMENTS) return data
def hcard(identifier): """ Find the first hcard in a URI and parse it to usefulness. """ links = finger(identifier) hcard_uri = None for link in links: if link['rel'] == HCARD: data = fetch(link['href']) break if not data: raise HcardError('no links to get data') body = (minidom.parseString(data).documentElement .getElementsByTagName('body')[0]) vcard = _traverse_for_class(body, 'vcard', None) data = _traverse_for_data(vcard, HCARD_ELEMENTS) return data
def test_webfinger(): links = finger('*****@*****.**') assert 'http://tiddlyspace.com/profiles/cdent' in [ link['href'] for link in links]
def test_webfinger(): links = finger('*****@*****.**') assert 'http://tiddlyspace.com/profiles/cdent' in [ link['href'] for link in links ]