Skip to content
Snippets Groups Projects
Commit 63365e9621d6 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

demandimport: insert empty line per method

_demandmod class is getting bigger, and I don't want to put more things in
a dense form.
parent 847233374434
No related branches found
No related tags found
No related merge requests found
......@@ -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,5 +146,6 @@
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))
......@@ -147,7 +150,8 @@
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)
......@@ -149,8 +153,9 @@
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment