Skip to content

Instantly share code, notes, and snippets.

@ramalho
Created November 10, 2011 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramalho/1353990 to your computer and use it in GitHub Desktop.
Save ramalho/1353990 to your computer and use it in GitHub Desktop.
Generate report from pycon-pc JSON
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