forked from belowtheline/site_2014
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcandidate.py
29 lines (23 loc) · 802 Bytes
/
candidate.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
#!/usr/bin/env python
import json
while True:
first = raw_input('First name: ')
if not first:
break
last = raw_input('Last name : ')
party = raw_input('Party : ')
candidate = raw_input('Where : ')
filename = '{}-{}.json'.format(last.lower().translate(None, " -'"),
first.lower().translate(None, " -'"))
data = {
'first_name': first,
'last_name': last,
'party': party,
'candidate': candidate
}
if candidate.startswith('state'):
data['ballot_position'] = int(raw_input('Position : '))
open('data/people/' + filename, 'w').write(json.dumps(data, sort_keys=True,
indent=4, separators=(',', ': ')))
print open('data/people/' + filename).read()
print ""