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

Function _fullmodname

Lib/trace.py:124–150  ·  view source on GitHub ↗

Return a plausible module name for the path.

(path)

Source from the content-addressed store, hash-verified

122 return filename
123
124def _fullmodname(path):
125 """Return a plausible module name for the path."""
126
127 # If the file 'path' is part of a package, then the filename isn't
128 # enough to uniquely identify it. Try to do the right thing by
129 # looking in sys.path for the longest matching prefix. We'll
130 # assume that the rest is the package name.
131
132 comparepath = os.path.normcase(path)
133 longest = ""
134 for dir in sys.path:
135 dir = os.path.normcase(dir)
136 if comparepath.startswith(dir) and comparepath[len(dir)] == os.sep:
137 if len(dir) > len(longest):
138 longest = dir
139
140 if longest:
141 base = path[len(longest) + 1:]
142 else:
143 base = path
144 # the drive letter is never part of the module name
145 drive, base = os.path.splitdrive(base)
146 base = base.replace(os.sep, ".")
147 if os.altsep:
148 base = base.replace(os.altsep, ".")
149 filename, ext = os.path.splitext(base)
150 return filename.lstrip(".")
151
152class CoverageResults:
153 def __init__(self, counts=None, calledfuncs=None, infile=None,

Callers 1

write_resultsMethod · 0.85

Calls 5

normcaseMethod · 0.80
splitextMethod · 0.80
startswithMethod · 0.45
replaceMethod · 0.45
lstripMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…