Sort comments by lines and update mail extraction
This commit is contained in:
parent
2605c82ddf
commit
593bd0cf30
2 changed files with 15 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import math
|
||||||
|
|
||||||
|
|
||||||
from commands.base import BaseCommand
|
from commands.base import BaseCommand
|
||||||
|
@ -22,6 +23,12 @@ class Comments(BaseCommand):
|
||||||
|
|
||||||
result[author].append(comment)
|
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
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -7,6 +7,8 @@ from typing import Dict, List
|
||||||
|
|
||||||
|
|
||||||
class Submission:
|
class Submission:
|
||||||
|
MAIL_CONTENT= re.compile(r"<pre>((.*\s+)+)<\/pre>")
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
uco: str,
|
uco: str,
|
||||||
|
@ -44,8 +46,12 @@ class Submission:
|
||||||
self.flag = "LATE"
|
self.flag = "LATE"
|
||||||
|
|
||||||
def get_mail(self) -> str:
|
def get_mail(self) -> str:
|
||||||
match = re.search(r"<pre>((.*\s+)+)<\/pre>", self.mail)
|
left = self.mail.find("<pre>")
|
||||||
return match.group(1) if match else self.mail
|
right = self.mail.rfind("</pre>")
|
||||||
|
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:
|
def print_submissions(all_submissions: Dict[str, List[Submission]]) -> None:
|
||||||
|
|
Reference in a new issue