diff options
author | David Douard <david.douard@logilab.fr> | 2013-06-17 18:09:03 +0200 |
---|---|---|
committer | David Douard <david.douard@logilab.fr> | 2013-06-17 18:09:03 +0200 |
commit | 5b40f8a5d5e6a36fd966eb473d0897f3e2f8c547 (patch) | |
tree | 1597a5d9029ffa1d6ebe328e842f1dd9778290a0 /builder.py | |
parent | 712b9ea501fcea3dce78de05e83083bfa31a7510 (diff) | |
download | astroid-git-5b40f8a5d5e6a36fd966eb473d0897f3e2f8c547.tar.gz |
rename the project astroid
Diffstat (limited to 'builder.py')
-rw-r--r-- | builder.py | 46 |
1 files changed, 23 insertions, 23 deletions
@@ -1,21 +1,21 @@ # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # -# This file is part of logilab-astng. +# This file is part of astroid. # -# logilab-astng is free software: you can redistribute it and/or modify it +# astroid is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by the # Free Software Foundation, either version 2.1 of the License, or (at your # option) any later version. # -# logilab-astng is distributed in the hope that it will be useful, but +# astroid is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License # for more details. # # You should have received a copy of the GNU Lesser General Public License along -# with logilab-astng. If not, see <http://www.gnu.org/licenses/>. -"""The ASTNGBuilder makes astng from living object and / or from _ast +# with astroid. If not, see <http://www.gnu.org/licenses/>. +"""The AstroidBuilder makes astroid from living object and / or from _ast The builder is not thread safe and can't be used to parse different sources at the same time. @@ -28,11 +28,11 @@ from os.path import splitext, basename, exists, abspath from logilab.common.modutils import modpath_from_file -from logilab.astng.exceptions import ASTNGBuildingException, InferenceError -from logilab.astng.raw_building import InspectBuilder -from logilab.astng.rebuilder import TreeRebuilder -from logilab.astng.manager import ASTNGManager -from logilab.astng.bases import YES, Instance +from astroid.exceptions import AstroidBuildingException, InferenceError +from astroid.raw_building import InspectBuilder +from astroid.rebuilder import TreeRebuilder +from astroid.manager import AstroidManager +from astroid.bases import YES, Instance from _ast import PyCF_ONLY_AST def parse(string): @@ -50,7 +50,7 @@ if sys.version_info >= (3, 0): except UnicodeError, uex: # wrong encodingg # detect_encoding returns utf-8 if no encoding specified msg = 'Wrong (%s) or no encoding specified' % encoding - raise ASTNGBuildingException(msg) + raise AstroidBuildingException(msg) return stream, encoding, data else: @@ -79,10 +79,10 @@ else: # ast NG builder ############################################################## -MANAGER = ASTNGManager() +MANAGER = AstroidManager() -class ASTNGBuilder(InspectBuilder): - """provide astng building methods""" +class AstroidBuilder(InspectBuilder): + """provide astroid building methods""" rebuilder = TreeRebuilder() def __init__(self, manager=None): @@ -90,7 +90,7 @@ class ASTNGBuilder(InspectBuilder): self._manager = manager or MANAGER def module_build(self, module, modname=None): - """build an astng from a living module instance + """build an astroid from a living module instance """ node = None path = getattr(module, '__file__', None) @@ -105,7 +105,7 @@ class ASTNGBuilder(InspectBuilder): return node def file_build(self, path, modname=None): - """build astng from a source code file (i.e. from an ast) + """build astroid from a source code file (i.e. from an ast) path is expected to be a python source file """ @@ -113,26 +113,26 @@ class ASTNGBuilder(InspectBuilder): stream, encoding, data = open_source_file(path) except IOError, exc: msg = 'Unable to load file %r (%s)' % (path, exc) - raise ASTNGBuildingException(msg) + raise AstroidBuildingException(msg) except SyntaxError, exc: # py3k encoding specification error - raise ASTNGBuildingException(exc) + raise AstroidBuildingException(exc) except LookupError, exc: # unknown encoding - raise ASTNGBuildingException(exc) + raise AstroidBuildingException(exc) # get module name if necessary if modname is None: try: modname = '.'.join(modpath_from_file(path)) except ImportError: modname = splitext(basename(path))[0] - # build astng representation + # build astroid representation node = self.string_build(data, modname, path) node.file_encoding = encoding return node def string_build(self, data, modname='', path=None): - """build astng from source code string and return rebuilded astng""" + """build astroid from source code string and return rebuilded astroid""" module = self._data_build(data, modname, path) - self._manager.astng_cache[module.name] = module + self._manager.astroid_cache[module.name] = module # post tree building steps after we stored the module in the cache: for from_node in module._from_nodes: self.add_from_names_to_locals(from_node) @@ -176,7 +176,7 @@ class ASTNGBuilder(InspectBuilder): if name == '*': try: imported = node.root().import_module(node.modname) - except ASTNGBuildingException: + except AstroidBuildingException: continue for name in imported.wildcard_import_names(): node.parent.set_local(name, node) |