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

Function pythonModuleOfFile

src/resolution/module-importers.ts:811–815  ·  view source on GitHub ↗

A Python file's module as a path: `shop/models.py` → 'shop/models', `shop/__init__.py` → 'shop'. Null for a top-level `__init__.py`.

(filePath: string)

Source from the content-addressed store, hash-verified

809
810/** A Python file's module as a path: `shop/models.py` → 'shop/models', `shop/__init__.py` → 'shop'. Null for a top-level `__init__.py`. */
811function pythonModuleOfFile(filePath: string): string | null {
812 if (!filePath.endsWith('.py') || filePath === '__init__.py') return null;
813 if (filePath.endsWith('/__init__.py')) return filePath.slice(0, -'/__init__.py'.length);
814 return filePath.slice(0, -'.py'.length);
815}
816
817/** Deepest relative import a lookup spells out: `from ........ import x`. */
818const MAX_RELATIVE_DOTS = 8;

Callers 1

addPythonImportersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected