From b4c88ba22974c08abb50d269ba81f83f0bcdad06 Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 10:08:28 -0400 Subject: [PATCH 1/2] Removed dependancy on requsts (urllib2 and json instead). --- gitfiti.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gitfiti.py b/gitfiti.py index 6e4b017b0..2ac4a898f 100755 --- a/gitfiti.py +++ b/gitfiti.py @@ -1,10 +1,5 @@ #!/usr/bin/env python -import os, sys, datetime, math, itertools -try: - import requests -except: - print 'the requests module is required' - exit(1) +import os, sys, datetime, math, itertools, urllib2, json title=''' ''' @@ -96,8 +91,8 @@ def get_calendar(username): """retrieves the github commit calendar data for a username""" BASEURL='https://github.com/' url = BASEURL + 'users/' + username + '/contributions_calendar_data' - req = requests.get(url) - return req.json() + page = urllib2.urlopen(url).read() + return json.loads(page) def max_commits(input): """finds the highest number of commits in one day""" From d639d759bf2651d7d6727a3f0e142302d8df8016 Mon Sep 17 00:00:00 2001 From: William Povell Date: Tue, 21 May 2013 11:13:22 -0400 Subject: [PATCH 2/2] Used json.load instead of loads (no need to read out file). --- gitfiti.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitfiti.py b/gitfiti.py index 2ac4a898f..61cc45e47 100755 --- a/gitfiti.py +++ b/gitfiti.py @@ -91,8 +91,8 @@ def get_calendar(username): """retrieves the github commit calendar data for a username""" BASEURL='https://github.com/' url = BASEURL + 'users/' + username + '/contributions_calendar_data' - page = urllib2.urlopen(url).read() - return json.loads(page) + page = urllib2.urlopen(url) + return json.load(page) def max_commits(input): """finds the highest number of commits in one day"""