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:
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

View file

@ -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: