MCPcopy Create free account
hub / github.com/ParzivalHack/PySpector / _deserialize_entry

Function _deserialize_entry

src/pyspector/ast_cache.py:207–226  ·  view source on GitHub ↗

Deserialize a FileCacheEntry from JSON. Raises on malformed data.

(raw: str)

Source from the content-addressed store, hash-verified

205
206
207def _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 ─────────────────────────────────────────────────────────────────────

Callers 3

test_roundtripMethod · 0.90
_disk_loadMethod · 0.85

Calls 2

FileCacheEntryClass · 0.85
AstChunkClass · 0.85

Tested by 2

test_roundtripMethod · 0.72