Write `content` to `self.output_root / rel_path`, creating parent dirs. Refuses to write outside `self.output_root` (catches `..` segments and absolute paths).
(self, rel_path: str | Path, content: str)
| 421 | # ── Shared utilities ────────────────────────────────────────────────── |
| 422 | |
| 423 | def write(self, rel_path: str | Path, content: str) -> Path: |
| 424 | """Write `content` to `self.output_root / rel_path`, creating parent dirs. |
| 425 | |
| 426 | Refuses to write outside `self.output_root` (catches `..` segments and absolute paths). |
| 427 | """ |
| 428 | target = (self.output_root / rel_path).resolve() |
| 429 | root = self.output_root.resolve() |
| 430 | if not target.is_relative_to(root): |
| 431 | raise ValueError(f"refusing to write outside output_root: {target} (root={root})") |
| 432 | target.parent.mkdir(parents=True, exist_ok=True) |
| 433 | target.write_text(content, encoding="utf-8") |
| 434 | return target |
| 435 | |
| 436 | def write_bytes(self, rel_path: str | Path, content: bytes) -> Path: |
| 437 | """Binary counterpart of `write` — for mirroring non-UTF-8 reference assets.""" |
no outgoing calls
no test coverage detected