From 95f20eb8b754f4d5cd9c1077e048d166232c6973 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= Date: Tue, 10 Mar 2026 14:21:35 +0100 Subject: [PATCH] Working state --- add_final_score.py | 6 +++++- annotating_by_label.py | 2 ++ giving_names.py | 3 ++- post-correction.py | 5 ----- update_ods.py | 4 ++++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/add_final_score.py b/add_final_score.py index a9f0831..9319775 100644 --- a/add_final_score.py +++ b/add_final_score.py @@ -8,7 +8,7 @@ from PIL import Image, ImageDraw, ImageFont # Configuration constants ODS_PATH = "/home/sebastien/Rust/gestion_classe/Staging/simple_eval.ods" -OUTPUT_DIR = Path("/home/sebastien/Rust/Server/assets/static/copies") +OUTPUT_DIR = Path("/home/sebastien/Rust/Server/copies") FONT_PATH = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" # Standard Linux font path def get_rounded_score(score): @@ -100,5 +100,9 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description="Stamp scores on exam copies.") parser.add_argument("dir", type=Path, help="Root directory containing 'A Rendre' folder") + args = parser.parse_args() + + OUTPUT_DIR = OUTPUT_DIR / args.dir + OUTPUT_DIR.mkdir(parents=True, exist_ok=True) process_images(args.dir) diff --git a/annotating_by_label.py b/annotating_by_label.py index 1f46788..808f792 100644 --- a/annotating_by_label.py +++ b/annotating_by_label.py @@ -12,6 +12,8 @@ import annotating_with_checks # Roughly 10 A4 pages at 100 DPI MAX_HEIGHT_PX = 11690 +# MAX_HEIGHT_PX = 18000 +# MAX_HEIGHT_PX = 16000 def render_item(item): student_id, label, content = item diff --git a/giving_names.py b/giving_names.py index 9b5969e..342ad22 100644 --- a/giving_names.py +++ b/giving_names.py @@ -10,7 +10,7 @@ def main(): sys.exit(1) work_dir = os.path.abspath(sys.argv[1]) - bnot_dir = os.path.abspath(sys.argv[2]) + bnot_dir = sys.argv[2] target_subdir = os.path.join(work_dir, "A Rendre") os.makedirs(target_subdir, exist_ok=True) @@ -56,6 +56,7 @@ def main(): # Fallback to Anot elif (os.path.exists(os.path.join(path_a, "Concat.jpg")) and os.path.exists(os.path.join(path_a, "score.json"))): + print(f"Debug : couldn't find {path_b} falling back to Anot path") source_folder = path_a if not source_folder: diff --git a/post-correction.py b/post-correction.py index 677bb50..4a593c9 100644 --- a/post-correction.py +++ b/post-correction.py @@ -15,11 +15,6 @@ INPUT_DIR = str(arg_path) if not arg_path.exists(): sys.exit(f"Directory {INPUT_DIR} not found.") -import ftfy -import ftfy - -clean = ftfy.fix_text(text.replace("\x00", "")) - import json import ftfy diff --git a/update_ods.py b/update_ods.py index 31ad650..d29f3f2 100644 --- a/update_ods.py +++ b/update_ods.py @@ -2,8 +2,12 @@ import os import sys import json import ezodf +import re from pathlib import Path +def natural_key(text): + return [int(c) if c.isdigit() else c.lower() for c in re.split(r'(\d+)', str(text))] + # Configuration ODS_PATH = "/home/sebastien/Rust/gestion_classe/Staging/current_eval.ods" TARGET_DIR_NAME = "A Rendre"