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

Function iter_zipimport_modules

tools/python-3.11.9-amd64/Lib/pkgutil.py:373–399  ·  view source on GitHub ↗
(importer, prefix='')

Source from the content-addressed store, hash-verified

371 from zipimport import zipimporter
372
373 def iter_zipimport_modules(importer, prefix=''):
374 dirlist = sorted(zipimport._zip_directory_cache[importer.archive])
375 _prefix = importer.prefix
376 plen = len(_prefix)
377 yielded = {}
378 import inspect
379 for fn in dirlist:
380 if not fn.startswith(_prefix):
381 continue
382
383 fn = fn[plen:].split(os.sep)
384
385 if len(fn)==2 and fn[1].startswith('__init__.py'):
386 if fn[0] not in yielded:
387 yielded[fn[0]] = 1
388 yield prefix + fn[0], True
389
390 if len(fn)!=1:
391 continue
392
393 modname = inspect.getmodulename(fn[0])
394 if modname=='__init__':
395 continue
396
397 if modname and '.' not in modname and modname not in yielded:
398 yielded[modname] = 1
399 yield prefix + modname, False
400
401 iter_importer_modules.register(zipimporter, iter_zipimport_modules)
402

Callers

nothing calls this directly

Calls 3

sortedFunction · 0.85
startswithMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected