From f7067d858566020b7d0894f477b47ce9d2feef20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Miquel?= Date: Thu, 20 Aug 2026 10:05:44 +0200 Subject: [PATCH] Export and Import --- Readme.org | 34 +++++++++++++++------------------- default_config.py | 4 ++++ to_tablette.py => export.py | 6 ++++-- from_tablette.py => import.py | 4 +++- 4 files changed, 26 insertions(+), 22 deletions(-) rename to_tablette.py => export.py (94%) rename from_tablette.py => import.py (95%) diff --git a/Readme.org b/Readme.org index 35636ad..031386a 100644 --- a/Readme.org +++ b/Readme.org @@ -1,7 +1,7 @@ #+title: Script #+author: Sébastien Miquel #+date: 14-03-2026 -# Time-stamp: <08-08-26 16:44> +# Time-stamp: <20-08-26 09:59> #+OPTIONS: * Méta @@ -155,7 +155,7 @@ Mettre les copies scannées au format pdf dans =Interro=. ** Labelisation et regroupement -Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ +Optional : Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ 1. =python gemini_for_labels.py Interro=, avec éventuellement =--overwrite= @@ -179,8 +179,7 @@ Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ En cas de soucis, (par exemple les pages ne sont pas dans le bon ordre) - Réordonner les pages du fichier pdf - Rerun =python cutleft.py Interro/Copie{id}= - - Rerun =python gemini_dir_batching.py Interro/Copie{id}= - ?? À vérifier, pas sûr que ça marche. + - Rerun =python gemini_for_labels.py Interro/Copie{id}= 3. =python splitting_int.py Interro= Découpe les copies suivant les exercices @@ -192,7 +191,7 @@ Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ ** Correction et annotation -Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ +Optional : Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ 1. Il faut créer des persp, pour indication de comment corriger, et relancer =enonce_info.py= @@ -222,7 +221,7 @@ Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ - Essaye de corriger des erreurs d'encodage/d'accents dans =correction.json=. - aussi échappe les `_` en dehors du mode math, pour LaTeX. - 4. Résolution manuel de conflits + 4. Résolution manuel de conflits, s'il y en a. Edit `manual_resolutions.txt`. Use : + `->` or `x>` : Here set a pipe `|` before or after the new_label name @@ -242,7 +241,7 @@ Set proxy with ~export HTTPS_PROXY="http://10.0.0.1:3128"~ Ajoute les annotations Gemini aux copies, enregistrées dans le dossier =Anot=. On peut passer l'argument =--overwrite=. - +OU 2. =python annotating_with_checks.py Interro= Ajoute les annotations Gemini, et des checkboxes à cocher. @@ -257,27 +256,24 @@ OU _Needs_ : label_groups file (made automatically by this function), qui dit quelles questions regrouper. - - - 3. =python to_tablette.py Interro= (gestion perso) - Cela déplace les groupes dans =SyncCopies/À Annoter=. + 3. =python export.py Interro= (gestion perso) + Cela déplace les groupes dans le dossier configuré par =EXPORT_DIR= + (par défaut =Export=). - Les mettre dans le dossier racine de la tablette, et renommer en =aaa=. - Vider =Syncthing/Annotées= sur la tablette et localement. À automatiser, aussi c'est lent… ** Lecture de la correction manuscrite - 1. =python from_tablette.py Interro= (gestion perso) + 1. =python import.py Interro= (gestion perso) - _Before_ : delete =~/SyncCopies/Annotées=, copy or sync from the - tablette to here. + _Before_ : vider le dossier configuré par =IMPORT_DIR= (par défaut + =Import=), puis y copier ou synchroniser les fichiers depuis la tablette. Une fois les corrections manuelles appliquées aux fichiers =Concat.pdf=, il faut enregistrer le fichier annoté au même endroit, sous le nom =Concat_annotated.pdf=. -(À faire : universaliser =to_tablette.py= et =from_tablette.py=) - 2. =python reading_annotations.py Interro= Lit les =Concat_annotated= dans =Bnot=, regénère les copies avec @@ -332,8 +328,8 @@ groupée into refaire !! 4. ?? Si je fais refaire, avant d'avoir créer les annotating with checks, que se passe-t-il ??? 5. Appeler =annotating_with_checks.py --refaire --overwrite= - 6. =python to_tablette.py --refaire Interro24= - 6. =python from_tablette.py --refaire Interro24= + 6. =python export.py --refaire Interro24= + 6. =python import.py --refaire Interro24= 7. =python reading_grouped_annotations.py --refaire Interro24= ** Exemple de replotting, refaire d'une copie @@ -345,4 +341,4 @@ groupée into refaire !! 3. Make `refaire.json`, avec la copie, et les labels à refaire. 4. `python correction.py DS09VA --refaire` 5. `python annotating_with_checks.py DS09VA --refaire` - 6. `python from_tablette.py Interro24 --refaire` + 6. `python import.py Interro24 --refaire` diff --git a/default_config.py b/default_config.py index 1bf7e71..5786d94 100644 --- a/default_config.py +++ b/default_config.py @@ -1,7 +1,11 @@ import os +from pathlib import Path API_KEY = os.environ.get("GEMINI_API_KEY") +EXPORT_DIR = Path("Export") +IMPORT_DIR = Path("Import") + # Modèle pour des choses très légères MODEL_LITE_ID = "gemini-3.5-flash-lite" diff --git a/to_tablette.py b/export.py similarity index 94% rename from to_tablette.py rename to export.py index 1e4b8fa..d24024f 100644 --- a/to_tablette.py +++ b/export.py @@ -2,11 +2,13 @@ import sys import os from pathlib import Path +from config import EXPORT_DIR + def process_directory(dir_arg): # Résolution des chemins base_dir = Path(dir_arg) bgnot_dir = base_dir / "BGnot" - sync_dir = Path.home() / "SyncCopies" / "À Annoter" / dir_arg + sync_dir = EXPORT_DIR / dir_arg # Création du dossier de destination s'il n'existe pas sync_dir.mkdir(parents=True, exist_ok=True) @@ -57,7 +59,7 @@ if __name__ == "__main__": if args.refaire: base_dir = Path(root_dir) brnot_dir = base_dir / "BRnot" - sync_dir = Path.home() / "SyncCopies" / "À Annoter" / root_dir + sync_dir = EXPORT_DIR / root_dir sync_dir.mkdir(parents=True, exist_ok=True) for f in brnot_dir.iterdir(): diff --git a/from_tablette.py b/import.py similarity index 95% rename from from_tablette.py rename to import.py index 834f80b..aa16106 100644 --- a/from_tablette.py +++ b/import.py @@ -2,13 +2,15 @@ import sys import shutil from pathlib import Path +from config import IMPORT_DIR + def sync_annotated(dir_arg, refaire): if not refaire: bgnot_dir = Path(dir_arg) / "BGnot" else: bgnot_dir = Path(dir_arg) / "BRnot" - annotated_dir = Path.home() / "SyncCopies" / "Annotées" + annotated_dir = IMPORT_DIR if not annotated_dir.is_dir(): print(f"Error: Directory {annotated_dir} does not exist.")