MCPcopy Create free account
hub / github.com/cocoindex-io/cocoindex-code / resolve_db_dir

Function resolve_db_dir

src/cocoindex_code/settings.py:225–240  ·  view source on GitHub ↗

Return the directory for database files given a project root. Applies ``COCOINDEX_CODE_DB_PATH_MAPPING`` if set, otherwise falls back to ``project_root / ".cocoindex_code"``.

(project_root: Path)

Source from the content-addressed store, hash-verified

223
224
225def resolve_db_dir(project_root: Path) -> Path:
226 """Return the directory for database files given a project root.
227
228 Applies ``COCOINDEX_CODE_DB_PATH_MAPPING`` if set, otherwise falls back
229 to ``project_root / ".cocoindex_code"``.
230 """
231 global _db_path_mapping # noqa: PLW0603
232 if _db_path_mapping is None:
233 _db_path_mapping = _parse_path_mapping(_ENV_DB_PATH_MAPPING)
234
235 resolved = project_root.resolve()
236 for mapping in _db_path_mapping:
237 if resolved == mapping.source or resolved.is_relative_to(mapping.source):
238 rel = resolved.relative_to(mapping.source)
239 return mapping.target / rel
240 return project_root / _SETTINGS_DIR_NAME
241
242
243def get_db_path_mappings() -> list[PathMapping]:

Calls 1

_parse_path_mappingFunction · 0.85