mod, name, buf = load_next(mod, altmod, name, buf) altmod is either None or same as mod
(mod, altmod, name, buf)
| 120 | return parent, name |
| 121 | |
| 122 | def load_next(mod, altmod, name, buf): |
| 123 | """ |
| 124 | mod, name, buf = load_next(mod, altmod, name, buf) |
| 125 | |
| 126 | altmod is either None or same as mod |
| 127 | """ |
| 128 | |
| 129 | if len(name) == 0: |
| 130 | # completely empty module name should only happen in |
| 131 | # 'from . import' (or '__import__("")') |
| 132 | return mod, None, buf |
| 133 | |
| 134 | dot = name.find('.') |
| 135 | if dot == 0: |
| 136 | raise ValueError('Empty module name') |
| 137 | |
| 138 | if dot < 0: |
| 139 | subname = name |
| 140 | next = None |
| 141 | else: |
| 142 | subname = name[:dot] |
| 143 | next = name[dot+1:] |
| 144 | |
| 145 | if buf != '': |
| 146 | buf += '.' |
| 147 | buf += subname |
| 148 | |
| 149 | result = import_submodule(mod, subname, buf) |
| 150 | if result is None and mod != altmod: |
| 151 | result = import_submodule(altmod, subname, subname) |
| 152 | if result is not None: |
| 153 | buf = subname |
| 154 | |
| 155 | if result is None: |
| 156 | raise ImportError("No module named %.200s" % name) |
| 157 | |
| 158 | return result, next, buf |
| 159 | |
| 160 | |
| 161 | # Need to keep track of what we've already reloaded to prevent cyclic evil |
no test coverage detected
searching dependent graphs…