Yield finders for the given module name If fullname contains a '.', the finders will be for the package containing fullname, otherwise they will be all registered top level finders (i.e. those on both sys.meta_path and sys.path_hooks). If the named module is in a package, that pack
(fullname="")
| 233 | |
| 234 | |
| 235 | def iter_importers(fullname=""): |
| 236 | """Yield finders for the given module name |
| 237 | |
| 238 | If fullname contains a '.', the finders will be for the package |
| 239 | containing fullname, otherwise they will be all registered top level |
| 240 | finders (i.e. those on both sys.meta_path and sys.path_hooks). |
| 241 | |
| 242 | If the named module is in a package, that package is imported as a side |
| 243 | effect of invoking this function. |
| 244 | |
| 245 | If no module name is specified, all top level finders are produced. |
| 246 | """ |
| 247 | if fullname.startswith('.'): |
| 248 | msg = "Relative module name {!r} not supported".format(fullname) |
| 249 | raise ImportError(msg) |
| 250 | if '.' in fullname: |
| 251 | # Get the containing package's __path__ |
| 252 | pkg_name = fullname.rpartition(".")[0] |
| 253 | pkg = importlib.import_module(pkg_name) |
| 254 | path = getattr(pkg, '__path__', None) |
| 255 | if path is None: |
| 256 | return |
| 257 | else: |
| 258 | yield from sys.meta_path |
| 259 | path = sys.path |
| 260 | for item in path: |
| 261 | yield get_importer(item) |
| 262 | |
| 263 | |
| 264 | def extend_path(path, name): |
searching dependent graphs…