<s> import hashlib <EOL> import urllib <EOL> def gravatar ( user , use_ssl = False , d = None , r = None , size = None ) : <EOL> if use_ssl : <EOL> base_url = '<STR_LIT>' <EOL> else : <EOL> base_url = '<STR_LIT>' <EOL> username = user . username if hasattr ( user , '<STR_LIT:username>' ) else user <EOL> hash_code = hashlib . md5 ( unicode ( username ) . encode ( '<STR_LIT:utf-8>' ) ) . hexdigest ( ) <EOL> url = base_url + '<STR_LIT:?>' <EOL> params = [ <EOL> ( '<STR_LIT:d>' , '<STR_LIT>' ) <EOL> ] <EOL> if size : <EOL> params . append ( ( '<STR_LIT:s>' , size ) ) <EOL> if r : <EOL> params . append ( ( '<STR_LIT:r>' , r ) ) <EOL> url = base_url + hash_code + '<STR_LIT:?>' + urllib . urlencode ( params ) <EOL> return url </s>
