Created
September 21, 2012 23:30
-
-
Save colinpollock/3764500 to your computer and use it in GitHub Desktop.
Code for running Friday Shots and persisting winner/loser results
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
from datetime import datetime | |
import json | |
import random | |
import sys | |
names = list(set(sys.argv[1:])) | |
print 'There are %d players: %s' % (len(names), ', '.join(sorted(names))) | |
raw_input('Continue?') | |
random.shuffle(names) | |
results = {} | |
for index, name in enumerate(names): | |
result = raw_input('[%d] %s: ' % (index, name)) | |
if result.lower() in ('y', 't', '1'): | |
results[name] = True | |
elif result.lower() == 'skip': | |
continue | |
else: | |
results[name] = False | |
with open('results.json', 'r') as f: | |
data = json.load(f) | |
data.append({'date': str(datetime.now().date()), 'results': results}) | |
with open('results.json', 'w') as f: | |
json.dump(data, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment