Created
November 8, 2011 20:38
-
-
Save ramalho/1349123 to your computer and use it in GitHub Desktop.
Generate report from pycon-pc IRC log - DOES NOT HANDLE SKIPPED TALKS
This file contains hidden or 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 | |
| from itertools import dropwhile | |
| import re | |
| START = re.compile(r'''<pycon_bot> ==== Talk (\d{1,3}): (.*?) now, (http://.*?) ====''') | |
| VOTES = re.compile(r'''<pycon_bot> Talk Votes: (\d+) yays, (\d+) nays, (\d+) abstentions''') | |
| DECISION = re.compile(r'''<pycon_bot> ==== Chair decision: talk (\w+)''') | |
| LINE_FORMAT = '{talk_id:>3} {decision} {yays:>2} {nays:>2} {abst:>2} {title}' | |
| def find_line(regex): | |
| lines = dropwhile(lambda s: not regex.search(s), log) | |
| found = next(lines).strip() | |
| return regex.search(found).groups() | |
| print LINE_FORMAT.format(talk_id='ID', decision='D', yays='Y', nays='N', abst='A', title='TALK TITLE') | |
| with open(sys.argv[1]) as log: | |
| while True: | |
| try: | |
| talk_id, title, url = find_line(START) | |
| yays, nays, abst = find_line(VOTES) | |
| decision = '+' if find_line(DECISION)[0][0] == 'a' else '-' | |
| print LINE_FORMAT.format(**locals()) | |
| except StopIteration: | |
| break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment