Skip to content

Instantly share code, notes, and snippets.

@rhelmer
Created December 29, 2011 20:54
Show Gist options
  • Select an option

  • Save rhelmer/1536146 to your computer and use it in GitHub Desktop.

Select an option

Save rhelmer/1536146 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import json
import urllib2
url = 'https://github.com/mozilla/socorro/graphs/impact_data'
data = json.load(urllib2.urlopen(url))
attribs = {'n': 'username', 'a': 'additions', 'c': 'commits', 'd': 'deletions'}
results = {}
for n in data['authors']:
entry = data['authors'][n]
impact = entry['a'] + entry['d']
results[impact] = {}
for attrib in attribs:
name = attribs[attrib]
value = entry[attrib]
if name == 'username':
value = value.split('@')[0]
results[impact][name] = value
keylist = results.keys()
keylist.sort(reverse=True)
for impact in keylist:
print results[impact]['username']
del results[impact]['username']
print '\timpact(add+del):\t%s' % impact
for r in results[impact]:
print '\t%s:\t\t%s' % (r, results[impact][r])
print '---'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment