def avatar_for_email(email, size=80, skip_cache=False):
 if (email == u''):
  email = u'noreply@weblate.org'
 mail_hash = hashlib.md5(email.lower().encode(u'utf-8')).hexdigest()
 cache_key = u'-'.join((u'avatar', mail_hash, str(size)))
 cache = caches[u'default']
 url = cache.get(cache_key)
 if ((url is not None) and (not skip_cache)):
  return url
 if HAS_LIBRAVATAR:
  url = libravatar.libravatar_url(email=email, https=True, default=appsettings.AVATAR_DEFAULT_IMAGE, size=size)
 else:
  url = u'{0}avatar/{1}?d={2}&s={3}'.format(appsettings.AVATAR_URL_PREFIX, mail_hash, quote(appsettings.AVATAR_DEFAULT_IMAGE), str(size))
 cache.set(cache_key, url)
 return url

def avatar_for_email ( email , size = 80 , skip_cache = False ) : if ( email == u'' ) : email = u'noreply@weblate.org' mail_hash = hashlib . md5 ( email . lower ( ) . encode ( u'utf-8' ) ) . hexdigest ( ) cache_key = u'-' . join ( ( u'avatar' , mail_hash , str ( size ) ) ) cache = caches [ u'default' ] url = cache . get ( cache_key ) if ( ( url is not None ) and ( not skip_cache ) ) : return url if HAS_LIBRAVATAR : url = libravatar . libravatar_url ( email = email , https = True , default = appsettings . AVATAR_DEFAULT_IMAGE , size = size ) else : url = u'{0}avatar/{1}?d={2}&s={3}' . format ( appsettings . AVATAR_URL_PREFIX , mail_hash , quote ( appsettings . AVATAR_DEFAULT_IMAGE ) , str ( size ) ) cache . set ( cache_key , url ) return url
generates url for avatar .