Skip to content

Commit

Permalink
Fixed compatibility with Python 3 in the gravatar module.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-waldenberg committed Jul 27, 2013
1 parent 20d8227 commit b219937
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gitinspector/gravatar.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@
# You should have received a copy of the GNU General Public License
# along with gitinspector. If not, see <http://www.gnu.org/licenses/>.

from __future__ import unicode_literals
try:
from urllib.parse import urlencode
except:
from urllib import urlencode
import format
import hashlib
import urllib

def get_url(email, size=20):
md5hash = hashlib.md5(email.lower().strip()).hexdigest()
md5hash = hashlib.md5(email.encode("utf-8").lower().strip()).hexdigest()
base_url = "http://www.gravatar.com/avatar/" + md5hash
params = None

Expand All @@ -31,4 +35,4 @@ def get_url(email, size=20):
elif format.get_selected() == "xml":
params = {"default": "identicon"}

return base_url + "?" + urllib.urlencode(params)
return base_url + "?" + urlencode(params)

0 comments on commit b219937

Please sign in to comment.