Commit c0979706 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent b1539ad6
...@@ -200,51 +200,56 @@ Module_getattr = Module.getattr ...@@ -200,51 +200,56 @@ Module_getattr = Module.getattr
def _getattr(self, name, *args, **kw): def _getattr(self, name, *args, **kw):
print 'AAA getattr %s %s' % (self.name, name) print 'AAA getattr %s %s' % (self.name, name)
try: 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: try:
attr = getattr(real_module, name) return Module_getattr(self, name, *args, **kw)
except AttributeError: except NotFoundError, e:
raise e if self.name.startswith('erp5.'):
raise
# REQUEST object (or any object non acquisition-wrapped) real_module = __import__(self.name, fromlist=[self.name], level=0)
if (isinstance(attr, str) and try:
attr == '<Special Object Used to Force Acquisition>'): attr = getattr(real_module, name)
raise e except AttributeError:
raise e
try: # REQUEST object (or any object non acquisition-wrapped)
origin_module_name = attr.__module__ if (isinstance(attr, str) and
except AttributeError: attr == '<Special Object Used to Force Acquisition>'):
from astroid import nodes raise e
if isinstance(attr, dict):
ast = nodes.Dict(attr) try:
elif isinstance(attr, list): origin_module_name = attr.__module__
ast = nodes.List(attr) except AttributeError:
elif isinstance(attr, tuple): from astroid import nodes
ast = nodes.Tuple(attr) if isinstance(attr, dict):
elif isinstance(attr, set): ast = nodes.Dict(attr)
ast = nodes.Set(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: else:
if self.name == origin_module_name:
raise
# ast_from_class() actually works for any attribute of a Module
try: try:
ast = nodes.Const(attr) ast = MANAGER.ast_from_class(attr)
except Exception: except AstroidBuildingException:
raise e 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] self.locals[name] = [ast]
return [ast] print '\t-> ok %s' % (ast,)
return [ast]
except Exception, e:
print '\t-> %s' % (e,)
raise
Module.getattr = _getattr Module.getattr = _getattr
if sys.version_info < (2, 8): 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