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

Function iter_importers

Lib/pkgutil.py:235–261  ·  view source on GitHub ↗

Yield finders for the given module name If fullname contains a '.', the finders will be for the package containing fullname, otherwise they will be all registered top level finders (i.e. those on both sys.meta_path and sys.path_hooks). If the named module is in a package, that pack

(fullname="")

Source from the content-addressed store, hash-verified

233
234
235def iter_importers(fullname=""):
236 """Yield finders for the given module name
237
238 If fullname contains a '.', the finders will be for the package
239 containing fullname, otherwise they will be all registered top level
240 finders (i.e. those on both sys.meta_path and sys.path_hooks).
241
242 If the named module is in a package, that package is imported as a side
243 effect of invoking this function.
244
245 If no module name is specified, all top level finders are produced.
246 """
247 if fullname.startswith('.'):
248 msg = "Relative module name {!r} not supported".format(fullname)
249 raise ImportError(msg)
250 if '.' in fullname:
251 # Get the containing package's __path__
252 pkg_name = fullname.rpartition(".")[0]
253 pkg = importlib.import_module(pkg_name)
254 path = getattr(pkg, '__path__', None)
255 if path is None:
256 return
257 else:
258 yield from sys.meta_path
259 path = sys.path
260 for item in path:
261 yield get_importer(item)
262
263
264def extend_path(path, name):

Callers 2

iter_modulesFunction · 0.85
test_iter_importersMethod · 0.85

Calls 5

get_importerFunction · 0.85
startswithMethod · 0.45
formatMethod · 0.45
rpartitionMethod · 0.45
import_moduleMethod · 0.45

Tested by 1

test_iter_importersMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…