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

Method _chunk_hashes

src/pyspector/ast_cache.py:303–316  ·  view source on GitHub ↗
(source: str)

Source from the content-addressed store, hash-verified

301 analysis drivers that want to know exactly what changed.
302 """
303 def _chunk_hashes(source: str) -> Dict[str, str]:
304 with warnings.catch_warnings():
305 warnings.filterwarnings("ignore", category=SyntaxWarning)
306 try:
307 tree = ast.parse(source, filename=str(file_path))
308 except SyntaxError:
309 return {}
310 lines = source.splitlines(keepends=True)
311 seen: Dict[str, int] = {}
312 out: Dict[str, str] = {}
313 for node in tree.body:
314 cid = _make_chunk_id(node, seen)
315 out[cid] = hashlib.sha256(_source_slice(lines, node).encode()).hexdigest()
316 return out
317
318 old_h = _chunk_hashes(old_content)
319 new_h = _chunk_hashes(new_content)

Callers

nothing calls this directly

Calls 2

_make_chunk_idFunction · 0.85
_source_sliceFunction · 0.85

Tested by

no test coverage detected