Skip to content

Commit

Permalink
[build/screenshots] Add messages for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
PiaNumworks authored and MarcNumworks committed Apr 25, 2024
1 parent 27b6c25 commit e2ea684
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions build/screenshots/helpers/nws_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,21 @@ def convert_txt_to_nws(txtpath, nwspath):
sys.exit(1)
version = f.readline().strip()
formatVersion = int(f.readline())
assert 0 < formatVersion < 256
if formatVersion <= 0 or 256 <= formatVersion:
print("Error:", formatVersion, "is not a valid format version")
sys.exit(1)
language = f.readline().strip()
assert len(language) == 2
events = [events_ids[line.strip()] for line in f]
if len(language) != 2:
print("Error:", language, "is not a valid language")
sys.exit(1)
events = []
for line in f:
event = line.strip()
event_id = events_ids.get(event)
if event_id is None:
print("Error:", event, "is not a valid event")
sys.exit(1)
events.append(events_ids[event])

with open(nwspath, "wb") as f:
f.write(BIN_HEADER)
Expand Down

0 comments on commit e2ea684

Please sign in to comment.