MCPcopy Index your code
hub / github.com/python/cpython / _path_to_module

Function _path_to_module

Lib/profiling/sampling/heatmap_collector.py:154–169  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

152
153
154def _path_to_module(path):
155 if isinstance(path, str):
156 path = Path(path)
157
158 # Remove .py extension
159 if path.suffix == '.py':
160 path = path.with_suffix('')
161
162 # Convert path separators to dots
163 parts = path.parts
164
165 # Handle __init__ files - they represent the package itself
166 if parts and parts[-1] == '__init__':
167 parts = parts[:-1]
168
169 return '.'.join(parts) if parts else path.stem
170
171
172# ============================================================================

Callers 1

extract_module_nameFunction · 0.85

Calls 3

PathClass · 0.90
with_suffixMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…