##// END OF EJS Templates
demandimport: fix import x.y.z as a when x.y is already imported.
Matt Mackall -
r3921:6d0d025e default
parent child Browse files
Show More
@@ -45,12 +45,18 b' class _demandmod(object):'
45 head, globals, locals, after = self._data
45 head, globals, locals, after = self._data
46 mod = _origimport(head, globals, locals)
46 mod = _origimport(head, globals, locals)
47 # load submodules
47 # load submodules
48 def subload(mod, p):
49 h, t = p, None
50 if '.' in p:
51 h, t = p.split('.', 1)
52 if not hasattr(mod, h):
53 setattr(mod, h, _demandmod(p, mod.__dict__, mod.__dict__))
54 else:
55 subload(getattr(mod, h), t)
56
48 for x in after:
57 for x in after:
49 hx = x
58 subload(mod, x)
50 if '.' in x:
59
51 hx = x.split('.')[0]
52 if not hasattr(mod, hx):
53 setattr(mod, hx, _demandmod(x, mod.__dict__, mod.__dict__))
54 # are we in the locals dictionary still?
60 # are we in the locals dictionary still?
55 if locals and locals.get(head) == self:
61 if locals and locals.get(head) == self:
56 locals[head] = mod
62 locals[head] = mod
General Comments 0
You need to be logged in to leave comments. Login now