-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.py
35 lines (29 loc) · 874 Bytes
/
check.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
import json
import sys
import anonymize
from typing import Union
import pprint
"""
Usage: python3 check.py [email] [results json filename]
"""
def audit(ballots: list, email: str) -> Union[bool, str]:
"""
Prints the ballot associated with the email
"""
for each_ballot in ballots:
if anonymize.verify_hash(email.rstrip().lower(), each_ballot["Email Address"]):
return each_ballot
return False
if __name__ == "__main__":
if len(sys.argv) == 3:
filename = sys.argv[2]
email = sys.argv[1]
elif len(sys.argv) == 2:
email = sys.argv[1]
else:
raise ValueError("Please provide [email] [json filename]!")
with open(filename) as f:
ballots = json.load(f)
specific_ballot = audit(ballots, email)
print("Was this your ballot:")
pprint.pprint(specific_ballot)