extension de export/import aux autres modes de génération
This commit is contained in:
+43
-2
@@ -36,6 +36,12 @@ STATUS_LABELS = {
|
||||
}
|
||||
|
||||
DEFAULT_HTTPS_PROXY = "http://10.0.0.1:3128"
|
||||
ANNOTATION_DIRECTORIES = ("BGnot", "Bnot", "Anot")
|
||||
ANNOTATION_VARIANT_DIRECTORIES = {
|
||||
"simple": "Anot",
|
||||
"checks": "Bnot",
|
||||
"grouped": "BGnot",
|
||||
}
|
||||
|
||||
|
||||
def copy_pdf_paths(evaluation: Path) -> list[Path]:
|
||||
@@ -57,6 +63,12 @@ def copy_pdf_paths(evaluation: Path) -> list[Path]:
|
||||
return []
|
||||
|
||||
|
||||
def detected_annotation_directories(evaluation: Path) -> tuple[str, ...]:
|
||||
return tuple(
|
||||
name for name in ANNOTATION_DIRECTORIES if (evaluation / name).is_dir()
|
||||
)
|
||||
|
||||
|
||||
def plotting_shortcut_lines() -> list[str]:
|
||||
try:
|
||||
from config import PLOTTING_KB
|
||||
@@ -530,6 +542,9 @@ class CopienatorApp(tk.Tk):
|
||||
if spec.variants and variant.id not in spec.variants:
|
||||
continue
|
||||
value = values.get(spec.name, value_for_default(spec.default, evaluation_arg))
|
||||
choices = spec.choices
|
||||
if spec.name == "annotation_dir" and step.id in {"export", "import"}:
|
||||
choices, value = self._annotation_directory_choices(step.id)
|
||||
ttk.Label(self.form, text=spec.label).grid(row=row, column=0, sticky="nw", pady=4, padx=(0, 8))
|
||||
if spec.kind == "bool":
|
||||
variable: tk.Variable = tk.BooleanVar(value=bool(value))
|
||||
@@ -537,7 +552,7 @@ class CopienatorApp(tk.Tk):
|
||||
widget.grid(row=row, column=1, sticky="w", pady=4)
|
||||
elif spec.kind == "choice":
|
||||
variable = tk.StringVar(value=str(value))
|
||||
widget = ttk.Combobox(self.form, textvariable=variable, values=spec.choices, state="readonly")
|
||||
widget = ttk.Combobox(self.form, textvariable=variable, values=choices, state="readonly")
|
||||
widget.grid(row=row, column=1, sticky="ew", pady=4)
|
||||
else:
|
||||
variable = tk.StringVar(value=str(value))
|
||||
@@ -626,6 +641,25 @@ class CopienatorApp(tk.Tk):
|
||||
row += 1
|
||||
return row
|
||||
|
||||
def _annotation_directory_choices(self, step_id: str) -> tuple[tuple[str, ...], str]:
|
||||
evaluation = self.evaluation
|
||||
detected = detected_annotation_directories(evaluation) if evaluation else ()
|
||||
choices = detected or ANNOTATION_DIRECTORIES
|
||||
|
||||
if step_id == "export":
|
||||
annotation = self.state_store.step("annotation")
|
||||
variant = annotation.get("last_run_variant", annotation.get("variant", "grouped"))
|
||||
preferred = ANNOTATION_VARIANT_DIRECTORIES.get(str(variant), "BGnot")
|
||||
else:
|
||||
export = self.state_store.step("export")
|
||||
last_values = export.get("last_run_values", export.get("values", {}))
|
||||
preferred = (
|
||||
str(last_values.get("annotation_dir", "BGnot"))
|
||||
if isinstance(last_values, dict)
|
||||
else "BGnot"
|
||||
)
|
||||
return choices, preferred if preferred in choices else choices[0]
|
||||
|
||||
def _open_persp(self) -> None:
|
||||
evaluation = self.evaluation
|
||||
self._open_desktop_path(evaluation / "Persp" if evaluation else None, "dossier Persp")
|
||||
@@ -775,9 +809,16 @@ class CopienatorApp(tk.Tk):
|
||||
return
|
||||
|
||||
self._save_current_form()
|
||||
run_values = self._values()
|
||||
ordered_ids = [item.id for item in self.steps]
|
||||
self.state_store.invalidate_after(ordered_ids, step.id)
|
||||
self.state_store.update_step(step.id, status="running", command=command_display(command))
|
||||
self.state_store.update_step(
|
||||
step.id,
|
||||
status="running",
|
||||
command=command_display(command),
|
||||
last_run_variant=variant.id,
|
||||
last_run_values=run_values,
|
||||
)
|
||||
self.active_step_id = step.id
|
||||
workspace = self.state_store.workspace
|
||||
assert workspace is not None
|
||||
|
||||
Reference in New Issue
Block a user