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

Method _resolve_filename

Lib/importlib/_bootstrap.py:1023–1045  ·  view source on GitHub ↗
(cls, fullname, alias=None, ispkg=False)

Source from the content-addressed store, hash-verified

1021
1022 @classmethod
1023 def _resolve_filename(cls, fullname, alias=None, ispkg=False):
1024 if not fullname or not getattr(sys, '_stdlib_dir', None):
1025 return None, None
1026 try:
1027 sep = cls._SEP
1028 except AttributeError:
1029 sep = cls._SEP = '\\' if sys.platform == 'win32' else '/'
1030
1031 if fullname != alias:
1032 if fullname.startswith('<'):
1033 fullname = fullname[1:]
1034 if not ispkg:
1035 fullname = f'{fullname}.__init__'
1036 else:
1037 ispkg = False
1038 relfile = fullname.replace('.', sep)
1039 if ispkg:
1040 pkgdir = f'{sys._stdlib_dir}{sep}{relfile}'
1041 filename = f'{pkgdir}{sep}__init__.py'
1042 else:
1043 pkgdir = None
1044 filename = f'{sys._stdlib_dir}{sep}{relfile}.py'
1045 return filename, pkgdir
1046
1047 @classmethod
1048 def find_spec(cls, fullname, path=None, target=None):

Callers 2

_fix_up_moduleMethod · 0.80
find_specMethod · 0.80

Calls 2

startswithMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected