Differentiate between path and "ID"

This commit is contained in:
Matej Focko 2019-12-02 10:52:57 +01:00
parent a79b3f4319
commit 6a7438c217
2 changed files with 8 additions and 7 deletions

View file

@ -15,7 +15,7 @@ from submission import Submission, print_submissions
class Parser: class Parser:
INFO_REGEX = re.compile(r"(\d{6}) \| (x\S*)\s*") 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*") POINTS_REGEX = re.compile(r"\*\scelkový počet bodů\s+((\d|\.)*)\s*")
DATE_FORMAT = "%Y_%m%d_%H%M%S" DATE_FORMAT = "%Y_%m%d_%H%M%S"
OFFSET_FOR_CORRECTION = datetime.timedelta(days=8) OFFSET_FOR_CORRECTION = datetime.timedelta(days=8)
@ -37,7 +37,7 @@ class Parser:
@staticmethod @staticmethod
def parse_submission(mail: mboxMessage) -> str: def parse_submission(mail: mboxMessage) -> str:
match = Parser.get_match_from_mail(Parser.SUBMISSION_REGEX, mail) match = Parser.get_match_from_mail(Parser.SUBMISSION_REGEX, mail)
return match.group(1) return match.group(1), match.group(2)
@staticmethod @staticmethod
def parse_points(mail: mboxMessage) -> float: def parse_points(mail: mboxMessage) -> float:
@ -60,7 +60,7 @@ class Parser:
for mail in self.box.values(): for mail in self.box.values():
uco, login = Parser.parse_info(mail) uco, login = Parser.parse_info(mail)
path = Parser.parse_submission(mail) path, submission_id = Parser.parse_submission(mail)
points = Parser.parse_points(mail) points = Parser.parse_points(mail)
submissions.append( submissions.append(
@ -68,6 +68,7 @@ class Parser:
uco, uco,
login, login,
path, path,
submission_id,
points, points,
hw_tag, hw_tag,
self.correction, self.correction,
@ -130,8 +131,6 @@ class Parser:
result = [] result = []
for something in submissions.values(): for something in submissions.values():
functools.reduce( functools.reduce(__reducer, something, result)
__reducer, something, result,
)
return result return result

View file

@ -12,6 +12,7 @@ class Submission:
uco: str, uco: str,
login: str, login: str,
path: str, path: str,
submission_id: str,
points: float, points: float,
homework: str, homework: str,
correction: bool, correction: bool,
@ -20,6 +21,7 @@ class Submission:
self.uco = uco self.uco = uco
self.login = login self.login = login
self.path = path self.path = path
self.submission_id = submission_id
self.points = points self.points = points
self.homework = homework self.homework = homework
self.correction = correction self.correction = correction
@ -33,7 +35,7 @@ class Submission:
def __set_submission_date(self) -> None: def __set_submission_date(self) -> None:
self.submitted_at = datetime.datetime.strptime( 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: def set_late_tag(self, deadline: datetime.datetime) -> None: