Index: third_party/logilab/astng/mixins.py |
diff --git a/third_party/logilab/astroid/mixins.py b/third_party/logilab/astng/mixins.py |
similarity index 73% |
rename from third_party/logilab/astroid/mixins.py |
rename to third_party/logilab/astng/mixins.py |
index f903724559eb4458b152beb49599b3b1615731fc..869a25adddaae1131259d00b2f1bee4278d445b1 100644 |
--- a/third_party/logilab/astroid/mixins.py |
+++ b/third_party/logilab/astng/mixins.py |
@@ -1,25 +1,39 @@ |
-# copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
+# This program 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 of the License, or (at your option) any later |
+# version. |
+# |
+# This program 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 |
+# this program; if not, write to the Free Software Foundation, Inc., |
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
+# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
+# copyright 2003-2010 Sylvain Thenault, all rights reserved. |
+# contact mailto:thenault@gmail.com |
# |
-# This file is part of astroid. |
+# This file is part of logilab-astng. |
# |
-# astroid is free software: you can redistribute it and/or modify it |
+# logilab-astng 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. |
# |
-# astroid is distributed in the hope that it will be useful, but |
+# logilab-astng 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 astroid. If not, see <http://www.gnu.org/licenses/>. |
+# with logilab-astng. If not, see <http://www.gnu.org/licenses/>. |
"""This module contains some mixins for the different nodes. |
""" |
-from astroid.exceptions import (AstroidBuildingException, InferenceError, |
- NotFoundError) |
+from logilab.astng.exceptions import (ASTNGBuildingException, InferenceError, |
+ NotFoundError) |
class BlockRangeMixIn(object): |
@@ -41,7 +55,6 @@ class BlockRangeMixIn(object): |
return lineno, orelse[0].fromlineno - 1 |
return lineno, last or self.tolineno |
- |
class FilterStmtsMixin(object): |
"""Mixin for statement filtering and assignment type""" |
@@ -79,13 +92,14 @@ class ParentAssignTypeMixin(AssignTypeMixin): |
return self.parent.ass_type() |
+ |
class FromImportMixIn(FilterStmtsMixin): |
"""MixIn for From and Import Nodes""" |
def _infer_name(self, frame, name): |
return name |
- def do_import_module(self, modname=None): |
+ def do_import_module(self, modname): |
"""return the ast for a module whose name is <modname> imported by <self> |
""" |
# handle special case where we are on a package node importing a module |
@@ -94,8 +108,6 @@ class FromImportMixIn(FilterStmtsMixin): |
# XXX: no more needed ? |
mymodule = self.root() |
level = getattr(self, 'level', None) # Import as no level |
- if modname is None: |
- modname = self.modname |
# XXX we should investigate deeper if we really want to check |
# importing itself: modname and mymodule.name be relative or absolute |
if mymodule.relative_to_absolute_name(modname, level) == mymodule.name: |
@@ -103,7 +115,7 @@ class FromImportMixIn(FilterStmtsMixin): |
return mymodule |
try: |
return mymodule.import_module(modname, level=level) |
- except AstroidBuildingException: |
+ except ASTNGBuildingException: |
raise InferenceError(modname) |
except SyntaxError, ex: |
raise InferenceError(str(ex)) |
@@ -120,3 +132,5 @@ class FromImportMixIn(FilterStmtsMixin): |
return name |
raise NotFoundError(asname) |
+ |
+ |