diff --git a/commands/comments.py b/commands/comments.py index 3993fbd..3d7fe79 100644 --- a/commands/comments.py +++ b/commands/comments.py @@ -2,6 +2,7 @@ import json +import math from commands.base import BaseCommand @@ -22,6 +23,12 @@ class Comments(BaseCommand): result[author].append(comment) + # sort by lines + for author in result: + result[author].sort(key=lambda comment: + comment["position"]["new_line"] if "position" in comment + else math.inf) + return result @staticmethod diff --git a/submission.py b/submission.py index f4a7ab9..e38599d 100644 --- a/submission.py +++ b/submission.py @@ -7,6 +7,8 @@ from typing import Dict, List class Submission: + MAIL_CONTENT= re.compile(r"
((.*\s+)+)<\/pre>")
+
     def __init__(
         self,
         uco: str,
@@ -44,8 +46,12 @@ class Submission:
             self.flag = "LATE"
 
     def get_mail(self) -> str:
-        match = re.search(r"
((.*\s+)+)<\/pre>", self.mail)
-        return match.group(1) if match else self.mail
+        left = self.mail.find("
")
+        right = self.mail.rfind("
") + return self.mail[left + 5:right] + # print(self.mail) + # match = Submission.MAIL_CONTENT.search(self.mail) + # return match.group(1) if match else self.mail def print_submissions(all_submissions: Dict[str, List[Submission]]) -> None: