profile.py 700 B

1234567891011121314151617181920212223242526272829303132333435
  1. """
  2. Profile fetching and processing.
  3. """
  4. from ostatus.fetcher import fetch
  5. from ostatus.webfinger import finger
  6. PROFILE = "http://webfinger.net/rel/profile-page"
  7. class ProfileError(Exception):
  8. """
  9. Report an error trying to fetch or process a profile.
  10. """
  11. pass
  12. def profile(identifier):
  13. """
  14. Given a webfinger address, find the profile page,
  15. and fetch that.
  16. """
  17. links = finger(identifier)
  18. profile_data = None
  19. for link in links:
  20. if link['rel'] == PROFILE:
  21. profile_data = fetch(link['href'])
  22. break
  23. if not profile_data:
  24. raise ProfileError('no links found to get profile')
  25. else:
  26. return profile_data