* The module file for the dotted path `relPath` (slash-joined) under `root`, * walking it the way the import system does: every prefix must be a package * — regular, or a namespace directory — so a prefix that is a plain module * (`pkg/sub.py` with no `pkg/sub/__init__.py`) ends the walk, and *
(root: string, relPath: string, index: PythonModuleIndex)
| 832 | * `pkg.sub.x` does not exist even if `pkg/sub/x.py` does. |
| 833 | */ |
| 834 | function pythonModuleUnder(root: string, relPath: string, index: PythonModuleIndex): string | null { |
| 835 | const parts = relPath.split('/'); |
| 836 | let base = root; |
| 837 | for (let i = 0; i < parts.length - 1; i++) { |
| 838 | base = joinRel(base, parts[i]!); |
| 839 | if (index.files.has(joinRel(base, '__init__.py'))) continue; |
| 840 | if (index.files.has(`${base}.py`) || !index.dirs.has(base)) return null; |
| 841 | } |
| 842 | return pythonModuleAt(joinRel(root, relPath), index); |
| 843 | } |
| 844 | |
| 845 | /** How `root` provides the top-level name `head`: concretely, as a namespace portion, or not at all. */ |
| 846 | function pythonHeadKind(root: string, head: string, index: PythonModuleIndex): 'concrete' | 'namespace' | null { |
no test coverage detected