# Path: yithlibraryserver/compat.py
# PY3 = sys.version_info[0] == 3
#     def encode_header(obj):  # pragma: no cover
#     def encode_header(obj):  # pragma: no cover


import hashlib
from yithlibraryserver.compat import url_encode

    def get_email_hash(self, email):
        return hashlib.md5(email.lower().encode('utf-8')).hexdigest()

    def get_image_url(self, size=32):
        default_image_url = self.default_image_url

        email = self.get_email()
        if not email:
            return default_image_url

        email_hash = self.get_email_hash(email)
        parameters = {
            'd': default_image_url,
            's': size,
            }
        gravatar_url = 'https://www.gravatar.com/avatar/%s?%s' % (
            email_hash, url_encode(parameters))

        return gravatar_url

    def has_avatar(self):
        return self.get_email() is not None

    def get_email(self):
        user = self.request.user
        if user is None:
            return None

        email = user.get('email', '')

# Path: yithlibraryserver/compat.py
# PY3 = sys.version_info[0] == 3
#     def encode_header(obj):  # pragma: no cover
#     def encode_header(obj):  # pragma: no cover


# Path: yithlibraryserver/user/gravatar.py
import hashlib
from yithlibraryserver.compat import url_encode


    def get_email_hash(self, email):
        return hashlib.md5(email.lower().encode('utf-8')).hexdigest()

    def get_image_url(self, size=32):
        default_image_url = self.default_image_url

        email = self.get_email()
        if not email:
            return default_image_url

        email_hash = self.get_email_hash(email)
        parameters = {
            'd': default_image_url,
            's': size,
            }
        gravatar_url = 'https://www.gravatar.com/avatar/%s?%s' % (
            email_hash, url_encode(parameters))

        return gravatar_url

    def has_avatar(self):
        return self.get_email() is not None

    def get_email(self):
        user = self.request.user
        if user is None:
            return None

        email = user.get('email', '')

        if not email: