opton to skip visual check in cutleft

This commit is contained in:
sebastien committed 2026-09-29 15:46:47 +02:00
1 parent 5b7d4b611e
commit 2f8422f6d5
5 files changed
+112 -3

No files matched your search

+37 -1
View File
@@ -384,6 +384,7 @@ def run(
target: Path,
*,
fullpage: bool = False,
no_visual_check: bool = False,
marked: bool = False,
) -> ExitCode:
files = marked_copy_paths(workspace) if marked else _selected_files(workspace, target)
@@ -392,6 +393,30 @@ def run(
return ExitCode.SUCCESS
workspace.cutleft_dir.mkdir(parents=True, exist_ok=True)
_get_pdf_pages_cached.cache_clear()
if fullpage and no_visual_check:
had_errors = False
for pdf_path in files:
result = process_single_pdf(pdf_path, max_per_file=1)
if result is None:
mark_copy_error(
workspace,
pdf_path,
"Échec de la conversion en pages entières",
)
had_errors = True
continue
try:
save_results(result, pdf_path, workspace.cutleft_dir)
clear_copy_error(workspace, pdf_path)
except Exception as exc: # noqa: BLE001 - continue with remaining copies
mark_copy_error(
workspace,
pdf_path,
f"Échec de l’enregistrement : {exc}",
)
print(f"[Copie signalée] {pdf_path.name}: {exc}")
had_errors = True
return ExitCode.PARTIAL if had_errors else ExitCode.SUCCESS
reviewer = ImageReviewer(
files,
workspace.cutleft_dir,
@@ -410,6 +435,11 @@ def build_parser() -> argparse.ArgumentParser:
action="store_true",
help="Use each complete page instead of cropping the label margin",
)
parser.add_argument(
"--no-visual-check",
action="store_true",
help="Save full pages without opening the visual reviewer (requires --fullpage)",
)
return parser
@@ -418,7 +448,13 @@ def main(argv: Sequence[str] | None = None) -> int:
def handle(args: argparse.Namespace) -> ExitCode:
workspace, target = workspace_from_target(args)
return run(workspace, target, fullpage=args.fullpage, marked=args.marked)
return run(
workspace,
target,
fullpage=args.fullpage,
no_visual_check=args.no_visual_check,
marked=args.marked,
)
return execute(parser, argv, handle)