1
0
mirror of synced 2024-11-28 06:50:49 +01:00

parsers.py: Account for blank header metadata

Some charters are too lazy to add scoreInit/scoreDiff/etc. values
This commit is contained in:
Viv 2023-06-02 16:33:48 -04:00
parent 0a3a4ae4e6
commit 4b194e5f71

View File

@ -54,7 +54,7 @@ def parseTJA(tja):
def parseLine(line):
# Regex matches for various line types
match_comment = re.match(r"//.*", line)
match_header = re.match(r"^([A-Z]+):(.+)", line)
match_header = re.match(r"^([A-Z]+):(.*)", line)
match_command = re.match(r"^#([A-Z]+)(?:\s+(.+))?", line)
match_data = re.match(r"^(([0-9]|A|B|C|F|G)*,?)$", line)
@ -87,11 +87,11 @@ def getCourse(tjaHeaders, lines):
if line["name"] == 'COURSE':
headers['course'] = line['value']
elif line["name"] == 'LEVEL':
headers['level'] = int(line['value'])
headers['level'] = int(line['value']) if line['value'] else 0
elif line["name"] == 'SCOREINIT':
headers['scoreInit'] = int(line['value'])
headers['scoreInit'] = int(line['value']) if line['value'] else 0
elif line["name"] == 'SCOREDIFF':
headers['scoreDiff'] = int(line['value'])
headers['scoreDiff'] = int(line['value']) if line['value'] else 0
elif line["name"] == 'BALLOON':
if line['value']:
balloons = [int(v) for v in line['value'].split(",")]