Skip to content

Commit

Permalink
fix exception caused by malformed "Teacher (Stunde)"
Browse files Browse the repository at this point in the history
  • Loading branch information
Belissimo-T committed Nov 18, 2023
1 parent 6692dcf commit 9f9a680
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions backend/vplan_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,19 @@ def periods_to_block_label(periods: typing.Iterable[int]) -> str:


def _parse_periods(period_str: str) -> list[int]:
def period_str_to_int(string: str) -> int:
return int(string.replace("Stunde", "").replace(".", ""))
try:
def period_str_to_int(string: str) -> int:
return int(string.replace("Stunde", "").replace(".", ""))

if not period_str:
if not period_str:
return []
elif "-" not in period_str:
return [period_str_to_int(period_str)]
else:
begin, end = period_str.split("-")
return list(range(period_str_to_int(begin), period_str_to_int(end) + 1))
except ValueError:
return []
elif "-" not in period_str:
return [period_str_to_int(period_str)]
else:
begin, end = period_str.split("-")
return list(range(period_str_to_int(begin), period_str_to_int(end) + 1))


def parse_periods(period_str: str) -> set[int]:
Expand Down

0 comments on commit 9f9a680

Please sign in to comment.