Serialize a FileCacheEntry to a JSON string. No code-execution paths.
(entry: FileCacheEntry)
| 184 | |
| 185 | |
| 186 | def _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 | |
| 207 | def _deserialize_entry(raw: str) -> FileCacheEntry: |
no outgoing calls