txLibravatar-1.1/ 0000755 0001750 0001750 00000000000 11665013500 015445 5 ustar francois francois 0000000 0000000 txLibravatar-1.1/setup.py 0000644 0001750 0001750 00000002257 11665013415 017172 0 ustar francois francois 0000000 0000000 from distutils.core import setup
setup(
name = 'txLibravatar',
version = '1.1',
description = 'Twisted module for Libravatar',
author = 'Francois Marier',
author_email = 'francois@libravatar.org',
url = 'https://launchpad.net/txlibravatar',
py_modules = ['txlibravatar'],
license = 'MIT',
keywords = ['libravatar', 'avatars', 'autonomous', 'social', 'federated', 'twisted'],
requires = ['pyLibravatar', 'TwistedNames'],
classifiers = [
"Framework :: Twisted",
"Programming Language :: Python",
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries :: Python Modules",
],
long_description = """\
txLibravatar is an easy way to make use of the federated `Libravatar`_
avatar hosting service from within your Twisted applications.
See the `project page`_ to file bugs or ask questions.
.. _Libravatar: https://www.libravatar.org/
.. _project page: https://launchpad.net/txlibravatar
"""
)
txLibravatar-1.1/README.txt 0000644 0001750 0001750 00000003736 11651505700 017157 0 ustar francois francois 0000000 0000000 # txLibravatar
txLibravatar is an easy way to make use of the federated [Libravatar](http://www.libravatar.org)
avatar hosting service from within your Twisted applications.
See the [project page](https://launchpad.net/txlibravatar) for the bug tracker and downloads.
## Installation
To install using pip, simply do this:
$ pip install txLibravatar
## Usage
To generate the correct avatar URL based on someone's email address, use the
following:
>>> d = libravatar_url(email = 'person@example.com')
>>> d.addCallback(lambda x: print '
')
Here are other options you can provide:
>>> d = libravatar_url(openid = 'http://example.org/id/Bob', https = True, size = 96, default = 'mm')
See the [Libravatar documentation](http://wiki.libravatar.org/api) for more
information on the special values for the "default" parameter.
## License
Copyright (C) 2011 Francois Marier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
txLibravatar-1.1/PKG-INFO 0000644 0001750 0001750 00000002102 11665013500 016535 0 ustar francois francois 0000000 0000000 Metadata-Version: 1.1
Name: txLibravatar
Version: 1.1
Summary: Twisted module for Libravatar
Home-page: https://launchpad.net/txlibravatar
Author: Francois Marier
Author-email: francois@libravatar.org
License: MIT
Description: txLibravatar is an easy way to make use of the federated `Libravatar`_
avatar hosting service from within your Twisted applications.
See the `project page`_ to file bugs or ask questions.
.. _Libravatar: https://www.libravatar.org/
.. _project page: https://launchpad.net/txlibravatar
Keywords: libravatar,avatars,autonomous,social,federated,twisted
Platform: UNKNOWN
Classifier: Framework :: Twisted
Classifier: Programming Language :: Python
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires: pyLibravatar
Requires: TwistedNames
txLibravatar-1.1/txlibravatar.py 0000644 0001750 0001750 00000006474 11651476551 020553 0 ustar francois francois 0000000 0000000 """
TxLibravatar Twisted module for Libravatar
Copyright (C) 2011 Francois Marier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
# pylint: disable=F0401
from libravatar import compose_avatar_url, service_name, normalized_target
from libravatar import parse_user_identity, parse_options
from twisted.internet import defer
from twisted.names import client, dns
from twisted.names.error import DNSNameError, DNSServerError, DNSFormatError
from twisted.names.error import DNSNotImplementedError, DNSQueryRefusedError
from twisted.names.error import DNSUnknownError, ResolverError
def libravatar_url(email=None, openid=None, https=False,
default=None, size=None):
"""
Return a URL to the appropriate avatar
"""
avatar_hash, domain = parse_user_identity(email, openid)
query_string = parse_options(default, size)
d = lookup_avatar_server(domain, https)
d.addCallback(compose_avatar_url, avatar_hash, query_string, https)
return d
def parse_srv_response(result, https):
"""
Extract the avatar servers from SRV records in the DNS zone
The SRV records should look like this:
_avatars._tcp.example.com. IN SRV 0 0 80 avatars.example.com
_avatars-sec._tcp.example.com. IN SRV 0 0 443 avatars.example.com
"""
(answer, unused, unused) = result
records = []
for record in answer:
if record.type != dns.SRV:
continue
srv_record = {'priority': int(record.payload.priority),
'weight': int(record.payload.weight),
'port': int(record.payload.port),
'target': record.payload.target}
records.append(srv_record)
return normalized_target(records, https)
def error_handler(failure):
"""
Swallow all DNS-related errors and simply default to
libravatar.org in these cases.
"""
failure.trap(DNSNameError, DNSServerError, DNSFormatError,
DNSNotImplementedError, DNSQueryRefusedError,
DNSUnknownError, ResolverError)
def lookup_avatar_server(domain, https):
"""
Return the avatar server to federate to (if any).
"""
if not domain:
return defer.succeed(None)
d = client.lookupService(service_name(domain, https))
d.addCallback(parse_srv_response, https)
d.addErrback(error_handler)
return d
txLibravatar-1.1/Changelog.txt 0000644 0001750 0001750 00000000212 11665012631 020074 0 ustar francois francois 0000000 0000000 1.1 (2011-11-29)
- Add missing dependency on Twisted Names
- Add example to README
1.0 (2011-10-25)
- Initial public release