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

Function iter_modules

Lib/pkgutil.py:94–117  ·  view source on GitHub ↗

Yields ModuleInfo for all submodules on path, or, if path is None, all top-level modules on sys.path. 'path' should be either None or a list of paths to look for modules in. 'prefix' is a string to output on the front of every module name on output.

(path=None, prefix='')

Source from the content-addressed store, hash-verified

92
93
94def iter_modules(path=None, prefix=''):
95 """Yields ModuleInfo for all submodules on path,
96 or, if path is None, all top-level modules on sys.path.
97
98 'path' should be either None or a list of paths to look for
99 modules in.
100
101 'prefix' is a string to output on the front of every module name
102 on output.
103 """
104 if path is None:
105 importers = iter_importers()
106 elif isinstance(path, str):
107 raise ValueError("path must be None or list of paths to look for "
108 "modules in")
109 else:
110 importers = map(get_importer, path)
111
112 yielded = {}
113 for i in importers:
114 for name, ispkg in iter_importer_modules(i, prefix):
115 if name not in yielded:
116 yielded[name] = 1
117 yield ModuleInfo(i, name, ispkg)
118
119
120@simplegeneric

Callers 1

walk_packagesFunction · 0.85

Calls 2

iter_importersFunction · 0.85
iter_importer_modulesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…