1- # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
2- # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
3- #
4- # This file is part of astroid.
5- #
6- # astroid is free software: you can redistribute it and/or modify it
7- # under the terms of the GNU Lesser General Public License as published by the
8- # Free Software Foundation, either version 2.1 of the License, or (at your
9- # option) any later version.
10- #
11- # astroid is distributed in the hope that it will be useful, but
12- # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13- # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14- # for more details.
15- #
16- # You should have received a copy of the GNU Lesser General Public License along
17- # with astroid. If not, see <http://www.gnu.org/licenses/>.
1+ # Copyright (c) 2006-2013, 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
2+ # Copyright (c) 2014 Google, Inc.
3+ # Copyright (c) 2015-2016 Claudiu Popa <pcmanticore@gmail.com>
4+
5+ # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
6+ # For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
7+
188"""Python Abstract Syntax Tree New Generation
199
2010The aim of this module is to provide a common base representation of
3929
4030* builder contains the class responsible to build astroid trees
4131"""
42- __doctype__ = "restructuredtext en"
4332
33+ import os
4434import sys
4535import re
4636from operator import attrgetter
4737
38+ import enum
39+
40+
41+ _Context = enum .Enum ('Context' , 'Load Store Del' )
42+ Load = _Context .Load
43+ Store = _Context .Store
44+ Del = _Context .Del
45+ del _Context
46+
47+
48+ from .__pkginfo__ import version as __version__
4849# WARNING: internal imports order matters !
4950
51+ # pylint: disable=redefined-builtin, wildcard-import
52+
5053# make all exception classes accessible from astroid package
5154from astroid .exceptions import *
5255
5861
5962# more stuff available
6063from astroid import raw_building
61- from astroid .bases import Instance , BoundMethod , UnboundMethod
64+ from astroid .bases import BaseInstance , Instance , BoundMethod , UnboundMethod
6265from astroid .node_classes import are_exclusive , unpack_infer
6366from astroid .scoped_nodes import builtin_lookup
64- from astroid .builder import parse
65- from astroid .util import YES
67+ from astroid .builder import parse , extract_node
68+ from astroid .util import Uninferable , YES
6669
67- # make a manager instance (borg) as well as Project and Package classes
68- # accessible from astroid package
70+ # make a manager instance (borg) accessible from astroid package
6971from astroid .manager import AstroidManager
7072MANAGER = AstroidManager ()
7173del AstroidManager
7274
7375# transform utilities (filters and decorator)
7476
7577class AsStringRegexpPredicate (object ):
76- """Class to be used as predicate that may be given to `register_transform`
78+ """ClassDef to be used as predicate that may be given to `register_transform`
7779
7880 First argument is a regular expression that will be searched against the `as_string`
7981 representation of the node onto which it's applied.
@@ -92,6 +94,7 @@ def __init__(self, regexp, expression=None):
9294 def __call__ (self , node ):
9395 if self .expression is not None :
9496 node = attrgetter (self .expression )(node )
97+ # pylint: disable=no-member; github.com/pycqa/astroid/126
9598 return self .regexp .search (node .as_string ())
9699
97100def inference_tip (infer_function ):
@@ -114,8 +117,8 @@ def transform(node, infer_function=infer_function):
114117def register_module_extender (manager , module_name , get_extension_mod ):
115118 def transform (node ):
116119 extension_module = get_extension_mod ()
117- for name , objs in extension_module ._locals .items ():
118- node ._locals [name ] = objs
120+ for name , objs in extension_module .locals .items ():
121+ node .locals [name ] = objs
119122 for obj in objs :
120123 if obj .parent is extension_module :
121124 obj .parent = node
@@ -124,13 +127,11 @@ def transform(node):
124127
125128
126129# load brain plugins
127- from os import listdir
128- from os .path import join , dirname
129- BRAIN_MODULES_DIR = join (dirname (__file__ ), 'brain' )
130+ BRAIN_MODULES_DIR = os .path .join (os .path .dirname (__file__ ), 'brain' )
130131if BRAIN_MODULES_DIR not in sys .path :
131132 # add it to the end of the list so user path take precedence
132133 sys .path .append (BRAIN_MODULES_DIR )
133134# load modules in this directory
134- for module in listdir (BRAIN_MODULES_DIR ):
135+ for module in os . listdir (BRAIN_MODULES_DIR ):
135136 if module .endswith ('.py' ):
136137 __import__ (module [:- 3 ])
0 commit comments