diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2009-11-25 18:45:19 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2009-11-25 18:45:19 +0100 |
commit | 61df5384faee1c38e4881a81a00183be6861ed6f (patch) | |
tree | 622dec29438dc1f942298ac694384fca0deb674e /nodes.py | |
parent | 6b59dfa123bb3cfb7474ba321f3ea813bf07e3c8 (diff) | |
download | astroid-git-61df5384faee1c38e4881a81a00183be6861ed6f.tar.gz |
moving stuff around to avoid circular imports
--HG--
branch : rebuild
Diffstat (limited to 'nodes.py')
-rw-r--r-- | nodes.py | 39 |
1 files changed, 6 insertions, 33 deletions
@@ -44,16 +44,16 @@ from itertools import imap from logilab.astng._exceptions import UnresolvableName, NotFoundError, \ InferenceError, ASTNGError from logilab.astng.utils import REDIRECT -from logilab.astng._nodes import _const_factory +from logilab.astng._nodes import class_factory, module_factory -from logilab.astng.node_classes import (Arguments, AssAttr, AssName, Assert, +from logilab.astng.node_classes import (Arguments, AssAttr, Assert, Assign, AugAssign, Backquote, BinOp, BoolOp, Break, CallFunc, Compare, - Comprehension, Const, Continue, Decorators, DelAttr, DelName, Delete, + Comprehension, Const, Continue, Decorators, DelAttr, Delete, Dict, Discard, Ellipsis, EmptyNode, ExceptHandler, Exec, ExtSlice, For, From, Getattr, Global, If, IfExp, Import, Index, Keyword, - 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 + List, ListComp, Pass, Print, Raise, Return, Slice, Subscript, + TryExcept, TryFinally, Tuple, UnaryOp, While, With, Yield, const_factory ) +from logilab.astng.scoped_nodes import AssName, DelName, Name, Module, GenExpr, Lambda, Function, Class # astng fields definition #################################################### @@ -116,32 +116,5 @@ With._astng_fields = ('expr', 'vars', 'body') While._astng_fields = ('test', 'body', 'orelse',) Yield._astng_fields = ('value',) -# constants ... ############################################################## - -CONST_CLS = { - list: List, - tuple: Tuple, - dict: Dict, - } - -def const_factory(value): - """return an astng node for a python value""" - try: - # if value is of class list, tuple, dict use specific class, not Const - cls = CONST_CLS[value.__class__] - node = cls() - if isinstance(node, Dict): - node.items = () - else: - node.elts = () - except KeyError: - try: - node = Const(value) - except KeyError: - node = _const_factory(value) - return node - -LOCALS_NODES = (Class, Function, GenExpr, Lambda, Module) - |