B
    S\                 @   sl  d Z ddlZddlZddlZddlZddlZeddZejZej	Z	ej
Z
[ddlmZ ddlT ddlT ddlmZ dd	lmZ dd
lmZmZmZmZ ddlmZmZ ddlmZ ddlmZmZ ddl m!Z! ddl"m#Z# e# Z$[#ej%i fddZ&dddZ'dd Z(ej)*ej)+e,dZ-e-ej)kr6ej).e- x0e/e-D ]"Z0e01drBe2e0dd  qBW dS )a  Python Abstract Syntax Tree New Generation

The aim of this module is to provide a common base representation of
python source code for projects such as pychecker, pyreverse,
pylint... Well, actually the development of this library is essentially
governed by pylint's needs.

It extends class defined in the python's _ast module with some
additional methods and attributes. Instance attributes are added by a
builder object, which can either generate extended ast (let's call
them astroid ;) by visiting an existent ast tree or by inspecting living
object. Methods are added by monkey patching ast classes.

Main modules are:

* nodes and scoped_nodes for more information about methods and
  attributes added to different node classes

* the manager contains a high level object to get astroid trees from
  source files and living objects. It maintains a cache of previously
  constructed tree for quick access

* builder contains the class responsible to build astroid trees
    NZContextzLoad Store Del   )version)*)	inference)raw_building)BaseInstanceInstanceBoundMethodUnboundMethod)are_exclusiveunpack_infer)builtin_lookup)parseextract_node)Uninferable)AstroidManagerc       	      C   sZ   |d }yt || |f S  tk
rT   | ||}t|\}}t||| |f< |S X dS )z'Cache decorator used for inference tipsr   N)iterKeyError	itertoolsteelist)	funcinstanceargskwargs_cachenoderesultZoriginalcopy r   /lib/python3.7/site-packages/astroid/__init__.py_inference_tip_cachedV   s    
r!   Fc                s   | f fdd	}|S )a  Given an instance specific inference function, return a function to be
    given to MANAGER.register_transform to set this inference function.

    :param bool raise_on_overwrite: Raise an `InferenceOverwriteError`
        if the inference tip will overwrite another. Used for debugging

    Typical usage

    .. sourcecode:: python

       MANAGER.register_transform(Call, inference_tip(infer_named_tuple),
                                  predicate)

    .. Note::

        Using an inference tip will override
        any previously set inference tip for the given
        node. Use a predicate in the transform to prevent
        excess overwrites.
    c                s<    r.| j d k	r.| j |k	r.tdj|| j | dt|| _ | S )NzbInference already set to {existing_inference}. Trying to overwrite with {new_inference} for {node})Zexisting_inferenceZnew_inferencer   )Z_explicit_inferenceZInferenceOverwriteErrorformatr!   )r   infer_function)raise_on_overwriter   r    	transform}   s    



z inference_tip.<locals>.transformr   )r#   r$   r%   r   )r$   r    inference_tipg   s    r&   c                s&    fdd}|  t|fdd d S )Nc                sJ     }x>|j  D ]0\}}|| j |< x|D ]}|j|kr*| |_q*W qW d S )N)localsitemsparent)r   Zextension_modulenameZobjsobj)get_extension_modr   r    r%      s    


z+register_module_extender.<locals>.transformc                s
   | j  kS )N)r*   )n)module_namer   r    <lambda>   s    z*register_module_extender.<locals>.<lambda>)Zregister_transformZModule)Zmanagerr.   r,   r%   r   )r,   r.   r    register_module_extender   s    r0   Zbrainz.py)F)3__doc__enumr   ossysZwraptEnumZ_ContextZLoadZStoreZDelZ__pkginfo__r   __version__Zastroid.exceptionsZastroid.nodesZastroidr   r   Zastroid.basesr   r   r	   r
   Zastroid.node_classesr   r   Zastroid.scoped_nodesr   Zastroid.builderr   r   Zastroid.utilr   Zastroid.managerr   ZMANAGERZ	decoratorr!   r&   r0   pathjoindirname__file__ZBRAIN_MODULES_DIRappendlistdirmoduleendswith
__import__r   r   r   r    <module>$   sB   
+