MCPcopy Index your code
hub / github.com/ipython/ipython / load_next

Function load_next

IPython/lib/deepreload.py:122–158  ·  view source on GitHub ↗

mod, name, buf = load_next(mod, altmod, name, buf) altmod is either None or same as mod

(mod, altmod, name, buf)

Source from the content-addressed store, hash-verified

120 return parent, name
121
122def 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

Callers 1

deep_import_hookFunction · 0.85

Calls 2

import_submoduleFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…