mercurial/demandimport.py
changeset 4631 e3afa670e484
parent 4626 eb99af2d845e
child 4635 63b9d2deed48
equal deleted inserted replaced
4630:e6d105a51ec7 4631:e3afa670e484
    59 
    59 
    60             # are we in the locals dictionary still?
    60             # are we in the locals dictionary still?
    61             if locals and locals.get(head) == self:
    61             if locals and locals.get(head) == self:
    62                 locals[head] = mod
    62                 locals[head] = mod
    63             object.__setattr__(self, "_module", mod)
    63             object.__setattr__(self, "_module", mod)
       
    64 
    64     def __repr__(self):
    65     def __repr__(self):
       
    66         if self._module:
       
    67             return "<proxied module '%s'>" % self._data[0]
    65         return "<unloaded module '%s'>" % self._data[0]
    68         return "<unloaded module '%s'>" % self._data[0]
    66     def __call__(self, *args, **kwargs):
    69     def __call__(self, *args, **kwargs):
    67         raise TypeError("'unloaded module' object is not callable")
    70         raise TypeError("'unloaded module' object is not callable")
    68     def __getattribute__(self, attr):
    71     def __getattribute__(self, attr):
    69         if attr in ('_data', '_extend', '_load', '_module'):
    72         if attr in ('_data', '_extend', '_load', '_module'):
   100                 setattr(mod, comp, _demandmod(comp, mod.__dict__, mod.__dict__))
   103                 setattr(mod, comp, _demandmod(comp, mod.__dict__, mod.__dict__))
   101             mod = getattr(mod, comp)
   104             mod = getattr(mod, comp)
   102         for x in fromlist:
   105         for x in fromlist:
   103             # set requested submodules for demand load
   106             # set requested submodules for demand load
   104             if not(hasattr(mod, x)):
   107             if not(hasattr(mod, x)):
   105                 setattr(mod, x, _demandmod(x, mod.__dict__, mod.__dict__))
   108                 setattr(mod, x, _demandmod(x, mod.__dict__, locals))
   106         return mod
   109         return mod
   107 
   110 
   108 ignore = ['_hashlib', '_xmlplus', 'fcntl', 'win32com.gen_py']
   111 ignore = ['_hashlib', '_xmlplus', 'fcntl', 'win32com.gen_py']
   109 
   112 
   110 def enable():
   113 def enable():