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

Function _serialize_entry

src/pyspector/ast_cache.py:186–204  ·  view source on GitHub ↗

Serialize a FileCacheEntry to a JSON string. No code-execution paths.

(entry: FileCacheEntry)

Source from the content-addressed store, hash-verified

184
185
186def _serialize_entry(entry: FileCacheEntry) -> str:
187 """Serialize a FileCacheEntry to a JSON string. No code-execution paths."""
188 return json.dumps({
189 "version": entry.version,
190 "file_path": entry.file_path,
191 "file_hash": entry.file_hash,
192 "mtime": entry.mtime,
193 "full_ast_json_z": base64.b64encode(entry.full_ast_json_z).decode(),
194 "chunks": {
195 k: {
196 "chunk_id": c.chunk_id,
197 "start_line": c.start_line,
198 "end_line": c.end_line,
199 "content_hash": c.content_hash,
200 "ast_json_z": base64.b64encode(c.ast_json_z).decode(),
201 }
202 for k, c in entry.chunks.items()
203 },
204 })
205
206
207def _deserialize_entry(raw: str) -> FileCacheEntry:

Callers 3

test_roundtripMethod · 0.90
_disk_saveMethod · 0.85

Calls

no outgoing calls

Tested by 2

test_roundtripMethod · 0.72