Support for A.pdf, A.tex and Ac.tex for initial files

This commit is contained in:
sebastien committed 2026-09-26 11:22:09 +02:00
1 parent 42a5b9778e
commit e4e25eca55
12 files changed
+104 -32

No files matched your search

+40 -3
View File
@@ -63,12 +63,49 @@ class EvaluationWorkspace:
".copienator",
".copienator-gui.json",
)
return path.is_dir() and any((path / marker).exists() for marker in markers)
if not path.is_dir():
return False
aliases = (f"{path.name}.pdf", f"{path.name}.tex", f"{path.name}c.tex")
return any((path / marker).exists() for marker in (*markers, *aliases))
@property
def name(self) -> str:
return self.root.name
def input_candidates(self, canonical_name: str) -> tuple[Path, ...]:
"""Return preferred paths for one of the three statement inputs."""
aliases = {
"enonce.pdf": ("enonce.pdf", "énoncé.pdf", f"{self.name}.pdf"),
"enonce.tex": ("enonce.tex", f"{self.name}.tex"),
"correction.tex": ("correction.tex", f"{self.name}c.tex"),
}
names = aliases.get(canonical_name, (canonical_name,))
return tuple(self.root / name for name in names)
def resolve(self, relative_path: str) -> Path:
"""Resolve a logical workspace path, including statement aliases."""
candidates = self.input_candidates(relative_path)
return next((path for path in candidates if path.exists()), candidates[0])
def resolve_file(self, relative_path: str) -> Path:
candidates = self.input_candidates(relative_path)
return next((path for path in candidates if path.is_file()), candidates[0])
@property
def statement_pdf_file(self) -> Path:
return self.resolve_file("enonce.pdf")
@property
def statement_source_file(self) -> Path:
return self.resolve_file("enonce.tex")
@property
def correction_source_file(self) -> Path:
return self.resolve_file("correction.tex")
def is_statement_pdf(self, path: Path) -> bool:
return path in self.input_candidates("enonce.pdf")
@property
def metadata_dir(self) -> Path:
return self.root / ".copienator"
@@ -220,7 +257,7 @@ class EvaluationWorkspace:
missing = [
relative_path
for relative_path in relative_paths
if not (self.root / relative_path).exists()
if not self.resolve(relative_path).exists()
]
if missing:
raise WorkspaceValidationError(self.root, missing)
@@ -229,7 +266,7 @@ class EvaluationWorkspace:
missing = [
relative_path
for relative_path in relative_paths
if not (self.root / relative_path).is_file()
if not self.resolve_file(relative_path).is_file()
]
if missing:
raise WorkspaceValidationError(self.root, missing)