From 4e71f12254fd09d735b8f47b8a08c606324846f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Fri, 17 Sep 2021 09:48:16 +0200 Subject: [PATCH] handle invalid lecture file format with invalid title --- scripts/lectures.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scripts/lectures.py b/scripts/lectures.py index a91556e..5801e04 100644 --- a/scripts/lectures.py +++ b/scripts/lectures.py @@ -30,12 +30,17 @@ class Lecture: break # number = int(lecture_match.group(1)) + if lecture_match: + date_str = lecture_match.group(2) + date = datetime.strptime(date_str, DATE_FORMAT) + week = get_week(date) - date_str = lecture_match.group(2) - date = datetime.strptime(date_str, DATE_FORMAT) - week = get_week(date) + title = lecture_match.group(3) + else: + date = datetime.min + week = get_week(date) - title = lecture_match.group(3) + title = 'Error while parsing lecture file' self.file_path = file_path self.date = date