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

Function scan_modules

scripts/whats_left.py:223–242  ·  view source on GitHub ↗

taken from the source code of help('modules') https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/pydoc.py#L2178

()

Source from the content-addressed store, hash-verified

221
222
223def scan_modules():
224 """taken from the source code of help('modules')
225
226 https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/pydoc.py#L2178"""
227 modules = {}
228
229 def callback(path, modname, desc, modules=modules):
230 if modname and modname[-9:] == ".__init__":
231 modname = modname[:-9] + " (package)"
232 if modname.find(".") < 0:
233 modules[modname] = 1
234
235 def onerror(modname):
236 callback(None, modname, None)
237
238 with warnings.catch_warnings():
239 # ignore warnings from importing deprecated modules
240 warnings.simplefilter("ignore")
241 ModuleScanner().run(callback, onerror=onerror)
242 return list(modules.keys())
243
244
245def import_module(module_name):

Callers 1

gen_modulesFunction · 0.85

Calls 4

ModuleScannerClass · 0.90
listClass · 0.85
runMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected