Clear import directory, possibly
This commit is contained in:
1 parent
52a8589261
commit
22c04f6e15
7 files changed
+88
-6
No files matched your search
@@ -30,6 +30,7 @@ from copienator import (
|
||||
workspace_from_args,
|
||||
)
|
||||
from copienator.annotation_data import load_annotation_data
|
||||
from copienator.commands.import_annotations import clear_import_directory
|
||||
from copienator.answer_info import build_answer_info
|
||||
from copienator.filesystem import staged_directory
|
||||
from copienator.feedback_boxes import valid_feedback_box
|
||||
@@ -525,6 +526,8 @@ def process_correction(root_dir, data, all_labels, overwrite=False):
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
parser = evaluation_parser("Generate simple annotated copies.")
|
||||
parser.add_argument("--clear-import", action="store_true",
|
||||
help="Empty IMPORT_DIR after successful annotation generation")
|
||||
parser.add_argument(
|
||||
"--overwrite",
|
||||
action="store_true",
|
||||
@@ -533,7 +536,8 @@ def build_parser() -> argparse.ArgumentParser:
|
||||
return parser
|
||||
|
||||
|
||||
def run(workspace: EvaluationWorkspace, *, overwrite: bool = False) -> ExitCode:
|
||||
def run(workspace: EvaluationWorkspace, *, overwrite: bool = False,
|
||||
clear_import: bool = False) -> ExitCode:
|
||||
workspace.require_files("labels", "correction.json")
|
||||
workspace.require_directories("Copies", "Par label")
|
||||
labels = utils.read_all_labels(workspace.root)
|
||||
@@ -551,6 +555,8 @@ def run(workspace: EvaluationWorkspace, *, overwrite: bool = False) -> ExitCode:
|
||||
)
|
||||
if loaded.warnings and result == ExitCode.SUCCESS:
|
||||
return ExitCode.PARTIAL
|
||||
if clear_import and result == ExitCode.SUCCESS:
|
||||
clear_import_directory(workspace)
|
||||
return result
|
||||
|
||||
|
||||
@@ -559,7 +565,8 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
return execute(
|
||||
parser,
|
||||
argv,
|
||||
lambda args: run(workspace_from_args(args), overwrite=args.overwrite),
|
||||
lambda args: run(workspace_from_args(args), overwrite=args.overwrite,
|
||||
clear_import=args.clear_import),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user