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

Function getmodulename

tools/python-3.11.9-amd64/Lib/inspect.py:920–930  ·  view source on GitHub ↗

Return the module name for a given file, or None.

(path)

Source from the content-addressed store, hash-verified

918 type(object).__name__))
919
920def getmodulename(path):
921 """Return the module name for a given file, or None."""
922 fname = os.path.basename(path)
923 # Check for paths that look like an actual module file
924 suffixes = [(-len(suffix), suffix)
925 for suffix in importlib.machinery.all_suffixes()]
926 suffixes.sort() # try longest suffixes first, in case they overlap
927 for neglen, suffix in suffixes:
928 if fname.endswith(suffix):
929 return fname[:neglen]
930 return None
931
932def getsourcefile(object):
933 """Return the filename that can be used to locate an object's source.

Callers

nothing calls this directly

Calls 3

basenameMethod · 0.80
endswithMethod · 0.80
sortMethod · 0.45

Tested by

no test coverage detected