MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _fullmodname

Function _fullmodname

tools/python-3.11.9-amd64/Lib/trace.py:126–152  ·  view source on GitHub ↗

Return a plausible module name for the path.

(path)

Source from the content-addressed store, hash-verified

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

Callers 1

write_resultsMethod · 0.85

Calls 4

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

Tested by

no test coverage detected