Load reference texts from the split layout, or the legacy YAML as fallback.
(
base_dir: Path,
legacy_file: Path,
)
| 54 | |
| 55 | |
| 56 | def load_reference_texts( |
| 57 | base_dir: Path, |
| 58 | legacy_file: Path, |
| 59 | ) -> dict[str, ReferenceText]: |
| 60 | """Load reference texts from the split layout, or the legacy YAML as fallback.""" |
| 61 | split_dir = _split_reference_texts_dir(base_dir) |
| 62 | if split_dir.is_dir(): |
| 63 | return _load_reference_texts_split(split_dir) |
| 64 | if legacy_file.exists(): |
| 65 | return _load_reference_texts_legacy(legacy_file) |
| 66 | raise FileNotFoundError( |
| 67 | f"No reference text data found. Looked in {split_dir} and {legacy_file}." |
| 68 | ) |
| 69 | |
| 70 | |
| 71 | def _iter_yaml_files(directory: Path) -> Iterable[Path]: |
no test coverage detected