summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2010-12-09 10:05:30 +0100
committerEmile Anclin <emile.anclin@logilab.fr>2010-12-09 10:05:30 +0100
commit618701a1cae066ff9e9fd00a6a3c3420931637d5 (patch)
tree2381b7b1de0abbc1fab91a494c3c93195182066d /utils.py
parente997206801738d624e5bb49bf90e88188f26b0f7 (diff)
downloadastroid-git-618701a1cae066ff9e9fd00a6a3c3420931637d5.tar.gz
refactoring for tree rebuilding
rebuilder: move all post build process to builder and don't depend on manager builder: - instanciate ASTNGBuilder's ASTNGManager and TreeRebuilder only once - cleanup build methods; - "_data_build" should become entry point for possible astng pickle cache
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/utils.py b/utils.py
index b9db89e6..745c975a 100644
--- a/utils.py
+++ b/utils.py
@@ -141,6 +141,10 @@ def _check_children(node):
_check_children(child)
+from _ast import PyCF_ONLY_AST
+def parse(string):
+ return compile(string, "<string>", 'exec', PyCF_ONLY_AST)
+
class TreeTester(object):
'''A helper class to see _ast tree and compare with astng tree
@@ -176,9 +180,6 @@ class TreeTester(object):
def build_ast(self):
"""build the _ast tree from the source code"""
- from _ast import PyCF_ONLY_AST
- def parse(string):
- return compile(string, "<string>", 'exec', PyCF_ONLY_AST)
self._ast_node = parse(self.sourcecode)
def native_tree_repr(self, node=None, indent=''):
@@ -240,7 +241,7 @@ class TreeTester(object):
"""build astng tree from the _ast tree
"""
from logilab.astng.builder import ASTNGBuilder
- tree = ASTNGBuilder().ast_build(self._ast_node)
+ tree = ASTNGBuilder().string_build(self.sourcecode)
return tree
def astng_tree_repr(self, ids=False):