(importer, prefix='')
| 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 |
nothing calls this directly
no test coverage detected