Initialize one declared template and verify canonical relocation preserves its content.
84def audit_template_copy(template_name: str, temporary_root: Path) -> None:
85 """!
86 @brief Initialize one declared template and verify canonical relocation preserves its content.
87 @param[in] template_name Top-level example directory name.
88 @param[in] temporary_root Temporary parent directory for initialized cases.
89 @return None.
90 """
91 source = REPO_ROOT / "examples" / template_name
92 destination = temporary_root / template_name
93 result = run_cli(["init", template_name, "--dest", str(destination)])
94 if result.returncode:
95 fail(f"picurv init {template_name}", result)
96 required_dirs = (
97 "config", "config/studies", "inputs", "assets/objects", "assets/sets", "runs", "studies"
98 )
99 for relative in required_dirs:
100 if not (destination / relative).is_dir():
101 raise RuntimeError(f"picurv init {template_name} omitted workspace directory {relative}")
102 if not (destination / ".picurv-workspace.yml").is_file():
103 raise RuntimeError(f"picurv init {template_name} omitted .picurv-workspace.yml")
104
105 source_yamls = [path for path in source.rglob("*.yml") if path.name != RUNTIME_EXECUTION_EXAMPLE]
106 initialized_yamls =
list((destination /
"config").rglob(
"*.yml"))
107 if len(initialized_yamls) < len(source_yamls):
108 raise RuntimeError(f"picurv init {template_name} lost one or more YAML configurations")
109
110 for source_path in source.rglob("*"):
111 if not source_path.is_file():
112 continue
113 relative = source_path.relative_to(source)
114 if relative.as_posix() == RUNTIME_EXECUTION_EXAMPLE:
115 continue
116 if source_path.suffix.lower() in {".yml", ".yaml"}:
117 role = _yaml_role(source_path)
118 stem = source_path.stem
119 candidates = [
120 destination / "config" / source_path.name,
121 destination / "config" / f"{role}.yml" if role else destination / source_path.name,
122 destination / "config" / f"{role}-{stem}{source_path.suffix}" if role else destination / source_path.name,
123 destination / "config" / "studies" / source_path.name,
124 ]
125 if not any(candidate.is_file() for candidate in candidates):
126 raise RuntimeError(f"picurv init {template_name} did not relocate YAML {relative}")
127 continue
128 matches = [path for path in destination.rglob(source_path.name) if path.is_file()]
129 if not any(path.read_bytes() == source_path.read_bytes() for path in matches):
130 raise RuntimeError(f"picurv init {template_name} did not preserve {relative}")
131 if (destination / RUNTIME_EXECUTION_EXAMPLE).exists():
132 raise RuntimeError(f"picurv init {template_name} copied site-specific {RUNTIME_EXECUTION_EXAMPLE}")
133
134
Head of a generic C-style linked list.