Allow processing of given IDs instead of mailbox
This commit is contained in:
parent
593bd0cf30
commit
26b5c9343e
2 changed files with 22 additions and 10 deletions
|
@ -53,8 +53,14 @@ class Parser:
|
|||
match = Parser.get_match_from_mail(Parser.POINTS_REGEX, mail)
|
||||
return float(match.group(1))
|
||||
|
||||
def __init__(self, details: Dict, reviewer: str) -> None:
|
||||
self.box = mbox(details["mbox_path"])
|
||||
def __init__(self, details: Dict, reviewer: str, homework: str) -> None:
|
||||
self.homework = homework
|
||||
|
||||
self.from_ids = "submissions" in details
|
||||
if self.from_ids:
|
||||
self.submissions = details["submissions"]
|
||||
else:
|
||||
self.box = mbox(details["mbox_path"])
|
||||
self.reviewer = reviewer
|
||||
|
||||
self.deadline = datetime.datetime.strptime(details["deadline"], Parser.DATE_FORMAT)
|
||||
|
@ -66,14 +72,20 @@ class Parser:
|
|||
self.deadline += Parser.OFFSET_FOR_CORRECTION
|
||||
|
||||
def __get_submissions(self, hw_tag: str) -> Dict[str, List[Submission]]:
|
||||
mails = []
|
||||
if self.from_ids:
|
||||
print(self.submissions)
|
||||
for submission_id in self.submissions:
|
||||
with open(f'/home/kontr/kontr/_tmp_/pb071/{self.homework}/{submission_id}/teacher_email', 'r') as f:
|
||||
mails.append(f.read())
|
||||
else:
|
||||
for mail in self.box.values():
|
||||
if self.reviewer not in mail['subject']:
|
||||
continue
|
||||
mails.append(Parser.get_mail(mail))
|
||||
|
||||
submissions = []
|
||||
|
||||
for mail in self.box.values():
|
||||
if self.reviewer not in mail['subject']:
|
||||
continue
|
||||
|
||||
text = Parser.get_mail(mail)
|
||||
|
||||
for text in mails:
|
||||
uco, login = Parser.parse_info(text)
|
||||
path, submission_id = Parser.parse_submission(text)
|
||||
points = Parser.parse_points(text)
|
||||
|
|
2
pushee.py
Normal file → Executable file
2
pushee.py
Normal file → Executable file
|
@ -55,7 +55,7 @@ def main():
|
|||
details = config["homeworks"][config["homework"]]
|
||||
|
||||
submissions = Parser(
|
||||
details, config["reviewer"]
|
||||
details, config["reviewer"], config["homework"]
|
||||
).parse(config["homework"])
|
||||
|
||||
COMMANDS[sys.argv[1]](submissions, Gitlab(config["project_namespace"],
|
||||
|
|
Reference in a new issue