Mercurial > hg-stable
changeset 32484:63365e9621d6
demandimport: insert empty line per method
_demandmod class is getting bigger, and I don't want to put more things in
a dense form.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 01 May 2017 14:26:56 +0900 |
parents | 847233374434 |
children | 252d2260c74e |
files | hgdemandimport/demandimportpy2.py |
diffstat | 1 files changed, 5 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgdemandimport/demandimportpy2.py Mon May 01 13:43:31 2017 +0900 +++ b/hgdemandimport/demandimportpy2.py Mon May 01 14:26:56 2017 +0900 @@ -69,6 +69,7 @@ Specify 1 as 'level' argument at construction, to import module relatively. """ + def __init__(self, name, globals, locals, level): if '.' in name: head, rest = name.split('.', 1) @@ -79,6 +80,7 @@ object.__setattr__(self, r"_data", (head, globals, locals, after, level, set())) object.__setattr__(self, r"_module", None) + def _extend(self, name): """add to the list of submodules to load""" self._data[3].append(name) @@ -144,13 +146,16 @@ if self._module: return "<proxied module '%s'>" % self._data[0] return "<unloaded module '%s'>" % self._data[0] + def __call__(self, *args, **kwargs): raise TypeError("%s object is not callable" % repr(self)) + def __getattribute__(self, attr): if attr in ('_data', '_extend', '_load', '_module', '_addref'): return object.__getattribute__(self, attr) self._load() return getattr(self._module, attr) + def __setattr__(self, attr, val): self._load() setattr(self._module, attr, val)