1
0
mirror of synced 2024-11-23 21:20:56 +01:00

parsers.py: Allow songs with LEVEL: <1 and >10

This commit is contained in:
Viv 2024-02-10 13:26:36 -05:00
parent 3dbf82309e
commit 88ac7b7eac

View File

@ -98,10 +98,11 @@ def split_tja_lines_into_courses(lines: List[str]) -> TJASong:
current_course = NORMALIZE_COURSE[value]
current_course_basename = current_course
elif name_upper == 'LEVEL':
if value not in ['1', '2', '3', '4', '5',
'6', '7', '8', '9', '10']:
raise ValueError(f"Invalid LEVEL value: '{value}")
parsed_tja.courses[current_course].level = int(value)
if not value.isdigit():
raise ValueError(f"Invalid LEVEL value: '{value}'")
# restrict to 1 <= level <= 10
parsed_level = min(max(int(value), 1), 10)
parsed_tja.courses[current_course].level = parsed_level
elif name_upper == 'SCOREINIT':
parsed_tja.courses[current_course].score_init = \
int(value.split(",")[-1]) if value else 0