MCPcopy Index your code
hub / github.com/RustPython/RustPython / find_spec

Method find_spec

Lib/importlib/_bootstrap_external.py:1285–1306  ·  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

1283
1284 @classmethod
1285 def find_spec(cls, fullname, path=None, target=None):
1286 """Try to find a spec for 'fullname' on sys.path or 'path'.
1287
1288 The search is based on sys.path_hooks and sys.path_importer_cache.
1289 """
1290 if path is None:
1291 path = sys.path
1292 spec = cls._get_spec(fullname, path, target)
1293 if spec is None:
1294 return None
1295 elif spec.loader is None:
1296 namespace_path = spec.submodule_search_locations
1297 if namespace_path:
1298 # We found at least one namespace path. Return a spec which
1299 # can create the namespace package.
1300 spec.origin = None
1301 spec.submodule_search_locations = _NamespacePath(fullname, namespace_path, cls._get_spec)
1302 return spec
1303 else:
1304 return None
1305 else:
1306 return spec
1307
1308 @staticmethod
1309 def find_distributions(*args, **kwargs):

Callers 1

_get_specMethod · 0.45

Calls 2

_NamespacePathClass · 0.70
_get_specMethod · 0.45

Tested by

no test coverage detected