MCPcopy Index your code
hub / github.com/idank/explainshell / make

Function make

tests/test_caching_store.py:41–64  ·  view source on GitHub ↗
(
        manpages: Sequence[ParsedManpage],
        *,
        max_cache_bytes: int | None = None,
        max_entry_bytes: int | None = None,
        max_entries: int | None = None,
    )

Source from the content-addressed store, hash-verified

39 stores: list[CachingStore] = []
40
41 def make(
42 manpages: Sequence[ParsedManpage],
43 *,
44 max_cache_bytes: int | None = None,
45 max_entry_bytes: int | None = None,
46 max_entries: int | None = None,
47 ) -> CachingStore:
48 db_path = tmp_path / f"cache-{len(stores)}.db"
49 writable = Store.create(str(db_path))
50 for manpage in manpages:
51 writable.add_manpage(manpage, _make_raw())
52 writable.close()
53
54 kwargs: dict[str, int] = {}
55 if max_cache_bytes is not None:
56 kwargs["max_cache_bytes"] = max_cache_bytes
57 if max_entry_bytes is not None:
58 kwargs["max_entry_bytes"] = max_entry_bytes
59 if max_entries is not None:
60 kwargs["max_entries"] = max_entries
61
62 cached = CachingStore(str(db_path), **kwargs)
63 stores.append(cached)
64 return cached
65
66 yield make
67

Callers 3

loadBasenamesMethod · 0.85
loadCannedMethod · 0.85
basenameSetFunction · 0.85

Calls 5

CachingStoreClass · 0.90
add_manpageMethod · 0.80
_make_rawFunction · 0.70
createMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected