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)
| 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`. */ |
| 811 | function 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`. */ |
| 818 | const MAX_RELATIVE_DOTS = 8; |
no outgoing calls
no test coverage detected