MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / guarded_import

Function guarded_import

tests/test_coverage_terminal.py:31–41  ·  view source on GitHub ↗
(path, expected, name)

Source from the content-addressed store, hash-verified

29
30
31def guarded_import(path, expected, name):
32 path = Path(path).resolve(strict=True)
33 with path.open("rb") as stream:
34 snapshot = stream.read(256 * 1024 + 1)
35 require(len(snapshot) <= 256 * 1024 and hashlib.sha256(snapshot).hexdigest() == expected,
36 "reviewed source snapshot differs: " + str(path))
37 spec = importlib.util.spec_from_file_location(name, str(path))
38 require(spec is not None, "cannot construct guarded import")
39 module = importlib.util.module_from_spec(spec)
40 exec(compile(snapshot, str(path), "exec"), module.__dict__)
41 return module
42
43
44def reducer_worker():

Callers 2

reducer_workerFunction · 0.85
__init__Method · 0.85

Calls 4

strFunction · 0.85
openMethod · 0.80
requireFunction · 0.70
readMethod · 0.45

Tested by

no test coverage detected