@register.simple_tag
def user_avatar(user, secure=False, size=256, rating='pg', default=''):

    try:
        profile = user.get_profile()
        if profile.avatar:
            return profile.avatar.url
    except SiteProfileNotAvailable:
        pass
    except __HOLE__:
        pass
    except AttributeError:
        pass

    base_url = (secure and 'https://secure.gravatar.com' or
        'http://www.gravatar.com')
    m = hashlib.md5(user.email)
    return '%(base_url)s/avatar/%(hash)s?%(params)s' % dict(
        base_url=base_url, hash=m.hexdigest(),
        params=urllib.urlencode(dict(
            s=size, d=default, r=rating
        ))
    )
dataset/ETHPy150Open mozilla/django-badger/badger/templatetags/badger_tags.py/user_avatar