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

Method run

tools/python-3.11.9-amd64/Lib/pydoc.py:2309–2365  ·  view source on GitHub ↗
(self, callback, key=None, completer=None, onerror=None)

Source from the content-addressed store, hash-verified

2307 """An interruptible scanner that searches module synopses."""
2308
2309 def run(self, callback, key=None, completer=None, onerror=None):
2310 if key: key = key.lower()
2311 self.quit = False
2312 seen = {}
2313
2314 for modname in sys.builtin_module_names:
2315 if modname != '__main__':
2316 seen[modname] = 1
2317 if key is None:
2318 callback(None, modname, '')
2319 else:
2320 name = __import__(modname).__doc__ or ''
2321 desc = name.split('\n')[0]
2322 name = modname + ' - ' + desc
2323 if name.lower().find(key) >= 0:
2324 callback(None, modname, desc)
2325
2326 for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
2327 if self.quit:
2328 break
2329
2330 if key is None:
2331 callback(None, modname, '')
2332 else:
2333 try:
2334 spec = pkgutil._get_spec(importer, modname)
2335 except SyntaxError:
2336 # raised by tests for bad coding cookies or BOM
2337 continue
2338 loader = spec.loader
2339 if hasattr(loader, 'get_source'):
2340 try:
2341 source = loader.get_source(modname)
2342 except Exception:
2343 if onerror:
2344 onerror(modname)
2345 continue
2346 desc = source_synopsis(io.StringIO(source)) or ''
2347 if hasattr(loader, 'get_filename'):
2348 path = loader.get_filename(modname)
2349 else:
2350 path = None
2351 else:
2352 try:
2353 module = importlib._bootstrap._load(spec)
2354 except ImportError:
2355 if onerror:
2356 onerror(modname)
2357 continue
2358 desc = module.__doc__.splitlines()[0] if module.__doc__ else ''
2359 path = getattr(module,'__file__',None)
2360 name = modname + ' - ' + desc
2361 if name.lower().find(key) >= 0:
2362 callback(path, modname, desc)
2363
2364 if completer:
2365 completer()
2366

Callers

nothing calls this directly

Calls 12

__import__Function · 0.85
source_synopsisFunction · 0.85
splitlinesMethod · 0.80
callbackFunction · 0.70
onerrorFunction · 0.70
lowerMethod · 0.45
splitMethod · 0.45
findMethod · 0.45
_get_specMethod · 0.45
get_sourceMethod · 0.45
get_filenameMethod · 0.45
_loadMethod · 0.45

Tested by

no test coverage detected