fix(pronote): préserver les cours déplacés et changements de salle

Revue Codex validée. Statuts canoniques iCal/pronotepy et consolidation prudente des cours remplacés.

Co-authored-by: Codex <codex@antoineve.me>
Co-committed-by: Codex <codex@antoineve.me>
This commit was merged in pull request #32.
This commit is contained in:
2026-09-12 14:55:19 +02:00
committed by Codex
parent a9e4f610c0
commit 5bb5d2c2f1
6 changed files with 224 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
@@ -567,4 +569,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