From 6a7438c21714d70a481cde62e1afd666c437d30c Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 2 Dec 2019 10:52:57 +0100 Subject: [PATCH] Differentiate between path and "ID" --- kontr_emails.py | 11 +++++------ submission.py | 4 +++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/kontr_emails.py b/kontr_emails.py index 029e21a..fc86e7a 100644 --- a/kontr_emails.py +++ b/kontr_emails.py @@ -15,7 +15,7 @@ from submission import Submission, print_submissions class Parser: INFO_REGEX = re.compile(r"(\d{6}) \| (x\S*)\s*") - SUBMISSION_REGEX = re.compile(r"adresář:\s+\S*\/(\S*)\s*") + SUBMISSION_REGEX = re.compile(r"adresář:\s+(\S*\/(\S*))\s*") POINTS_REGEX = re.compile(r"\*\scelkový počet bodů\s+((\d|\.)*)\s*") DATE_FORMAT = "%Y_%m%d_%H%M%S" OFFSET_FOR_CORRECTION = datetime.timedelta(days=8) @@ -37,7 +37,7 @@ class Parser: @staticmethod def parse_submission(mail: mboxMessage) -> str: match = Parser.get_match_from_mail(Parser.SUBMISSION_REGEX, mail) - return match.group(1) + return match.group(1), match.group(2) @staticmethod def parse_points(mail: mboxMessage) -> float: @@ -60,7 +60,7 @@ class Parser: for mail in self.box.values(): uco, login = Parser.parse_info(mail) - path = Parser.parse_submission(mail) + path, submission_id = Parser.parse_submission(mail) points = Parser.parse_points(mail) submissions.append( @@ -68,6 +68,7 @@ class Parser: uco, login, path, + submission_id, points, hw_tag, self.correction, @@ -130,8 +131,6 @@ class Parser: result = [] for something in submissions.values(): - functools.reduce( - __reducer, something, result, - ) + functools.reduce(__reducer, something, result) return result diff --git a/submission.py b/submission.py index 022a5be..f4a7ab9 100644 --- a/submission.py +++ b/submission.py @@ -12,6 +12,7 @@ class Submission: uco: str, login: str, path: str, + submission_id: str, points: float, homework: str, correction: bool, @@ -20,6 +21,7 @@ class Submission: self.uco = uco self.login = login self.path = path + self.submission_id = submission_id self.points = points self.homework = homework self.correction = correction @@ -33,7 +35,7 @@ class Submission: def __set_submission_date(self) -> None: self.submitted_at = datetime.datetime.strptime( - self.path.split("/")[-1][-16:], "%Y_%m%d_%H%M%S" + self.submission_id[-16:], "%Y_%m%d_%H%M%S" ) def set_late_tag(self, deadline: datetime.datetime) -> None: