Commit c0979706 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b1539ad6
......@@ -200,51 +200,56 @@ Module_getattr = Module.getattr
def _getattr(self, name, *args, **kw):
print 'AAA getattr %s %s' % (self.name, name)
try:
return Module_getattr(self, name, *args, **kw)
except NotFoundError, e:
if self.name.startswith('erp5.'):
raise
real_module = __import__(self.name, fromlist=[self.name], level=0)
try:
attr = getattr(real_module, name)
except AttributeError:
raise e
return Module_getattr(self, name, *args, **kw)
except NotFoundError, e:
if self.name.startswith('erp5.'):
raise
# REQUEST object (or any object non acquisition-wrapped)
if (isinstance(attr, str) and
attr == '<Special Object Used to Force Acquisition>'):
raise e
real_module = __import__(self.name, fromlist=[self.name], level=0)
try:
attr = getattr(real_module, name)
except AttributeError:
raise e
try:
origin_module_name = attr.__module__
except AttributeError:
from astroid import nodes
if isinstance(attr, dict):
ast = nodes.Dict(attr)
elif isinstance(attr, list):
ast = nodes.List(attr)
elif isinstance(attr, tuple):
ast = nodes.Tuple(attr)
elif isinstance(attr, set):
ast = nodes.Set(attr)
# REQUEST object (or any object non acquisition-wrapped)
if (isinstance(attr, str) and
attr == '<Special Object Used to Force Acquisition>'):
raise e
try:
origin_module_name = attr.__module__
except AttributeError:
from astroid import nodes
if isinstance(attr, dict):
ast = nodes.Dict(attr)
elif isinstance(attr, list):
ast = nodes.List(attr)
elif isinstance(attr, tuple):
ast = nodes.Tuple(attr)
elif isinstance(attr, set):
ast = nodes.Set(attr)
else:
try:
ast = nodes.Const(attr)
except Exception:
raise e
else:
if self.name == origin_module_name:
raise
# ast_from_class() actually works for any attribute of a Module
try:
ast = nodes.Const(attr)
except Exception:
ast = MANAGER.ast_from_class(attr)
except AstroidBuildingException:
raise e
else:
if self.name == origin_module_name:
raise
# ast_from_class() actually works for any attribute of a Module
try:
ast = MANAGER.ast_from_class(attr)
except AstroidBuildingException:
raise e
self.locals[name] = [ast]
return [ast]
self.locals[name] = [ast]
print '\t-> ok %s' % (ast,)
return [ast]
except Exception, e:
print '\t-> %s' % (e,)
raise
Module.getattr = _getattr
if sys.version_info < (2, 8):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment