Deserialize a FileCacheEntry from JSON. Raises on malformed data.
(raw: str)
| 205 | |
| 206 | |
| 207 | def _deserialize_entry(raw: str) -> FileCacheEntry: |
| 208 | """Deserialize a FileCacheEntry from JSON. Raises on malformed data.""" |
| 209 | d = json.loads(raw) |
| 210 | return FileCacheEntry( |
| 211 | file_path=d["file_path"], |
| 212 | file_hash=d["file_hash"], |
| 213 | mtime=float(d["mtime"]), |
| 214 | full_ast_json_z=base64.b64decode(d["full_ast_json_z"]), |
| 215 | chunks={ |
| 216 | k: AstChunk( |
| 217 | chunk_id=v["chunk_id"], |
| 218 | start_line=int(v["start_line"]), |
| 219 | end_line=int(v["end_line"]), |
| 220 | content_hash=v["content_hash"], |
| 221 | ast_json_z=base64.b64decode(v["ast_json_z"]), |
| 222 | ) |
| 223 | for k, v in d["chunks"].items() |
| 224 | }, |
| 225 | version=int(d["version"]), |
| 226 | ) |
| 227 | |
| 228 | |
| 229 | # ── Cache ───────────────────────────────────────────────────────────────────── |