Skip to content

Commit

Permalink
Merge pull request #21 from agoravoting/id-warnings
Browse files Browse the repository at this point in the history
show warning when election id doesn't match filename
  • Loading branch information
Findeton authored Jun 12, 2017
2 parents a14b875 + d2c94fc commit d03d7c3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions import_election_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ def form_to_elections(path, separator, config, add_to_id):
file_path = os.path.join(args.input_path, name)
blocks = csv_to_blocks(path=file_path, separator=separator)
election = blocks_to_election(blocks, config, args.add_to_id)

if str(election['id']) + extension != name:
print("WARNING: election id %i doesn't match filename %s" % (election['id'], name))

if not args.admin_format:
output_path = os.path.join(args.output_path, str(election['id']) + ".config.json")
Expand Down Expand Up @@ -387,6 +390,9 @@ def form_to_elections(path, separator, config, add_to_id):
blocks = csv_to_blocks(path=args.input_path, separator=separator)
election = blocks_to_election(blocks, config, args.add_to_id)

if str(election['id']) + extension != os.path.basename(args.input_path):
print("WARNING: election id %i doesn't match filename %s" % (election['id'], os.path.basename(args.input_path)))

with open(args.output_path, mode='w', encoding="utf-8", errors='strict') as f:
f.write(serialize(election))
else:
Expand Down

0 comments on commit d03d7c3

Please sign in to comment.