Created
November 10, 2011 03:04
-
-
Save ramalho/1353990 to your computer and use it in GitHub Desktop.
Generate report from pycon-pc JSON
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 sys | |
import json | |
from itertools import dropwhile | |
LINE_FORMAT = '{id:>3} {mark} {yay:>2} {nay:>2} {abstain:>2} {name}' | |
with open(sys.argv[1]) as json_in: | |
talks = json.load(json_in) | |
for talk in dropwhile(lambda x:x['id']<264, talks): | |
if 'decision' not in talk: | |
break | |
else: | |
mark = {'rejected':'-', 'accepted': '+', 'poster': 'p' | |
}[talk['decision']] | |
votes = talk['votes'] if 'votes' in talk else dict( | |
yay=0, nay=0, abstain=0) | |
talk.update(votes) | |
print LINE_FORMAT.format(mark=mark, **talk) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment