Support for A.pdf, A.tex and Ac.tex for initial files
This commit is contained in:
1 parent
42a5b9778e
commit
e4e25eca55
12 files changed
+104
-32
No files matched your search
@@ -109,7 +109,10 @@ def _return_artifacts(workspace: EvaluationWorkspace) -> list[Path]:
|
||||
def _is_statement_text_file(workspace: EvaluationWorkspace, path: Path) -> bool:
|
||||
relative = path.relative_to(workspace.root)
|
||||
if len(relative.parts) == 1:
|
||||
return relative.name in STATEMENT_ROOT_FILES
|
||||
return relative.name in STATEMENT_ROOT_FILES or path in {
|
||||
*workspace.input_candidates("enonce.tex"),
|
||||
*workspace.input_candidates("correction.tex"),
|
||||
}
|
||||
top_level = relative.parts[0]
|
||||
if top_level in STATEMENT_TEXT_DIRECTORIES:
|
||||
return path.suffix.casefold() in {"", ".json", ".tex", ".txt"}
|
||||
|
||||
@@ -24,7 +24,7 @@ def copy_pdfs(directory: Path) -> list[Path]:
|
||||
(
|
||||
path
|
||||
for path in directory.glob("*.pdf")
|
||||
if path.name.casefold() not in {"enonce.pdf", "énoncé.pdf"}
|
||||
if not EvaluationWorkspace(directory).is_statement_pdf(path)
|
||||
),
|
||||
key=lambda path: path.name.casefold(),
|
||||
)
|
||||
@@ -134,4 +134,3 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
|
||||
@@ -143,7 +143,7 @@ def save_split_content(text, path, base_fname, problem):
|
||||
def process_directory(workspace: EvaluationWorkspace) -> ExitCode:
|
||||
directory = str(workspace.root)
|
||||
# Find the first .tex file in the directory
|
||||
enonce = workspace.root / "enonce.tex"
|
||||
enonce = workspace.statement_source_file
|
||||
tex_files = [str(enonce)] if enonce.is_file() else sorted(glob.glob(os.path.join(directory, "*.tex")))
|
||||
if not tex_files:
|
||||
print(f"No .tex file found in {directory}. Looking in /Staging/Interro/")
|
||||
|
||||
@@ -331,14 +331,18 @@ def process_exam(
|
||||
cache_c_file = cache_dir / "gemini_context.json"
|
||||
|
||||
# 1. Resolve files
|
||||
pdf_path = folder / "enonce.pdf"
|
||||
pdf_path = workspace.statement_pdf_file
|
||||
enonce_path = find_file(folder, "enonce")
|
||||
if enonce_path is None:
|
||||
enonce_path = workspace.statement_source_file
|
||||
correction_path = find_file(folder, "correction")
|
||||
if correction_path is None:
|
||||
correction_path = workspace.correction_source_file
|
||||
|
||||
missing = []
|
||||
if not pdf_path.is_file(): missing.append("enonce.pdf")
|
||||
if not enonce_path: missing.append("enonce.org or enonce.tex")
|
||||
if not correction_path: missing.append("correction.org or correction.tex")
|
||||
if not enonce_path.is_file(): missing.append("enonce.tex")
|
||||
if not correction_path.is_file(): missing.append("correction.tex")
|
||||
|
||||
if missing:
|
||||
raise CliError(
|
||||
|
||||
@@ -476,17 +476,11 @@ class ImageViewer:
|
||||
def on_open_interro(self, event):
|
||||
if self.is_viewing and self.current_json_path:
|
||||
# Check local directory first
|
||||
local_accent = self.base_dir / "énoncé.pdf"
|
||||
local_plain = self.base_dir / "enonce.pdf"
|
||||
|
||||
if local_accent.exists():
|
||||
pdf_path = str(local_accent)
|
||||
elif local_plain.exists():
|
||||
pdf_path = local_plain
|
||||
else:
|
||||
pdf_path = EvaluationWorkspace(self.base_dir).statement_pdf_file
|
||||
if not pdf_path.is_file():
|
||||
messagebox.showerror(
|
||||
"PDF not found",
|
||||
f"Neither {local_accent.name} nor {local_plain.name} exists in {self.base_dir}.",
|
||||
f"No statement PDF exists in {self.base_dir}.",
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
Reference in new issue
Block a user