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

Method find_spec

Lib/importlib/_bootstrap_external.py:1263–1284  ·  view source on GitHub ↗

Try to find a spec for 'fullname' on sys.path or 'path'. The search is based on sys.path_hooks and sys.path_importer_cache.

(cls, fullname, path=None, target=None)

Source from the content-addressed store, hash-verified

1261
1262 @classmethod
1263 def find_spec(cls, fullname, path=None, target=None):
1264 """Try to find a spec for 'fullname' on sys.path or 'path'.
1265
1266 The search is based on sys.path_hooks and sys.path_importer_cache.
1267 """
1268 if path is None:
1269 path = sys.path
1270 spec = cls._get_spec(fullname, path, target)
1271 if spec is None:
1272 return None
1273 elif spec.loader is None:
1274 namespace_path = spec.submodule_search_locations
1275 if namespace_path:
1276 # We found at least one namespace path. Return a spec which
1277 # can create the namespace package.
1278 spec.origin = None
1279 spec.submodule_search_locations = NamespacePath(fullname, namespace_path, cls._get_spec)
1280 return spec
1281 else:
1282 return None
1283 else:
1284 return spec
1285
1286 @classmethod
1287 def discover(cls, parent=None):

Callers 1

_get_specMethod · 0.45

Calls 2

NamespacePathClass · 0.85
_get_specMethod · 0.45

Tested by

no test coverage detected