(path: Path)
| 71 | |
| 72 | |
| 73 | def load_jsonl(path: Path) -> List[Dict[str, Any]]: |
| 74 | rows: List[Dict[str, Any]] = [] |
| 75 | if not path.exists(): |
| 76 | return rows |
| 77 | with path.open("r", encoding="utf-8") as handle: |
| 78 | for line in handle: |
| 79 | line = line.strip() |
| 80 | if not line: |
| 81 | continue |
| 82 | payload = json.loads(line) |
| 83 | if isinstance(payload, dict): |
| 84 | rows.append(payload) |
| 85 | return rows |
| 86 | |
| 87 | |
| 88 | def write_jsonl(path: Path, rows: Iterable[Dict[str, Any]]) -> None: |
no outgoing calls
no test coverage detected