Various HTML improvements
This commit is contained in:
1 parent
fd943696fb
commit
8c1fa0af57
16 files changed
+403
-45
No files matched your search
@@ -25,16 +25,22 @@ from copienator.annotation_modifications import (
|
||||
from copienator.filesystem import publish_file_sets
|
||||
|
||||
|
||||
def run(workspace: EvaluationWorkspace, *, annotation_dir: str = "BGnot") -> ExitCode:
|
||||
def run(workspace: EvaluationWorkspace, *, annotation_dir: str = "BGnot", incremental: bool = False) -> ExitCode:
|
||||
workspace.require_files("labels", DRAFT)
|
||||
workspace.require_directories("Copies", annotation_dir)
|
||||
text = (workspace.root / DRAFT).read_text(encoding="utf-8")
|
||||
instructions = read_instructions(text, annotation_dir)
|
||||
validate_instructions(workspace.root, annotation_dir, instructions)
|
||||
directory = workspace.root / annotation_dir
|
||||
applied = directory / APPLIED
|
||||
previous = read_instructions(applied.read_text(encoding="utf-8"), annotation_dir) if applied.exists() else []
|
||||
if incremental and previous == instructions:
|
||||
print("Skipping unchanged transfer instructions")
|
||||
return ExitCode.SUCCESS
|
||||
validate_instructions(workspace.root, annotation_dir, instructions)
|
||||
copy_ids = sorted({item.copy_id for item in [*previous, *instructions]})
|
||||
if incremental:
|
||||
copy_ids = [cid for cid in copy_ids
|
||||
if [i for i in previous if i.copy_id == cid] != [i for i in instructions if i.copy_id == cid]]
|
||||
# Prepare every copy before publishing anything, including the applied file.
|
||||
with TemporaryDirectory(prefix=".annotation-edits-", dir=directory) as temporary:
|
||||
staging_root = Path(temporary)
|
||||
@@ -61,12 +67,13 @@ def run(workspace: EvaluationWorkspace, *, annotation_dir: str = "BGnot") -> Exi
|
||||
def build_parser():
|
||||
parser = evaluation_parser("Modify reviewed answer bodies using annotation_modifications.txt")
|
||||
parser.add_argument("--annotation-dir", choices=MODES, default="BGnot")
|
||||
parser.add_argument("--incremental", action="store_true", help="Skip unchanged transfer instructions")
|
||||
return parser
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
return execute(build_parser(), argv, lambda args: run(
|
||||
workspace_from_args(args), annotation_dir=args.annotation_dir))
|
||||
workspace_from_args(args), annotation_dir=args.annotation_dir, incremental=args.incremental))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user