fix(pronote): préserver les cours déplacés

This commit is contained in:
2026-09-12 14:00:33 +02:00
parent e63000230b
commit d82bd8ffd8
6 changed files with 217 additions and 7 deletions
+6 -4
View File
@@ -35,6 +35,7 @@ from ...models.agenda import (
from ...models.homework import Homework
from ...utils.redaction import redact_exception, redact_url
from ...utils.uid import generate_deterministic_uid, normalize_pronote_uid
from .lessons import collapse_replaced_lessons
_HEADER_LABEL_PATTERN = re.compile(
r"(?P<label>Mati(?:ère|ere)|Professeur(?:s|\(s\))?|Salle(?:s|\(s\))?"
@@ -186,11 +187,12 @@ def parse_header(header: str) -> HeaderInfo:
"group": None,
"class_part": None,
}
matches = list(_HEADER_LABEL_PATTERN.finditer(header))
header_text = _strip_html(header)
matches = list(_HEADER_LABEL_PATTERN.finditer(header_text))
for index, match in enumerate(matches):
value_start = match.end()
value_end = matches[index + 1].start() if index + 1 < len(matches) else len(header)
value = unescape(header[value_start:value_end].strip())
value_end = matches[index + 1].start() if index + 1 < len(matches) else len(header_text)
value = unescape(header_text[value_start:value_end].strip())
label = _normalize_label(match.group("label")).replace("(s)", "s")
if label == "matiere":
info["subject"] = value
@@ -566,4 +568,4 @@ def parse_ical(raw_ical: str) -> tuple[list[Lesson], list[Homework], list[School
)
)
return lessons, homeworks, school_events
return collapse_replaced_lessons(lessons), homeworks, school_events