Add deadline check
This commit is contained in:
parent
4e80820ede
commit
4cba81140d
1 changed files with 16 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
|
||||
import datetime
|
||||
from mailbox import mbox, mboxMessage
|
||||
import re
|
||||
from typing import Tuple
|
||||
|
@ -10,6 +11,8 @@ class Parser:
|
|||
INFO_REGEX = re.compile(r"(\d{6}) \| (x\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)
|
||||
|
||||
@staticmethod
|
||||
def get_match_from_mail(regex: re.Pattern, mail: mboxMessage) -> re.Match:
|
||||
|
@ -35,9 +38,20 @@ class Parser:
|
|||
match = Parser.get_match_from_mail(Parser.POINTS_REGEX, mail)
|
||||
return float(match.group(1))
|
||||
|
||||
def __init__(self, path: str) -> None:
|
||||
self.path = path
|
||||
def submitted_before_deadline(self, submission: str) -> bool:
|
||||
submitted = datetime.datetime.strptime(
|
||||
submission.split("/")[-1][-16:], Parser.DATE_FORMAT
|
||||
)
|
||||
return self.deadline > submitted
|
||||
|
||||
def __init__(self, path: str, deadline: str, correction: bool = False) -> None:
|
||||
self.box = mbox(path)
|
||||
self.deadline = datetime.datetime.strptime(deadline, Parser.DATE_FORMAT)
|
||||
if correction:
|
||||
# in case of correction pass the date of
|
||||
# submitting review to IS for automatic computation
|
||||
self.deadline = self.deadline.replace(hour=0, minute=0, second=0)
|
||||
self.deadline += Parser.OFFSET_FOR_CORRECTION
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Reference in a new issue