(path: Path)
| 124 | |
| 125 | |
| 126 | def _load_scenario_file(path: Path) -> list[Scenario]: |
| 127 | text = path.read_text(encoding="utf-8").strip() |
| 128 | if not text: |
| 129 | return [] |
| 130 | |
| 131 | if path.suffix == ".jsonl": |
| 132 | return [ |
| 133 | Scenario.from_raw(json.loads(line)) |
| 134 | for line in text.splitlines() |
| 135 | if line.strip() |
| 136 | ] |
| 137 | |
| 138 | raw = json.loads(text) |
| 139 | if isinstance(raw, list): |
| 140 | return [Scenario.from_raw(item) for item in raw] |
| 141 | if isinstance(raw, dict): |
| 142 | return [Scenario.from_raw(raw)] |
| 143 | raise ValueError(f"unexpected scenario JSON shape in {path}: {type(raw).__name__}") |
| 144 | |
| 145 | |
| 146 | def join_records( |
no test coverage detected