parsers.py
: Account for blank header metadata
Some charters are too lazy to add scoreInit/scoreDiff/etc. values
This commit is contained in:
parent
0a3a4ae4e6
commit
4b194e5f71
@ -54,7 +54,7 @@ def parseTJA(tja):
|
|||||||
def parseLine(line):
|
def parseLine(line):
|
||||||
# Regex matches for various line types
|
# Regex matches for various line types
|
||||||
match_comment = re.match(r"//.*", line)
|
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_command = re.match(r"^#([A-Z]+)(?:\s+(.+))?", line)
|
||||||
match_data = re.match(r"^(([0-9]|A|B|C|F|G)*,?)$", 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':
|
if line["name"] == 'COURSE':
|
||||||
headers['course'] = line['value']
|
headers['course'] = line['value']
|
||||||
elif line["name"] == 'LEVEL':
|
elif line["name"] == 'LEVEL':
|
||||||
headers['level'] = int(line['value'])
|
headers['level'] = int(line['value']) if line['value'] else 0
|
||||||
elif line["name"] == 'SCOREINIT':
|
elif line["name"] == 'SCOREINIT':
|
||||||
headers['scoreInit'] = int(line['value'])
|
headers['scoreInit'] = int(line['value']) if line['value'] else 0
|
||||||
elif line["name"] == 'SCOREDIFF':
|
elif line["name"] == 'SCOREDIFF':
|
||||||
headers['scoreDiff'] = int(line['value'])
|
headers['scoreDiff'] = int(line['value']) if line['value'] else 0
|
||||||
elif line["name"] == 'BALLOON':
|
elif line["name"] == 'BALLOON':
|
||||||
if line['value']:
|
if line['value']:
|
||||||
balloons = [int(v) for v in line['value'].split(",")]
|
balloons = [int(v) for v in line['value'].split(",")]
|
||||||
|
Loading…
Reference in New Issue
Block a user