(path: Path)
| 87 | |
| 88 | |
| 89 | def load_jsonl(path: Path) -> List[Dict[str, Any]]: |
| 90 | rows: List[Dict[str, Any]] = [] |
| 91 | if not path.exists(): |
| 92 | return rows |
| 93 | with path.open("r", encoding="utf-8") as handle: |
| 94 | for line in handle: |
| 95 | line = line.strip() |
| 96 | if not line: |
| 97 | continue |
| 98 | payload = json.loads(line) |
| 99 | if isinstance(payload, dict): |
| 100 | rows.append(payload) |
| 101 | return rows |
| 102 | |
| 103 | |
| 104 | def write_jsonl(path: Path, rows: Iterable[Dict[str, Any]]) -> None: |
no outgoing calls
no test coverage detected