changed max_commits() and get_calendar() to fix issue #17
This commit is contained in:
16
gitfiti.py
16
gitfiti.py
@ -174,23 +174,21 @@ def get_calendar(username, base_url='https://github.com/'):
|
|||||||
try:
|
try:
|
||||||
url = base_url + '/contributions'
|
url = base_url + '/contributions'
|
||||||
page = urllib2.urlopen(url)
|
page = urllib2.urlopen(url)
|
||||||
except (urllib2.HTTPError,urllib2.URLError) as e:
|
|
||||||
print ("There was a problem fetching data from {0}".format(url))
|
|
||||||
print (e)
|
|
||||||
try:
|
|
||||||
url = base_url + '/contributions_calendar_data'
|
|
||||||
page = urllib2.urlopen(url)
|
|
||||||
except (urllib2.HTTPError,urllib2.URLError) as e:
|
except (urllib2.HTTPError,urllib2.URLError) as e:
|
||||||
print ("There was a problem fetching data from {0}".format(url))
|
print ("There was a problem fetching data from {0}".format(url))
|
||||||
print (e)
|
print (e)
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
return json.load(page)
|
return page.readlines()
|
||||||
|
|
||||||
def max_commits(input):
|
def max_commits(input):
|
||||||
"""finds the highest number of commits in one day"""
|
"""finds the highest number of commits in one day"""
|
||||||
output = set()
|
output = set()
|
||||||
for i, j in enumerate(input):
|
for line in input:
|
||||||
output.add(input[i][1])
|
for day in line.split():
|
||||||
|
if "data-count=" in day:
|
||||||
|
commit = day.split('=')[1]
|
||||||
|
commit = commit.strip('"')
|
||||||
|
output.add(int(commit))
|
||||||
output = list(output)
|
output = list(output)
|
||||||
output.sort()
|
output.sort()
|
||||||
output.reverse()
|
output.reverse()
|
||||||
|
Reference in New Issue
Block a user