import hashlib


def gravatar(person_data, fallback_key, fallback_suffix):
    """
    Get a gravatar for an email address.

    Defaults to libravatar with a gravatar fallback
    Uses the "avatar" key if it exists, or defaults to school email.
    """
    email = person_data.get("avatar",
                            person_data[fallback_key] + fallback_suffix)
    email = email.encode('utf8').lower()
    slug = hashlib.md5(email).hexdigest()
    libravatarURL = "https://seccdn.libravatar.org/avatar/"
    gravatarURL = "https://secure.gravatar.com/avatar/"
    return libravatarURL + slug + "?d=" + gravatarURL + slug