генерация gravatar URL на python

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
from urllib import urlencode
try:
from hashlib import md5
except ImportError:
from md5 import md5
def getGravatarUrl(email, default="", size=64):
"""
Generates the address an gravatar
"""
return "http://www.gravatar.com/avatar.php?" + urlencode({
'gravatar_id':md5(email.lower()).hexdigest(),
'default':default,
'size':str(size)})