MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / moduleReferenceKeys

Function moduleReferenceKeys

src/db/reference-tail.ts:150–159  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

148 * the same keys.
149 */
150export function moduleReferenceKeys(filePath: string): string[] {
151 const keys = importPathKeys(filePath);
152 // A Python package's `__init__.py` is a submodule of the package above it,
153 // as a module file beside it is through its folder: `app/pkg/sub/__init__.py`
154 // is what `from app.pkg import sub as s`, parked as 'module:pkg', imports.
155 const parts = filePath.split('/');
156 const above = parts.length >= 3 && parts[parts.length - 1] === '__init__.py' ? parts[parts.length - 3]! : '';
157 if (above && !keys.includes(above)) keys.push(above);
158 return keys.map((key) => MODULE_KEY + key);
159}

Calls 3

importPathKeysFunction · 0.85
pushMethod · 0.80
mapMethod · 0.80

Tested by

no test coverage detected