(importer, prefix='')
| 174 | from zipimport import zipimporter |
| 175 | |
| 176 | def iter_zipimport_modules(importer, prefix=''): |
| 177 | dirlist = sorted(zipimport._zip_directory_cache[importer.archive]) |
| 178 | _prefix = importer.prefix |
| 179 | plen = len(_prefix) |
| 180 | yielded = {} |
| 181 | import inspect |
| 182 | for fn in dirlist: |
| 183 | if not fn.startswith(_prefix): |
| 184 | continue |
| 185 | |
| 186 | fn = fn[plen:].split(os.sep) |
| 187 | |
| 188 | if len(fn)==2 and fn[1].startswith('__init__.py'): |
| 189 | if fn[0] not in yielded: |
| 190 | yielded[fn[0]] = 1 |
| 191 | yield prefix + fn[0], True |
| 192 | |
| 193 | if len(fn)!=1: |
| 194 | continue |
| 195 | |
| 196 | modname = inspect.getmodulename(fn[0]) |
| 197 | if modname=='__init__': |
| 198 | continue |
| 199 | |
| 200 | if modname and '.' not in modname and modname not in yielded: |
| 201 | yielded[modname] = 1 |
| 202 | yield prefix + modname, False |
| 203 | |
| 204 | iter_importer_modules.register(zipimporter, iter_zipimport_modules) |
| 205 |
nothing calls this directly
no test coverage detected