##// END OF EJS Templates
demandimport: insert empty line per method...
Yuya Nishihara -
r32446:63365e96 default
parent child Browse files
Show More
@@ -69,6 +69,7 b' class _demandmod(object):'
69 Specify 1 as 'level' argument at construction, to import module
69 Specify 1 as 'level' argument at construction, to import module
70 relatively.
70 relatively.
71 """
71 """
72
72 def __init__(self, name, globals, locals, level):
73 def __init__(self, name, globals, locals, level):
73 if '.' in name:
74 if '.' in name:
74 head, rest = name.split('.', 1)
75 head, rest = name.split('.', 1)
@@ -79,6 +80,7 b' class _demandmod(object):'
79 object.__setattr__(self, r"_data",
80 object.__setattr__(self, r"_data",
80 (head, globals, locals, after, level, set()))
81 (head, globals, locals, after, level, set()))
81 object.__setattr__(self, r"_module", None)
82 object.__setattr__(self, r"_module", None)
83
82 def _extend(self, name):
84 def _extend(self, name):
83 """add to the list of submodules to load"""
85 """add to the list of submodules to load"""
84 self._data[3].append(name)
86 self._data[3].append(name)
@@ -144,13 +146,16 b' class _demandmod(object):'
144 if self._module:
146 if self._module:
145 return "<proxied module '%s'>" % self._data[0]
147 return "<proxied module '%s'>" % self._data[0]
146 return "<unloaded module '%s'>" % self._data[0]
148 return "<unloaded module '%s'>" % self._data[0]
149
147 def __call__(self, *args, **kwargs):
150 def __call__(self, *args, **kwargs):
148 raise TypeError("%s object is not callable" % repr(self))
151 raise TypeError("%s object is not callable" % repr(self))
152
149 def __getattribute__(self, attr):
153 def __getattribute__(self, attr):
150 if attr in ('_data', '_extend', '_load', '_module', '_addref'):
154 if attr in ('_data', '_extend', '_load', '_module', '_addref'):
151 return object.__getattribute__(self, attr)
155 return object.__getattribute__(self, attr)
152 self._load()
156 self._load()
153 return getattr(self._module, attr)
157 return getattr(self._module, attr)
158
154 def __setattr__(self, attr, val):
159 def __setattr__(self, attr, val):
155 self._load()
160 self._load()
156 setattr(self._module, attr, val)
161 setattr(self._module, attr, val)
General Comments 0
You need to be logged in to leave comments. Login now