Created
November 9, 2016 15:40
-
-
Save benregn/21dee306f449b6a2ba3f0166b1d9f12f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from collections import defaultdict | |
import requests | |
token = '<github-access-token>' | |
gh_url = 'https://api.github.com' | |
headers = {'Authorization': 'token {}'.format(token)} | |
resp = requests.get(gh_url + '/users/benregn/events', headers=headers) | |
happenings = defaultdict(lambda: defaultdict(list)) | |
for each in resp.json(): | |
if each['type'] != 'PushEvent': | |
continue | |
created_date, created_time = each['created_at'][:-1].split('T') | |
repo_name = each['repo']['name'] | |
commits = [ | |
{ | |
'message': c['message'], | |
'time': created_time, | |
} | |
for c in each['payload']['commits'] | |
] | |
happenings[created_date][repo_name].extend(commits) | |
print(json.dumps(happenings, indent=2, sort_keys=True)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment