summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2009-11-25 17:27:23 +0100
committerEmile Anclin <emile.anclin@logilab.fr>2009-11-25 17:27:23 +0100
commit6b59dfa123bb3cfb7474ba321f3ea813bf07e3c8 (patch)
tree85d59842d94c26eed04b87d6a9e738ca6dbae311
parent0e0a115601ebbbaace352003299573450a4f1b31 (diff)
downloadastroid-git-6b59dfa123bb3cfb7474ba321f3ea813bf07e3c8.tar.gz
trying to handle the imports
--HG-- branch : rebuild
-rw-r--r--_nodes_ast.py3
-rw-r--r--builder.py2
-rw-r--r--inference.py2
-rw-r--r--infutils.py3
-rw-r--r--lookup.py11
-rw-r--r--nodes.py1
-rw-r--r--protocols.py2
7 files changed, 11 insertions, 13 deletions
diff --git a/_nodes_ast.py b/_nodes_ast.py
index 04a80eb8..216048f4 100644
--- a/_nodes_ast.py
+++ b/_nodes_ast.py
@@ -77,7 +77,8 @@ from _ast import (
from logilab.astng.utils import ASTVisitor
-BaseClass = object
+class BaseClass(object):
+ """base class for ASTNG node classes"""
_BIN_OP_CLASSES = {_Add: '+',
_BitAnd: '&',
diff --git a/builder.py b/builder.py
index 1eaabff5..6413f3d1 100644
--- a/builder.py
+++ b/builder.py
@@ -140,11 +140,11 @@ class ASTNGBuilder:
node.package = path and path.find('__init__.py') > -1 or False
node.name = modname
node.pure_python = True
+ node = self.rebuilder.walk(node) # XXX get the added attributes
if self._manager is not None:
self._manager._cache[node.file] = node
if self._file:
self._manager._cache[abspath(self._file)] = node
- self.rebuilder.walk(node)
return node
# astng from living objects ###############################################
diff --git a/inference.py b/inference.py
index d8f67c97..9e60662f 100644
--- a/inference.py
+++ b/inference.py
@@ -30,7 +30,7 @@ try:
except NameError:
class GeneratorExit(Exception): pass
-from logilab.astng import MANAGER, _nodes as nodes, raw_building
+from logilab.astng import MANAGER, nodes, raw_building
from logilab.astng import ASTNGError, InferenceError, UnresolvableName, \
NoDefault, NotFoundError, ASTNGBuildingException
from logilab.astng.infutils import YES, Instance, InferenceContext, \
diff --git a/infutils.py b/infutils.py
index f08afa56..b4e5650c 100644
--- a/infutils.py
+++ b/infutils.py
@@ -25,7 +25,8 @@ __doctype__ = "restructuredtext en"
from logilab.common.compat import chain, imap
from logilab.astng._exceptions import InferenceError, NotFoundError, UnresolvableName
-from logilab.astng._nodes import BaseClass, List, Tuple, Function, If, TryExcept
+from logilab.astng._nodes import BaseClass
+from logilab.astng.node_classes import List, Tuple, If, TryExcept
class Proxy(BaseClass):
diff --git a/lookup.py b/lookup.py
index df7c8554..fd731cda 100644
--- a/lookup.py
+++ b/lookup.py
@@ -31,7 +31,7 @@ __docformat__ = "restructuredtext en"
import __builtin__
from logilab.astng import MANAGER, NotFoundError
-from logilab.astng import _nodes as nodes
+from logilab.astng import nodes # XXX this will not work ?? circular import
from logilab.astng._nodes import BaseClass, NodeNG
from logilab.astng.infutils import are_exclusive, copy_context, _infer_stmts
@@ -118,7 +118,7 @@ class LookupMixIn(BaseClass):
# current node (gen exp, list comp)
_stmts = [node]
break
- optional_assign = isinstance(ass_type, nodes.LOOP_SCOPES)
+ optional_assign = isinstance(ass_type, (nodes.For, nodes.Comprehension))
if optional_assign and ass_type.parent_of(self):
# we are inside a loop, loop var assigment is hidding previous
# assigment
@@ -194,11 +194,6 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
""" this class provides locals handling common to Module, Function
and Class nodes, including a dict like interface for direct access
to locals information
-
- /!\ this class should not be used directly /!\ it's
- only used as a methods and attribute container, and update the
- original class from the compiler.ast module using its dictionary
- (see below the class definition)
"""
# attributes below are set by the builder module or by raw factories
@@ -315,4 +310,6 @@ class LocalsDictNodeNG(LookupMixIn, NodeNG):
__contains__ = has_key
+# maybe import at the end ?
+from logilab.astng import nodes
diff --git a/nodes.py b/nodes.py
index a714f711..244b43c8 100644
--- a/nodes.py
+++ b/nodes.py
@@ -54,7 +54,6 @@ from logilab.astng.node_classes import (Arguments, AssAttr, AssName, Assert,
List, ListComp, Name, Pass, Print, Raise, Return, Slice, Subscript,
TryExcept, TryFinally, Tuple, UnaryOp, While, With, Yield)
from logilab.astng.scoped_nodes import Module, GenExpr, Lambda, Function, Class
-from logilab.astng.lookup import LookupMixIn
# astng fields definition ####################################################
diff --git a/protocols.py b/protocols.py
index 492f3e91..b7962fe2 100644
--- a/protocols.py
+++ b/protocols.py
@@ -27,7 +27,7 @@ __doctype__ = "restructuredtext en"
from logilab.astng import InferenceError, NoDefault, _nodes as nodes
from logilab.astng.infutils import copy_context, unpack_infer, \
raise_if_nothing_infered, yes_if_nothing_infered, Instance, Generator, YES
-from logilab.astng._nodes import Const, Class, Function, Tuple, List, \
+from logilab.astng.nodes import Const, Class, Function, Tuple, List, \
const_factory
# unary operations ############################################################