43 def _load(self): |
43 def _load(self): |
44 if not self._module: |
44 if not self._module: |
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 |
57 object.__setattr__(self, "_module", mod) |
63 object.__setattr__(self, "_module", mod) |
58 def __repr__(self): |
64 def __repr__(self): |