MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / iter_modules

Function iter_modules

tools/python-3.11.9-amd64/Lib/pkgutil.py:110–133  ·  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

108
109
110def iter_modules(path=None, prefix=''):
111 """Yields ModuleInfo for all submodules on path,
112 or, if path is None, all top-level modules on sys.path.
113
114 'path' should be either None or a list of paths to look for
115 modules in.
116
117 'prefix' is a string to output on the front of every module name
118 on output.
119 """
120 if path is None:
121 importers = iter_importers()
122 elif isinstance(path, str):
123 raise ValueError("path must be None or list of paths to look for "
124 "modules in")
125 else:
126 importers = map(get_importer, path)
127
128 yielded = {}
129 for i in importers:
130 for name, ispkg in iter_importer_modules(i, prefix):
131 if name not in yielded:
132 yielded[name] = 1
133 yield ModuleInfo(i, name, ispkg)
134
135
136@simplegeneric

Callers 1

walk_packagesFunction · 0.85

Calls 3

iter_importersFunction · 0.85
iter_importer_modulesFunction · 0.85
mapFunction · 0.50

Tested by

no test coverage detected