<commit_before>import hashlib
import urllib

# Adapted from https://github.com/zzzsochi/Flask-Gravatar/blob/master/flaskext/gravatar.py
def gravatar(user, use_ssl=False, d=None, r=None, size=None):

    if use_ssl:
        base_url = 'https://secure.gravatar.com/avatar/'
    else:
        base_url = 'http://www.gravatar.com/avatar/'

    # user can be a User instance or a username string
    username = user.username if hasattr(user, 'username') else user
    hash_code = hashlib.md5(unicode(username).encode('utf-8')).hexdigest()

    url = base_url + '?'

    _locals = locals()
    params = {param: _locals[param] for param in ['r', 'size'] if _locals[param] is not None}
    params['d'] = 'identicon'
    url = base_url + hash_code + '?' + urllib.urlencode(params)

    return url<commit_msg>Fix gravatar sizing<commit_after>import hashlib
import urllib

# Adapted from https://github.com/zzzsochi/Flask-Gravatar/blob/master/flaskext/gravatar.py
def gravatar(user, use_ssl=False, d=None, r=None, size=None):

    if use_ssl:
        base_url = 'https://secure.gravatar.com/avatar/'
    else:
        base_url = 'http://www.gravatar.com/avatar/'

    # user can be a User instance or a username string
    username = user.username if hasattr(user, 'username') else user
    hash_code = hashlib.md5(unicode(username).encode('utf-8')).hexdigest()

    url = base_url + '?'

    params = {'s': size}
    if r:
        params['r'] = r
    params['d'] = 'identicon'
    url = base_url + hash_code + '?' + urllib.urlencode(params)

    return url
{'fraction_non_alphanumeric': 0.1410090556274256, 'fraction_numerical': 0.00258732212160414, 'mean_word_length': 3.3824362606232294, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1333563', 'n_tokens_mistral': 548, 'n_tokens_neox': 531, 'n_words': 121}