(path: Path)
| 40 | |
| 41 | |
| 42 | def load_jsonl(path: Path) -> List[Dict[str, Any]]: |
| 43 | rows: List[Dict[str, Any]] = [] |
| 44 | if not path.exists(): |
| 45 | return rows |
| 46 | with path.open("r", encoding="utf-8") as handle: |
| 47 | for line in handle: |
| 48 | line = line.strip() |
| 49 | if not line: |
| 50 | continue |
| 51 | payload = json.loads(line) |
| 52 | if isinstance(payload, dict): |
| 53 | rows.append(payload) |
| 54 | return rows |
| 55 | |
| 56 | |
| 57 | def write_jsonl(path: Path, rows: Iterable[Dict[str, Any]]) -> None: |
no outgoing calls
no test coverage detected