Clear import directory, possibly
This commit is contained in:
1 parent
52a8589261
commit
22c04f6e15
7 files changed
+88
-6
No files matched your search
@@ -24,6 +24,7 @@ from copienator import (
|
||||
)
|
||||
from copienator.annotation_data import load_annotation_data
|
||||
from copienator.commands import annotating, annotating_with_checks
|
||||
from copienator.commands.import_annotations import clear_import_directory
|
||||
from copienator.filesystem import staged_directory
|
||||
from copienator.utils import natural_key
|
||||
|
||||
@@ -347,7 +348,8 @@ def _generate_groups(
|
||||
|
||||
|
||||
def run(
|
||||
workspace: EvaluationWorkspace, *, overwrite: bool = False, refaire: bool = False
|
||||
workspace: EvaluationWorkspace, *, overwrite: bool = False, refaire: bool = False,
|
||||
clear_import: bool = False,
|
||||
) -> ExitCode:
|
||||
workspace.require_files("labels", "correction.json")
|
||||
workspace.require_directories("Copies", "Par label")
|
||||
@@ -408,11 +410,17 @@ def run(
|
||||
return ExitCode.PARTIAL
|
||||
if generated == 0:
|
||||
print("No new grouped annotations were required.")
|
||||
return ExitCode.PARTIAL if loaded.warnings else ExitCode.SUCCESS
|
||||
if loaded.warnings:
|
||||
return ExitCode.PARTIAL
|
||||
if clear_import:
|
||||
clear_import_directory(workspace)
|
||||
return ExitCode.SUCCESS
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = evaluation_parser("Generate annotated PDFs grouped by labels.")
|
||||
parser.add_argument("--clear-import", action="store_true",
|
||||
help="Empty IMPORT_DIR after successful annotation generation")
|
||||
parser.add_argument(
|
||||
"--overwrite", action="store_true", help="Replace annotation outputs safely"
|
||||
)
|
||||
@@ -430,7 +438,8 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
parser,
|
||||
argv,
|
||||
lambda args: run(
|
||||
workspace_from_args(args), overwrite=args.overwrite, refaire=args.refaire
|
||||
workspace_from_args(args), overwrite=args.overwrite, refaire=args.refaire,
|
||||
clear_import=args.clear_import,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user