forked from willowtreeapps/friday-shots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
46 lines (30 loc) · 962 Bytes
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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?')
print "'y' for a hit, 'n' for a miss, 's' to skip someone no longer playing, 'w' to wait"
random.shuffle(names)
results = {}
while names:
name = names.pop()
result = raw_input('[%d] %s: ' % (len(results) + 1, name))
result = result.lower()
if result in ('y', 'yes'):
results[name] = True
elif result in ('n', 'no'):
results[name] = False
elif result in ('w', 'wait'):
names.insert(0, name)
elif result in ('s', 'skip'):
continue
else:
print 'Unrecognized'
names.append(name)
with open('data.json', 'r') as f:
data = json.load(f)
data.append({'date': str(datetime.now().date()), 'results': results})
with open('data.json', 'w') as f:
json.dump(data, f, indent=2)