MCPcopy Create free account
hub / github.com/dbcli/mycli / parse_prefetch_config

Function parse_prefetch_config

mycli/schema_prefetcher.py:32–48  ·  view source on GitHub ↗

Parse the ``prefetch_schemas_mode`` / ``prefetch_schemas_list`` options. Returns ``None`` when every accessible schema should be prefetched (``always``), an empty list when prefetching is disabled (``never``), or ``schema_list`` when the mode is ``listed``. Unknown modes fall back t

(mode: str, schema_list: list[str])

Source from the content-addressed store, hash-verified

30
31
32def parse_prefetch_config(mode: str, schema_list: list[str]) -> list[str] | None:
33 """Parse the ``prefetch_schemas_mode`` / ``prefetch_schemas_list`` options.
34
35 Returns ``None`` when every accessible schema should be prefetched
36 (``always``), an empty list when prefetching is disabled
37 (``never``), or ``schema_list`` when the mode is ``listed``.
38 Unknown modes fall back to ``always``.
39 """
40 try:
41 parsed = PrefetchMode(mode.strip().lower())
42 except ValueError:
43 return None
44 if parsed is PrefetchMode.NEVER:
45 return []
46 if parsed is PrefetchMode.LISTED:
47 return schema_list
48 return None
49
50
51class SchemaPrefetcher:

Calls 1

PrefetchModeClass · 0.85