Clear import directory, possibly
This commit is contained in:
1 parent
52a8589261
commit
22c04f6e15
7 files changed
+88
-6
No files matched your search
@@ -27,6 +27,7 @@ from copienator import (
|
||||
)
|
||||
from copienator.annotation_data import load_annotation_data
|
||||
from copienator.commands import annotating
|
||||
from copienator.commands.import_annotations import clear_import_directory
|
||||
from copienator.filesystem import staged_directory
|
||||
from copienator.utils import natural_key
|
||||
|
||||
@@ -269,6 +270,7 @@ def run(
|
||||
*,
|
||||
overwrite: bool = False,
|
||||
refaire: bool = False,
|
||||
clear_import: bool = False,
|
||||
) -> ExitCode:
|
||||
workspace.require_files("labels", "correction.json")
|
||||
workspace.require_directories("Copies", "Par label")
|
||||
@@ -319,6 +321,8 @@ def run(
|
||||
except IncompleteRedo:
|
||||
print("Warning: incomplete redo generation; previous BRnot was preserved.")
|
||||
return ExitCode.PARTIAL
|
||||
if clear_import:
|
||||
clear_import_directory(workspace)
|
||||
return ExitCode.SUCCESS
|
||||
|
||||
statuses: list[str] = []
|
||||
@@ -338,11 +342,15 @@ def run(
|
||||
statuses.append(future.result())
|
||||
if loaded.warnings or "partial" in statuses:
|
||||
return ExitCode.PARTIAL
|
||||
if clear_import:
|
||||
clear_import_directory(workspace)
|
||||
return ExitCode.SUCCESS
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = target_parser("Generate annotated PDFs with checkboxes.")
|
||||
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 existing outputs"
|
||||
)
|
||||
@@ -364,6 +372,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
target,
|
||||
overwrite=args.overwrite,
|
||||
refaire=args.refaire,
|
||||
clear_import=args.clear_import,
|
||||
)
|
||||
|
||||
return execute(parser, argv, handler)
|
||||
|
||||
Reference in new issue
Block a user