Refaire session.

This commit is contained in:
2026-09-06 19:20:51 +02:00
parent 2ff1a9b7b9
commit 2313d51a62
8 changed files with 469 additions and 10 deletions
+13 -3
View File
@@ -4,7 +4,6 @@ import sys
from collections.abc import Sequence
from pathlib import Path
from copienator.configuration import IMPORT_DIR
from copienator import (
EvaluationWorkspace,
ExitCode,
@@ -12,6 +11,7 @@ from copienator import (
execute,
workspace_from_args,
)
from copienator.configuration import IMPORT_DIR
ANNOTATION_DIRECTORIES = ("BGnot", "Bnot", "Anot")
@@ -23,7 +23,10 @@ def sync_annotated(
import_dir: Path,
) -> ExitCode:
workspace.require_directories(annotation_dir_name)
annotation_dir = workspace.root / annotation_dir_name
annotation_dir = workspace.annotation_dir("refaire") if annotation_dir_name == "BRnot" else workspace.root / annotation_dir_name
session_id = workspace.refaire_session_id if annotation_dir_name == "BRnot" else None
prefix = f"{session_id}__" if session_id else ""
accepted = 0
annotated_dir = Path(import_dir).expanduser()
if not annotated_dir.is_dir():
print(f"Error: directory does not exist: {annotated_dir}", file=sys.stderr)
@@ -39,7 +42,10 @@ def sync_annotated(
key=lambda path: path.name.casefold(),
)
for annotated_file in annotated_files:
target_subdir = annotation_dir / annotated_file.stem
if prefix and not annotated_file.stem.startswith(prefix):
print(f"Ignoring return from another pass: {annotated_file.name}")
continue
target_subdir = annotation_dir / annotated_file.stem.removeprefix(prefix)
if not target_subdir.is_dir():
print(f"Warning: directory not found: {target_subdir}", file=sys.stderr)
@@ -49,6 +55,10 @@ def sync_annotated(
dest_file = target_subdir / f"Concat_annotated{suffix}"
print(f"Copying {annotated_file} to {dest_file}")
shutil.copy2(annotated_file, dest_file)
accepted += 1
if prefix and not accepted:
print(f"No returns for the active pass {session_id} were imported.")
return ExitCode.PARTIAL
return ExitCode.PARTIAL if missing_targets else ExitCode.SUCCESS