Move out of try block, fix typo, add line number
This commit is contained in:
parent
16ee5fd08d
commit
d88afa7a58
1 changed files with 8 additions and 7 deletions
9
table.py
9
table.py
|
@ -37,17 +37,18 @@ for line_nr, line in enumerate(sys.stdin, start=1):
|
|||
|
||||
try:
|
||||
del users[awardee][post_id][verifier]
|
||||
# If no more verifiers left, the dict, this makes it easier to count
|
||||
except KeyError:
|
||||
print(f"Line {line_nr}: trying to remove non-existing verification by {verifier}, looks like the file is corrupt!", file=sys.stderr)
|
||||
|
||||
# If no more verifiers left, clean up the dicts, this makes it easier to count
|
||||
if not users[awardee][post_id]:
|
||||
del users[awardee][post_id]
|
||||
if not users[awardee]:
|
||||
del users[awardee]
|
||||
except KeyError:
|
||||
print(f"Trying to remove non-existing verification by {verifier}, looks like the file is corrupt!", file=sys.stderr)
|
||||
|
||||
continue
|
||||
|
||||
print(f"Couldn't parse line, looks like the file is corrupt: {line}", file=sys.stderr)
|
||||
print(f"Couldn't parse line {line_nr}, looks like the file is corrupt: {line}", file=sys.stderr)
|
||||
|
||||
for username, user_posts in users.items():
|
||||
print(f"{username}: {len(user_posts)}")
|
||||
|
|
Loading…
Reference in a new issue