Hacked By AnonymousFox

Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/inspect.cpython-35.pyc



��Yf��@sdZddfZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZddlmZmZe�Zx+ejj�D]\ZZeede<qWdd	>Zd
d�Zdd
�Z dd�Z!dd�Z"dd�Z#e$ed�r�dd�Z%ndd�Z%e$ed�r�dd�Z&ndd�Z&dd�Z'dd�Z(d d!�Z)d"d#�Z*d$d%�Z+d&d'�Z,d(d)�Z-d*d+�Z.d,d-�Z/d.d/�Z0d0d1�Z1d2d3�Z2dd4d5�Z3ed6d7�Z4d8d9�Z5d:d;�Z6d<dd=d>�Z7d?d@�Z8dAdB�Z9dCdD�Z:dEdF�Z;dGdH�Z<dIdJ�Z=edKdL�Z>dMdN�Z?dOdP�Z@dQdR�ZAddSdT�ZBiZCiZDddUdV�ZEdWdX�ZFdYdZ�ZGGd[d\�d\eH�ZIGd]d^�d^�ZJd_d`�ZKdadb�ZLdcdd�ZMdedf�ZNdgdhdi�ZOedjdk�ZPdldm�ZQdndo�ZRedpdq�ZSdrds�ZTedtdu�ZUdvdw�ZVedxdy�ZWdzd{�ZXdd|d}�ZYd~d�ZZdddfiie[d�d��d�d��d�d��d�d��eYd�d��Z\e[d�d��d�d��d�d��d�d��Z]d�d��Z^d�d��Z_d�d��Z`ed�d��Zad�d��Zbed�d��Zcdd�d��Zdd�d��Zeed�d�fecjf�Zgdd�d��Zhdd�d��Zid�d��Zjdd�d��Zkdd�d��Zlem�Znd�d��Zod�d��Zpd�d��Zqd�d��Zrd�d��Zsend�d��Ztd�Zud�Zvd�Zwd�Zxd�d��Zyd�d��Zzd�Z{d�Z|d�Z}d�Z~d�d��Zd�d��Z�e�e�j��Z�e�e�j��Z�e�e�j�d��Z�e�e�e�ej�fZ�d�d��Z�fd�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d��Z�d�d�d��Z�d�d�d��Z�d�d��Z�d�d�d�d�d�d��Z�Gd�d��d��Z�Gd�d��d��Z�Gd�d��d�ej��Z�e�j�Z�e�j�Z�e�j�Z�e�j�Z�e�j�Z�Gd�d��d��Z�Gd�d��d��Z�Gd�d��d��Z�d�d�d�d��Z�d�d��Z�e�d�kr�e��dS)�a%Get useful information from live Python objects.

This module encapsulates the interface provided by the internal special
attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion.
It also provides some help for examining source code and class layout.

Here are some of the useful functions provided by this module:

    ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),
        isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),
        isroutine() - check object types
    getmembers() - get members of an object that satisfy a given condition

    getfile(), getsourcefile(), getsource() - find an object's source code
    getdoc(), getcomments() - get documentation on an object
    getmodule() - determine the module that an object came from
    getclasstree() - arrange classes so as to represent their hierarchy

    getargspec(), getargvalues(), getcallargs() - get info about function arguments
    getfullargspec() - same, with support for Python 3 features
    formatargspec(), formatargvalues() - format an argument spec
    getouterframes(), getinnerframes() - get info about frames
    currentframe() - get the current stack frame
    stack(), trace() - get info about frames on the stack or in a traceback

    signature() - get a Signature object for the callable
zKa-Ping Yee <ping@lfw.org>z'Yury Selivanov <yselivanov@sprymix.com>�N)�
attrgetter)�
namedtuple�OrderedDictZCO_��cCst|tj�S)z�Return true if the object is a module.

    Module objects provide these attributes:
        __cached__      pathname to byte compiled file
        __doc__         documentation string
        __file__        filename (missing for built-in modules))�
isinstance�types�
ModuleType)�object�r�,/opt/alt/python35/lib64/python3.5/inspect.py�ismodule?sr
cCs
t|t�S)z�Return true if the object is a class.

    Class objects provide these attributes:
        __doc__         documentation string
        __module__      name of module in which this class was defined)r�type)r
rrr�isclassHsrcCst|tj�S)a_Return true if the object is an instance method.

    Instance method objects provide these attributes:
        __doc__         documentation string
        __name__        name with which this method was defined
        __func__        function object containing implementation of method
        __self__        instance to which this method is bound)rr�
MethodType)r
rrr�ismethodPsrcCsQt|�s$t|�s$t|�r(dSt|�}t|d�oPt|d�S)a�Return true if the object is a method descriptor.

    But not if ismethod() or isclass() or isfunction() are true.

    This is new in Python 2.2, and, for example, is true of int.__add__.
    An object passing this test has a __get__ attribute but not a __set__
    attribute, but beyond that the set of attributes varies.  __name__ is
    usually sensible, and __doc__ often is.

    Methods implemented via descriptors that also pass one of the other
    tests return false from the ismethoddescriptor() test, simply because
    the other tests promise more -- you can, e.g., count on having the
    __func__ attribute (etc) when an object passes ismethod().F�__get__�__set__)rr�
isfunctionr�hasattr)r
�tprrr�ismethoddescriptorZs$rcCsPt|�s$t|�s$t|�r(dSt|�}t|d�oOt|d�S)a�Return true if the object is a data descriptor.

    Data descriptors have both a __get__ and a __set__ attribute.  Examples are
    properties (defined in Python) and getsets and members (defined in C).
    Typically, data descriptors will also have __name__ and __doc__ attributes
    (properties, getsets, and members have both of these attributes), but this
    is not guaranteed.Frr)rrrrr)r
rrrr�isdatadescriptorns$r�MemberDescriptorTypecCst|tj�S)z�Return true if the object is a member descriptor.

        Member descriptors are specialized descriptors defined in extension
        modules.)rrr)r
rrr�ismemberdescriptor~srcCsdS)z�Return true if the object is a member descriptor.

        Member descriptors are specialized descriptors defined in extension
        modules.Fr)r
rrrr�s�GetSetDescriptorTypecCst|tj�S)z�Return true if the object is a getset descriptor.

        getset descriptors are specialized descriptors defined in extension
        modules.)rrr)r
rrr�isgetsetdescriptor�srcCsdS)z�Return true if the object is a getset descriptor.

        getset descriptors are specialized descriptors defined in extension
        modules.Fr)r
rrrr�scCst|tj�S)a(Return true if the object is a user-defined function.

    Function objects provide these attributes:
        __doc__         documentation string
        __name__        name with which this function was defined
        __code__        code object containing compiled function bytecode
        __defaults__    tuple of any default values for arguments
        __globals__     global namespace in which this function was defined
        __annotations__ dict of parameter annotations
        __kwdefaults__  dict of keyword only parameters with defaults)rr�FunctionType)r
rrrr�srcCs,tt|�st|�o(|jjt@�S)z�Return true if the object is a user-defined generator function.

    Generator function objects provide the same attributes as functions.
    See help(isfunction) for a list of attributes.)�boolrr�__code__�co_flagsZCO_GENERATOR)r
rrr�isgeneratorfunction�sr!cCs,tt|�st|�o(|jjt@�S)z�Return true if the object is a coroutine function.

    Coroutine functions are defined with "async def" syntax,
    or generators decorated with "types.coroutine".
    )rrrrr ZCO_COROUTINE)r
rrr�iscoroutinefunction�sr"cCst|tj�S)aReturn true if the object is a generator.

    Generator objects provide these attributes:
        __iter__        defined to support iteration over container
        close           raises a new GeneratorExit exception inside the
                        generator to terminate the iteration
        gi_code         code object
        gi_frame        frame object or possibly None once the generator has
                        been exhausted
        gi_running      set to 1 when generator is executing, 0 otherwise
        next            return the next item from the container
        send            resumes the generator and "sends" a value that becomes
                        the result of the current yield-expression
        throw           used to raise an exception inside the generator)rr�
GeneratorType)r
rrr�isgenerator�sr$cCst|tj�S)z)Return true if the object is a coroutine.)rr�
CoroutineType)r
rrr�iscoroutine�sr&cCsMt|tj�pLt|tj�r:t|jjt@�pLt|tj	j
�S)z?Return true if object can be passed to an ``await`` expression.)rrr%r#r�gi_coder ZCO_ITERABLE_COROUTINE�collections�abc�	Awaitable)r
rrr�isawaitable�sr+cCst|tj�S)abReturn true if the object is a traceback.

    Traceback objects provide these attributes:
        tb_frame        frame object at this level
        tb_lasti        index of last attempted instruction in bytecode
        tb_lineno       current line number in Python source code
        tb_next         next inner traceback object (called by this level))rr�
TracebackType)r
rrr�istraceback�sr-cCst|tj�S)a`Return true if the object is a frame object.

    Frame objects provide these attributes:
        f_back          next outer frame object (this frame's caller)
        f_builtins      built-in namespace seen by this frame
        f_code          code object being executed in this frame
        f_globals       global namespace seen by this frame
        f_lasti         index of last attempted instruction in bytecode
        f_lineno        current line number in Python source code
        f_locals        local namespace seen by this frame
        f_trace         tracing function for this frame, or None)rr�	FrameType)r
rrr�isframe�sr/cCst|tj�S)a/Return true if the object is a code object.

    Code objects provide these attributes:
        co_argcount         number of arguments (not including *, ** args
                            or keyword only arguments)
        co_code             string of raw compiled bytecode
        co_cellvars         tuple of names of cell variables
        co_consts           tuple of constants used in the bytecode
        co_filename         name of file in which this code object was created
        co_firstlineno      number of first line in Python source code
        co_flags            bitmap: 1=optimized | 2=newlocals | 4=*arg | 8=**arg
                            | 16=nested | 32=generator | 64=nofree | 128=coroutine
                            | 256=iterable_coroutine
        co_freevars         tuple of names of free variables
        co_kwonlyargcount   number of keyword only arguments (not including ** arg)
        co_lnotab           encoded mapping of line numbers to bytecode indices
        co_name             name with which this code object was defined
        co_names            tuple of names of local variables
        co_nlocals          number of local variables
        co_stacksize        virtual machine stack space required
        co_varnames         tuple of names of arguments and local variables)rr�CodeType)r
rrr�iscode�sr1cCst|tj�S)a,Return true if the object is a built-in function or method.

    Built-in functions and methods provide these attributes:
        __doc__         documentation string
        __name__        original name of this function or method
        __self__        instance to which a method is bound, or None)rr�BuiltinFunctionType)r
rrr�	isbuiltinsr3cCs.t|�p-t|�p-t|�p-t|�S)z<Return true if the object is any kind of function or method.)r3rrr)r
rrr�	isroutinesr4cCs tt|t�o|jt@�S)z:Return true if the object is an abstract base class (ABC).)rrr�	__flags__�TPFLAGS_IS_ABSTRACT)r
rrr�
isabstractsr7cCsxt|�r"|ft|�}nf}g}t�}t|�}yWxP|jD]E}x<|jj�D]+\}}t|tj	�rf|j
|�qfWqPWWntk
r�YnXx�|D]�}	y%t||	�}
|	|kr�t�WnCtk
r&x.|D]#}|	|jkr�|j|	}
Pq�Ww�YnX|s:||
�rM|j
|	|
f�|j
|	�q�W|jddd��|S)z�Return all members of an object as (name, value) pairs sorted by name.
    Optionally, only return members that satisfy a given predicate.�keycSs|dS)Nrr)Zpairrrr�<lambda>Eszgetmembers.<locals>.<lambda>)r�getmro�set�dir�	__bases__�__dict__�itemsrr�DynamicClassAttribute�append�AttributeError�getattr�add�sort)r
Z	predicate�mro�results�	processed�names�base�k�vr8�valuerrr�
getmemberss:	





rN�	Attributezname kind defining_class objectcCst|�}tt|��}tdd�|D��}|f|}||}t|�}xM|D]E}x<|jj�D]+\}}t|tj�rw|j	|�qwWqaWg}	t
�}
xF|D]>}d}d}
d}||
kr�y+|dkr�td��t||�}
Wn%tk
r6}zWYdd}~Xn�Xt|
d|�}||kr�d}d}x2|D]*}t||d�}||
krh|}qhWxN|D]F}y|j
||�}Wntk
r�w�YnX||
kr�|}q�W|dk	r�|}x=|D]5}||jkr|j|}||kr4|}PqW|dkrHq�|
dk	rZ|
n|}t|t�r~d}|}nWt|t�r�d}|}n9t|t�r�d	}|}nt|�r�d
}nd}|	j	t||||��|
j|�q�W|	S)aNReturn list of attribute-descriptor tuples.

    For each name in dir(cls), the return list contains a 4-tuple
    with these elements:

        0. The name (a string).

        1. The kind of attribute this is, one of these strings:
               'class method'    created via classmethod()
               'static method'   created via staticmethod()
               'property'        created via property()
               'method'          any other flavor of method or descriptor
               'data'            not a method

        2. The class which defined this attribute (a class).

        3. The object as obtained by calling getattr; if this fails, or if the
           resulting object does not live anywhere in the class' mro (including
           metaclasses) then the object is looked up in the defining class's
           dict (found by walking the mro).

    If one of the items in dir(cls) is stored in the metaclass it will now
    be discovered and not have None be listed as the class in which it was
    defined.  Any items whose home class cannot be discovered are skipped.
    cSs(g|]}|ttfkr|�qSr)rr
)�.0�clsrrr�
<listcomp>gs	z(classify_class_attrs.<locals>.<listcomp>Nr>z)__dict__ is special, don't want the proxy�__objclass__z
static methodzclass method�property�method�data)r:r�tupler<r>r?rrr@rAr;�	ExceptionrC�__getattr__rB�staticmethod�classmethodrTr4rOrD)rQrFZmetamroZclass_basesZ	all_basesrIrJrKrL�resultrH�nameZhomeclsZget_objZdict_obj�excZlast_clsZsrch_clsZsrch_obj�obj�kindrrr�classify_class_attrsJs�


	







				racCs|jS)zHReturn tuple of base classes (including cls) in method resolution order.)�__mro__)rQrrrr:�sr:�stopcs��dkrdd�}n�fdd�}|}t|�h}xS||�r�|j}t|�}||kr�tdj|���|j|�qEW|S)anGet the object wrapped by *func*.

   Follows the chain of :attr:`__wrapped__` attributes returning the last
   object in the chain.

   *stop* is an optional callback accepting an object in the wrapper chain
   as its sole argument that allows the unwrapping to be terminated early if
   the callback returns a true value. If the callback never returns a true
   value, the last object in the chain is returned as usual. For example,
   :func:`signature` uses this to stop unwrapping if any object in the
   chain has a ``__signature__`` attribute defined.

   :exc:`ValueError` is raised if a cycle is encountered.

    NcSs
t|d�S)N�__wrapped__)r)�frrr�_is_wrapper�szunwrap.<locals>._is_wrappercst|d�o�|�S)Nrd)r)re)rcrrrf�sz!wrapper loop when unwrapping {!r})�idrd�
ValueError�formatrD)�funcrcrfre�memoZid_funcr)rcr�unwrap�s	rlcCs&|j�}t|�t|j��S)zBReturn the indent size, in spaces, at the start of a line of text.)�
expandtabs�len�lstrip)�lineZexplinerrr�
indentsize�srqcCsotjj|j�}|dkr%dSx3|jjd�dd�D]}t||�}qBWt|�skdS|S)N�.r���)�sys�modules�get�
__module__�__qualname__�splitrCr)rjrQr]rrr�
_findclass�s#rzcCsbt|�rexR|jD]G}|tk	ry
|j}Wntk
rLwYnX|dk	r|SqWdSt|�r�|jj}|j}t|�r�t	t	||d�d�|jkr�|}q|j
}nAt|�r|j}t|�}|dks
t	||�|k	rdSn�t
|�rm|j}|j}t|�ra|jd||jkra|}q|j
}n�t|t�r�|j}|j}t|�}|dks�t	||�|k	rdSnJt|�s�t|�r|j}|j}t	||�|k	rdSndSxO|jD]D}yt	||�j}Wntk
rIwYnX|dk	r|SqWdS)N�__func__rr)rrbr
�__doc__rBrr{�__name__�__self__rC�	__class__rrzr3rxrrT�fgetrrrS)r_rJ�docr]�selfrQrjrrr�_finddoc�sb

	$		!					!		
r�cCs~y
|j}Wntk
r%dSYnX|dkrayt|�}Wnttfk
r`dSYnXt|t�stdSt|�S)z�Get the documentation string for an object.

    All tabs are expanded to spaces.  To clean up docstrings that are
    indented to line up with blocks of code, any whitespace than can be
    uniformly removed from the second line onwards is removed.N)r|rBr��	TypeErrorr�str�cleandoc)r
r�rrr�getdoc/s

		r�cCsFy|j�jd�}Wntk
r1dSYnXtj}xO|dd�D]=}t|j��}|rLt|�|}t||�}qLW|r�|dj�|d<|tjkr�x5tdt|��D]}|||d�||<q�Wx|r|dr|j	�q�Wx"|r4|dr4|j	d�qWdj
|�SdS)z�Clean up indentation from docstrings.

    Any whitespace that can be uniformly removed from the second line
    onwards is removed.�
Nrrrs)rmry�UnicodeErrorrt�maxsizernro�min�range�pop�join)r��linesZmarginrpZcontent�indent�irrrr�Bs(
		r�cCst|�r7t|d�r"|jStdj|���t|�r�t|d�r}tjj|j	�}t|d�r}|jStdj|���t
|�r�|j}t|�r�|j
}t|�r�|j}t|�r�|j}t|�r�|jStdj|���dS)z@Work out which source or compiled file an object was defined in.�__file__z{!r} is a built-in modulerwz{!r} is a built-in classzO{!r} is not a module, class, method, function, traceback, frame, or code objectN)r
rr�r�rirrtrurvrwrr{rrr-�tb_framer/�f_coder1�co_filename)r
rrr�getfile_s,					r��
ModuleInfozname suffix mode module_typec
Cs�tjdtd�tj��!tjdt�ddl}WdQRXtjj	|�}dd�|j
�D�}|j�xM|D]E\}}}}||d�|krt|d|�|||�SqWdS)zDGet the module name, suffix, mode, and module type for a given file.z%inspect.getmoduleinfo() is deprecated��ignorerNcSs2g|](\}}}t|�|||f�qSr)rn)rP�suffix�mode�mtyperrrrR�s	z!getmoduleinfo.<locals>.<listcomp>)
�warnings�warn�DeprecationWarning�catch_warnings�simplefilter�PendingDeprecationWarning�imp�os�path�basenameZget_suffixesrEr�)r�r��filename�suffixes�neglenr�r�r�rrr�
getmoduleinfozs
	
r�cCsptjj|�}dd�tjj�D�}|j�x1|D])\}}|j|�r?|d|�Sq?WdS)z1Return the module name for a given file, or None.cSs#g|]}t|�|f�qSr)rn)rPr�rrrrR�s	z!getmodulename.<locals>.<listcomp>N)r�r�r��	importlib�	machinery�all_suffixesrE�endswith)r�Zfnamer�r�r�rrr�
getmodulename�s	
r�cs�t|��tjjdd�}|tjjdd�7}t�fdd�|D��r�tjj��dtjj	d�n)t�fdd�tjj
D��r�dStjj��r��Stt
|��dd�dk	r��S�tjkr��SdS)z�Return the filename that can be used to locate an object's source.
    Return None if no way can be identified to get the source.
    Nc3s|]}�j|�VqdS)N)r�)rP�s)r�rr�	<genexpr>�sz getsourcefile.<locals>.<genexpr>rc3s|]}�j|�VqdS)N)r�)rPr�)r�rrr��s�
__loader__)r�r�r��DEBUG_BYTECODE_SUFFIXES�OPTIMIZED_BYTECODE_SUFFIXES�anyr�r��splitext�SOURCE_SUFFIXES�EXTENSION_SUFFIXES�existsrC�	getmodule�	linecache�cache)r
Zall_bytecode_suffixesr)r�r�
getsourcefile�s!r�cCs@|dkr$t|�p!t|�}tjjtjj|��S)z�Return an absolute path to the source or compiled file for an object.

    The idea is for each object to have a unique origin, so this routine
    normalizes the result as much as possible.N)r�r�r�r��normcase�abspath)r
�	_filenamerrr�
getabsfile�sr�c

Cs�t|�r|St|d�r2tjj|j�S|dk	r^|tkr^tjjt|�Syt||�}Wntk
r�dSYnX|tkr�tjjt|�Sx�t	tjj
��D]�\}}t|�r�t|d�r�|j}|tj|d�krq�|t|<t|�}|j
t|<ttjj|�<q�W|tkrftjjt|�Stjd}t|d�s�dSt||j
�r�t||j
�}||kr�|Stjd}t||j
�r�t||j
�}	|	|kr�|SdS)zAReturn the module an object was defined in, or None if not found.rwNr��__main__r}�builtins)r
rrtrurvrw�
modulesbyfiler�r��listr?r��_filesbymodnamer}r�r��realpathrC)
r
r��file�modname�modulere�mainZ
mainobjectZbuiltinZ
builtinobjectrrrr��sD
	"	
%

r�c
Csnt|�}|r"tj|�n6t|�}|jd�oI|jd�sXtd��t||�}|r�tj||j	�}ntj|�}|s�td��t
|�r�|dfSt|�r�|j}t
jd|d�}g}xmtt|��D]Y}|j||�}|r||ddkr>||fS|j|jd	�|f�qW|r�|j�||dd	fStd
��t|�r�|j}t|�r�|j}t|�r�|j}t|�r�|j}t|�r^t|d�std��|jd	}	t
jd
�}x.|	dkrS|j||	�rFP|	d	}	q&W||	fStd��dS)abReturn the entire source file and starting line number for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a list of all the lines
    in the file and the line number indexes a line in that list.  An OSError
    is raised if the source code cannot be retrieved.�<�>zsource code not availablezcould not get source coderz^(\s*)class\s*z\b�crzcould not find class definition�co_firstlinenoz"could not find function definitionz>^(\s*def\s)|(\s*async\s+def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)zcould not find code objectN) r�r��
checkcacher��
startswithr��OSErrorr��getlinesr>r
rr}�re�compiler�rn�matchrA�grouprErr{rrr-r�r/r�r1rr�)
r
r�r�r�r]ZpatZ
candidatesr�r��lnumrrr�
findsource�s^
	
 
				

r�cCs�yt|�\}}Wnttfk
r4dSYnXt|�rBd}|rm|ddd�dkrmd}x6|t|�kr�||j�dkr�|d}qpW|t|�kr�||dd�dkr�g}|}xQ|t|�kr1||dd�dkr1|j||j��|d}q�Wdj|�Sn�|dkr�t	||�}|d}|dkr�||j
�dd�dkr�t	||�|kr�||j�j
�g}|dkrb|d}||j�j
�}xp|dd�dkrat	||�|kra|g|dd�<|d}|dkrHP||j�j
�}q�Wx0|r�|dj�dkr�g|dd�<qeWx0|r�|d	j�dkr�g|d
d�<q�Wdj|�SdS)zwGet lines of comments immediately preceding an object's source code.

    Returns None when source can't be found.
    Nrr�z#!r��#)r�r�rsrs)r�r�r�r
rn�striprArmr�rqro)r
r�r��startZcomments�endr�Zcommentrrr�getcomments.sJ	 +,/
,
/
r�c@seZdZdS)�
EndOfBlockN)r}rwrxrrrrr�[sr�c@s.eZdZdZdd�Zdd�ZdS)�BlockFinderz@Provide a tokeneater() method to detect the end of a code block.cCsCd|_d|_d|_d|_d|_d|_d|_dS)NrFr)r��islambda�started�passline�indecorator�decoratorhasargs�last)r�rrr�__init___s						zBlockFinder.__init__cCs�|jrb|jrb|dkr,d|_n*|dkrV|dkrMd|_d|_d|_n9|dkr�|jr�d|_n|dkr�|jr�d|_d|_n�|tjkrd|_|d	|_|jr�t�|jr�|jr�d|_n�|jrn�|tj	kr7|j
d
|_
d|_nd|tjkrn|j
d
|_
|j
d	kr�t�n-|j
d	kr�|tjtj
fkr�t�dS)N�@T�def�class�lambda�(�)Frr)r�r�r�)r�r�r�r�r��tokenize�NEWLINEr�r��INDENTr��DEDENT�COMMENT�NL)r�r�tokenZsrowcolZerowcolrprrr�
tokeneaterhsB						
			'zBlockFinder.tokeneaterN)r}rwrxr|r�r�rrrrr�]s	r�cCsot�}y:tjt|�j�}x|D]}|j|�q+WWnttfk
r]YnX|d|j�S)z@Extract the block of code at the top of the given list of lines.N)	r�r��generate_tokens�iter�__next__r�r��IndentationErrorr�)r�Zblockfinder�tokensZ_tokenrrr�getblock�s	
r�cCsVt|�}t|�\}}t|�r4|dfSt||d��|dfSdS)a�Return a list of source lines and starting line number for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a list of the lines
    corresponding to the object and the line number indicates where in the
    original source file the first line of code was found.  An OSError is
    raised if the source code cannot be retrieved.rNr)rlr�r
r�)r
r�r�rrr�getsourcelines�s

r�cCst|�\}}dj|�S)aReturn the text of the source code for an object.

    The argument may be a module, class, method, function, traceback, frame,
    or code object.  The source code is returned as a single string.  An
    OSError is raised if the source code cannot be retrieved.r�)r�r�)r
r�r�rrr�	getsource�sr�cCssg}|jdtdd��xM|D]E}|j||jf�||kr&|jt||||��q&W|S)z-Recursive helper function for getclasstree().r8rwr})rErrAr=�walktree)�classes�children�parentrGr�rrrr��s
!r�FcCs�i}g}x�|D]�}|jr�xw|jD]P}||krHg||<|||kri||j|�|r,||kr,Pq,Wq||kr|j|�qWx'|D]}||kr�|j|�q�Wt||d�S)a�Arrange the given list of classes into a hierarchy of nested lists.

    Where a nested list appears, it contains classes derived from the class
    whose entry immediately precedes the list.  Each entry is a 2-tuple
    containing a class and a tuple of its base classes.  If the 'unique'
    argument is true, exactly one entry appears in the returned structure
    for each class in the given list.  Otherwise, classes using multiple
    inheritance and their descendants will appear multiple times.N)r=rAr�)rZuniquer�rootsr�rrrr�getclasstree�s"	
	

r�	Argumentszargs, varargs, varkwcCs,t|�\}}}}t||||�S)aGet information about the arguments accepted by a code object.

    Three things are returned: (args, varargs, varkw), where
    'args' is the list of argument names. Keyword-only arguments are
    appended. 'varargs' and 'varkw' are the names of the * and **
    arguments or None.)�_getfullargsr)�co�args�varargs�
kwonlyargs�varkwrrr�getargs�src	Cs�t|�s!tdj|���|j}|j}|j}t|d|��}t||||��}d}||7}d}|jt@r�|j|}|d}d}|jt	@r�|j|}||||fS)aGet information about the arguments accepted by a code object.

    Four things are returned: (args, varargs, kwonlyargs, varkw), where
    'args' and 'kwonlyargs' are lists of argument names, and 'varargs'
    and 'varkw' are the names of the * and ** arguments or None.z{!r} is not a code objectNrr)
r1r�ri�co_argcount�co_varnames�co_kwonlyargcountr�r �
CO_VARARGS�CO_VARKEYWORDS)	r�nargsrIZnkwargsrr
�stepr	rrrrr�s"			





r�ArgSpeczargs varargs keywords defaultscCsbtjdtdd�t|�\}}}}}}}|sC|rOtd��t||||�S)aHGet the names and default values of a function's arguments.

    A tuple of four things is returned: (args, varargs, keywords, defaults).
    'args' is a list of the argument names, including keyword-only argument names.
    'varargs' and 'keywords' are the names of the * and ** arguments or None.
    'defaults' is an n-tuple of the default values of the last n arguments.

    Use the getfullargspec() API for Python 3 code, as annotations
    and keyword arguments are supported. getargspec() will raise ValueError
    if the func has either annotations or keyword arguments.
    zCinspect.getargspec() is deprecated, use inspect.signature() instead�
stacklevelr�zcFunction has keyword-only arguments or annotations, use getfullargspec() API which can support them)r�r�r��getfullargspecrhr)rjrr	r�defaultsr
�kwonlydefaults�annrrr�
getargspecs	!r�FullArgSpeczGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc
Cs�y"t|dddddt�}Wn4tk
rX}ztd�|�WYdd}~XnXg}d}d}g}f}i}f}i}	|j|jk	r�|j|d<x|jj�D]�}
|
j}|
j	}|t
kr�|j|�n�|tkr*|j|�|
j
|
jk	r�||
j
f7}nb|tkr?|}nM|tkrz|j|�|
j
|
jk	r�|
j
|	|<n|tkr�|}|
j|
jk	r�|
j||<q�W|	s�d}	|s�d}t||||||	|�S)a�Get the names and default values of a callable object's arguments.

    A tuple of seven things is returned:
    (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults annotations).
    'args' is a list of the argument names.
    'varargs' and 'varkw' are the names of the * and ** arguments or None.
    'defaults' is an n-tuple of the default values of the last n arguments.
    'kwonlyargs' is a list of keyword-only argument names.
    'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.
    'annotations' is a dictionary mapping argument names to annotations.

    The first four items in the tuple correspond to getargspec().

    This function is deprecated, use inspect.signature() instead.
    �follow_wrapper_chainsF�skip_bound_arg�sigclszunsupported callableN�return)�_signature_from_callable�	SignaturerXr��return_annotation�empty�
parameters�valuesr`r]�_POSITIONAL_ONLYrA�_POSITIONAL_OR_KEYWORD�default�_VAR_POSITIONAL�
_KEYWORD_ONLY�_VAR_KEYWORD�
annotationr)
rj�sig�exrr	rr
r�annotations�
kwdefaults�paramr`r]rrrr!sT	
"
		
	
r�ArgInfozargs varargs keywords localscCs.t|j�\}}}t||||j�S)a9Get information about arguments passed into a particular frame.

    A tuple of four things is returned: (args, varargs, varkw, locals).
    'args' is a list of the argument names.
    'varargs' and 'varkw' are the names of the * and ** arguments or None.
    'locals' is the locals dictionary of the given frame.)rr�r2�f_locals)�framerr	rrrr�getargvalues~sr5cCsut|dd�dkr.t|�jdd�St|t�rk|jd|fkrY|jS|jd|jSt|�S)NrwZtypingztyping.r�r�rr)rC�repr�replacerrrwrx)r,Zbase_modulerrr�formatannotation�sr8cs(t|dd���fdd�}|S)Nrwcs
t|��S)N)r8)r,)r�rr�_formatannotation�sz5formatannotationrelativeto.<locals>._formatannotation)rC)r
r9r)r�r�formatannotationrelativeto�sr:cCsd|S)N�*r)r]rrrr9�sr9cCsd|S)Nz**r)r]rrrr9�scCsdt|�S)N�=)r6)rMrrrr9�scCsd|S)Nz -> r)�textrrrr9�sc
s����fdd�}
g}|r:t|�t|�}x]t|�D]O\}}|
|�}|r�||kr�||
|||�}|j|�qGW|dk	r�|j||
|���n|r�|jd�|r+xM|D]E}|
|�}|r||kr||
||�7}|j|�q�W|dk	rP|j|	|
|���ddj|�d}d�kr�||��d��7}|S)	a�Format an argument spec from the values returned by getargspec
    or getfullargspec.

    The first seven arguments are (args, varargs, varkw, defaults,
    kwonlyargs, kwonlydefaults, annotations).  The other five arguments
    are the corresponding optional formatting functions that are called to
    turn names and values into strings.  The last argument is an optional
    function to format the sequence of arguments.cs4�|�}|�kr0|d��|�7}|S)Nz: r)�argr\)r/r8�	formatargrr�formatargandannotation�sz-formatargspec.<locals>.formatargandannotationNr;r�z, r�r)rn�	enumeraterAr�)rr	rrr
rr/r?�
formatvarargs�formatvarkw�formatvalueZ
formatreturnsr8r@�specsZfirstdefaultr�r>�specZ	kwonlyargr\r)r/r8r?r�
formatargspec�s2

rGcCsd|S)Nr;r)r]rrrr9�scCsd|S)Nz**r)r]rrrr9�scCsdt|�S)Nr<)r6)rMrrrr9�scCs�|||dd�}g}	x1tt|��D]}
|	j|||
��q.W|rv|	j||�|||��|r�|	j||�|||��ddj|	�dS)afFormat an argument spec from the 4 values returned by getargvalues.

    The first four arguments are (args, varargs, varkw, locals).  The
    next four arguments are the corresponding optional formatting functions
    that are called to turn names and values into strings.  The ninth
    argument is an optional function to format the sequence of arguments.cSs||�|||�S)Nr)r]�localsr?rDrrr�convert�sz formatargvalues.<locals>.convertr�z, r�)r�rnrAr�)rr	rrHr?rBrCrDrIrEr�rrr�formatargvalues�s!!rJcs��fdd�|D�}t|�}|dkr>|d}nW|dkr\dj|�}n9dj|dd��}|dd�=dj|�|}td	|||r�d
nd|dkr�dnd
|f��dS)Ncs(g|]}|�krt|��qSr)r6)rPr])r%rrrR�s	z&_missing_arguments.<locals>.<listcomp>rrr�z	{} and {}z, {} and {}z, z*%s() missing %i required %s argument%s: %s�
positionalzkeyword-onlyr�r����rL)rnrir�r�)�f_nameZargnames�posr%rI�missingr��tailr)r%r�_missing_arguments�s

rQc
	s.t|�|}t�fdd�|D��}|rQ|dk}	d|f}
nI|rvd}	d|t|�f}
n$t|�dk}	tt|��}
d}|r�d}||dkr�d	nd||dkr�d	ndf}td
||
|	r�d	nd|||dkr|rdndf��dS)
Ncs"g|]}|�kr|�qSrr)rPr>)r%rrrR�s	z_too_many.<locals>.<listcomp>rzat least %dTz
from %d to %dr�z7 positional argument%s (and %d keyword-only argument%s)r�z5%s() takes %s positional argument%s but %d%s %s givenZwasZwere)rnr�r�)
rMrZkwonlyr	ZdefcountZgivenr%ZatleastZkwonly_givenZpluralr-Z
kwonly_sig�msgr)r%r�	_too_many�s$rScOs�|d}|dd�}t|�}|\}}}}}	}
}|j}i}
t|�r{|jdk	r{|jf|}t|�}t|�}|r�t|�nd}t||�}x&t|�D]}|||
||<q�W|rt||d��|
|<t||	�}|r#i|
|<x|j	�D]q\}}||kru|sdt
d||f��||
||<q0||
kr�t
d||f��||
|<q0W||kr�|r�t|||	||||
�||kri|d||�}x-|D]%}||
kr�t||d|
�q�WxBt
|||d��D]&\}}||
kr?|||
|<q?Wd}xG|	D]?}||
krv|
r�||
kr�|
||
|<qv|d7}qvW|r�t||	d|
�|
S)z�Get the mapping of arguments to values.

    A dict is returned, with keys the function argument names (including the
    names of the * and ** arguments, if any), and values the respective bound
    values from 'positional' and 'named'.rrNz*%s() got an unexpected keyword argument %rz(%s() got multiple values for argument %rTF)rr}rr~rnr�r�rWr;r?r�rSrQrA)Zfunc_and_positionalZnamedrjrKrFrr	rrr
rrrMZ	arg2valueZnum_posZnum_argsZnum_defaults�nr�Zpossible_kwargs�kwrMZreqr>rO�kwargrrr�getcallargssd
	


'
rW�ClosureVarsz"nonlocals globals builtins unboundc	CsRt|�r|j}t|�s6tdj|���|j}|jdkrWi}n"dd�t|j|j�D�}|j	}|j
dtj�}t
|�r�|j}i}i}t�}x{|jD]p}|d	kr�q�y||||<Wq�tk
r:y||||<Wntk
r5|j|�YnXYq�Xq�Wt||||�S)
a
    Get the mapping of free variables to their current values.

    Returns a named tuple of dicts mapping the current nonlocal, global
    and builtin references as seen by the body of the function. A final
    set of unbound names that could not be resolved is also provided.
    z'{!r}' is not a Python functionNcSs"i|]\}}|j|�qSr)�
cell_contents)rP�varZcellrrr�
<dictcomp>Ws	z"getclosurevars.<locals>.<dictcomp>�__builtins__�None�True�False)r]r^r_)rr{rr�rir�__closure__�zip�co_freevars�__globals__rvr�r>r
r;�co_names�KeyErrorrDrX)	rj�codeZ
nonlocal_varsZ	global_nsZ
builtin_nsZglobal_varsZbuiltin_varsZ
unbound_namesr]rrr�getclosurevarsBs8								

	rg�	Tracebackz+filename lineno function code_context indexcCs#t|�r!|j}|j}n	|j}t|�sKtdj|���t|�p`t|�}|dkr�|d|d}yt	|�\}}Wnt
k
r�d}}YqXtdt|t
|�|��}||||�}|d|}n
d}}t|||jj||�S)a�Get information about a frame or traceback object.

    A tuple of five things is returned: the filename, the line number of
    the current line, the function name, a list of lines of context from
    the source code, and the index of the current line within that list.
    The optional second argument specifies the number of lines of context
    to return, which are centered around the current line.z'{!r} is not a frame or traceback objectrrr�N)r-�	tb_linenor��f_linenor/r�rir�r�r�r��maxr�rnrhr��co_name)r4�context�linenor�r�r�r��indexrrr�getframeinfoys$		
"
rpcCs|jS)zCGet the line number from a frame object, allowing for optimization.)rj)r4rrr�	getlineno�srq�	FrameInfor4cCsIg}x<|rD|ft||�}|jt|��|j}q	W|S)z�Get a list of records for a frame and all higher (calling) frames.

    Each record contains a frame object, filename, line number, function
    name, a list of lines of context, and index within the context.)rprArr�f_back)r4rm�	framelist�	frameinforrr�getouterframes�s	
rvcCsLg}x?|rG|jft||�}|jt|��|j}q	W|S)z�Get a list of records for a traceback's frame and all lower frames.

    Each record contains a frame object, filename, line number, function
    name, a list of lines of context, and index within the context.)r�rprArr�tb_next)�tbrmrtrurrr�getinnerframes�s	
rycCs ttd�rtjd�SdS)z?Return the frame of the caller or None if this is not possible.�	_getframerN)rrtrzrrrr�currentframe�sr{cCsttjd�|�S)z@Return a list of records for the stack above the caller's frame.r)rvrtrz)rmrrr�stack�sr|cCsttj�d|�S)zCReturn a list of records for the stack below the current exception.r�)ryrt�exc_info)rmrrr�trace�sr~cCstjdj|�S)Nrb)rr>r)�klassrrr�_static_getmro�sr�cCsDi}ytj|d�}Wntk
r0YnXtj||t�S)Nr>)r
�__getattribute__rB�dictrv�	_sentinel)r_�attrZ
instance_dictrrr�_check_instance�s
r�cCsWxPt|�D]B}tt|��tkr
y|j|SWq
tk
rNYq
Xq
WtS)N)r��_shadowed_dictrr�r>re)rr��entryrrr�_check_class�s
	r�cCs+yt|�Wntk
r&dSYnXdS)NFT)r�r�)r_rrr�_is_type�s

	r�cCs�tjd}xwt|�D]i}y|j|�d}Wntk
rKYqXt|�tjko||jdko||j|ks|SqWt	S)Nr>)
rr>r�rrerrr}rSr�)r�	dict_attrr�Z
class_dictrrrr��s

r�cCsit}t|�s]t|�}t|�}|tksKt|�tjkrct||�}n|}t||�}|tk	r�|tk	r�tt|�d�tk	r�tt|�d�tk	r�|S|tk	r�|S|tk	r�|S||krIxVtt|��D]B}tt|��tkry|j	|SWqt
k
rDYqXqW|tk	rY|St|��dS)a�Retrieve attributes without triggering dynamic lookup via the
       descriptor protocol,  __getattr__ or __getattribute__.

       Note: this function may not be able to retrieve all attributes
       that getattr can fetch (like dynamically created attributes)
       and may find attributes that getattr can't (like descriptors
       that raise AttributeError). It can also return descriptor objects
       instead of instance members in some cases. See the
       documentation for details.
    rrN)r�r�rr�rrr�r�r�r>rerB)r_r�r(Zinstance_resultrr�Zklass_resultr�rrr�getattr_static�s6
	r��GEN_CREATED�GEN_RUNNING�
GEN_SUSPENDED�
GEN_CLOSEDcCs:|jr
tS|jdkr tS|jjdkr6tStS)a#Get current state of a generator-iterator.

    Possible states are:
      GEN_CREATED: Waiting to start execution.
      GEN_RUNNING: Currently being executed by the interpreter.
      GEN_SUSPENDED: Currently suspended at a yield expression.
      GEN_CLOSED: Execution has completed.
    Nrrs)�
gi_runningr��gi_framer��f_lastir�r�)�	generatorrrr�getgeneratorstate(s		r�cCsQt|�s!tdj|���t|dd�}|dk	rI|jjSiSdS)z�
    Get the mapping of generator local variables to their current values.

    A dict is returned, with the keys the local variable names and values the
    bound values.z '{!r}' is not a Python generatorr�N)r$r�rirCr�r3)r�r4rrr�getgeneratorlocals:s
r��CORO_CREATED�CORO_RUNNING�CORO_SUSPENDED�CORO_CLOSEDcCs:|jr
tS|jdkr tS|jjdkr6tStS)a&Get current state of a coroutine object.

    Possible states are:
      CORO_CREATED: Waiting to start execution.
      CORO_RUNNING: Currently being executed by the interpreter.
      CORO_SUSPENDED: Currently suspended at an await expression.
      CORO_CLOSED: Execution has completed.
    Nrrs)�
cr_runningr��cr_framer�r�r�r�)�	coroutinerrr�getcoroutinestateRs		r�cCs-t|dd�}|dk	r%|jSiSdS)z�
    Get the mapping of coroutine local variables to their current values.

    A dict is returned, with the keys the local variable names and values the
    bound values.r�N)rCr3)r�r4rrr�getcoroutinelocalsdsr��
from_bytescCsCyt||�}Wntk
r+dSYnXt|t�s?|SdS)z�Private helper. Checks if ``cls`` has an attribute
    named ``method_name`` and returns it only if it is a
    pure python function.
    N)rCrBr�_NonUserDefinedCallables)rQZmethod_name�methrrr�"_signature_get_user_defined_method�s
	r�cCs3|j}t|j��}|jp'f}|jp6i}|rI||}y|j||�}WnCtk
r�}z#dj|�}	t|	�|�WYdd}~XnXd}
xo|j�D]a\}}y|j	|}
Wnt
k
r�Yn�X|jtkr	|j
|�q�|jtkrV||krCd}
|jd|
�||<n|j
|j�q�|jtkr{|jd|
�||<|
r�|jtk	s�t�|jtkr�||jdt�}|||<|j|�q�|jttfkr�|j|�q�|jtkr�|j
|j�q�W|jd|j��S)z�Private helper to calculate how 'wrapped_sig' signature will
    look like after applying a 'functools.partial' object (or alike)
    on it.
    z+partial object {!r} has incorrect argumentsNFTr(r`r$)r$rr?r�keywords�bind_partialr�rirh�	argumentsrer`r&r�r'r7r]r*�AssertionError�move_to_endr+r)r%)�wrapped_sig�partialZ
extra_argsZ
old_params�
new_paramsZpartial_argsZpartial_keywordsZbar.rRZtransform_to_kwonly�
param_namer1Z	arg_valueZ	new_paramrrr�_signature_get_partial�sN	
"



r�cCs�t|jj��}|s5|djttfkrAtd��|dj}|ttfkrs|dd�}n|t	k	r�td��|j
d|�S)zWPrivate helper to transform signatures for unbound
    functions to bound methods.
    rzinvalid method signaturerNzinvalid argument typer$)rWr$r%r`r+r*rhr'r&r)r7)r-�paramsr`rrr�_signature_bound_method�s 
r�cCs7t|�p6t|�p6t|t�p6|ttfkS)zxPrivate helper to test if `obj` is a callable that might
    support Argument Clinic's __text_signature__ protocol.
    )r3rrr�rr
)r_rrr�_signature_is_builtin�sr�cCs�t|�st|�rdSt|dd�}t|dd�}t|dt�}t|dt�}t|dd�}t|tj�o�t|t�o�|dks�t|t�o�|dks�t|t	�o�t|t	�S)z�Private helper to test if `obj` is a duck type of FunctionType.
    A good example of such objects are functions compiled with
    Cython, which have all attributes that a pure Python function
    would have, but have their code statically compiled.
    Fr}Nr�__defaults__�__kwdefaults__�__annotations__)
�callablerrC�_voidrrr0r�rWr�)r_r]rfrr0r/rrr�_signature_is_functionlikesr�cCs�|jd�st�|jd�}|dkr?|jd�}|jd�}|d	ksl||kslt�|jd�}|d
ks�||ks�t�|d|�S)z� Private helper to get first parameter name from a
    __text_signature__ of a builtin method, which should
    be in the following format: '($param1, ...)'.
    Assumptions are that the first argument won't have
    a default value or an annotation.
    z($�,rr��:r<r�rsrsrs)r�r��find)rFrNZcposrrr�_signature_get_bound_paramsr�cCs�|s|ddfSd}d}dd�|jd�D�}t|�j}tj|�}d}d}g}|j}	d}
tj}tj}t|�}
|
j	tj
ks�t�x'|D]}
|
j	|
j}}||krU|dkr|r�d}q�|st�d}|
d	7}
q�|d
krU|s0t�|dksBt�d}|
d	}q�||kr�|dkr�|dkst�|
}q�|r�d}||ko�|dks�|	d
�|	|�|dkr�|	d�q�Wdj
|�}|||fS)a�
    Private helper function. Takes a signature in Argument Clinic's
    extended signature format.

    Returns a tuple of three things:
      * that signature re-rendered in standard Python syntax,
      * the index of the "self" parameter (generally 0), or None if
        the function does not have a "self" parameter, and
      * the index of the last "positional only" parameter,
        or None if the signature has no positional-only parameters.
    NcSsg|]}|jd��qS)�ascii)�encode)rP�lrrrrREs	z6_signature_strip_non_python_syntax.<locals>.<listcomp>r�Frr�Tr�/�$r�z, � r�)ryr�r�r�rAr��OP�
ERRORTOKEN�nextr�ENCODINGr��stringr�)�	signature�self_parameter�last_positional_onlyr�r�Ztoken_streamZ
delayed_commaZskip_next_commar=rDZcurrent_parameterr�r��trr��clean_signaturerrr�"_signature_strip_non_python_syntax2sZ

			
	





r�Tcs8|j�t|�\}}}d|d}ytj|�}Wntk
rYd}YnXt|tj�s�tdj|���|j	d}	g��j
�t��d}i�t|dd�}
|
r�t
jj|
d�}|r�|j�t
j�dd����fd	d
��	G�	fdd�dtj����������fd
d�}t|	jj�}t|	jj�}
tj||
dd�}|dk	r��j�n	�j�xNttt|���D]4\}\}}|||�||kr��j�q�W|	jjr4�j�||	jj���j�x6t|	jj|	jj �D]\}}|||�qYW|	jj!r��j"�||	jj!��|dk	r%�s�t#�t|dd�}|dk	}t$|�}|r|s�|r�j%d�n#�dj&d�j�}|�d<|�d|j
�S)zdPrivate helper to parse content of '__text_signature__'
    and return a Signature based on it.
    zdef fooz: passNz"{!r} builtin has invalid signaturerrwcSs:t|tj�st�|jdkr3td��|jS)Nz'Annotations are not currently supported)r�astr>r�r,rh)�noderrr�
parse_name�sz&_signature_fromstr.<locals>.parse_namecs�yt|��}WnCtk
rXyt|��}Wntk
rSt��YnXYnXt|t�rutj|�St|ttf�r�tj	|�St|t
�r�tj|�S|dkr�tj|�St��dS)NTF)TFN)
�eval�	NameError�RuntimeErrorrr�r�ZStr�int�floatZNum�bytesZBytesZNameConstant)r�rM)�module_dict�sys_module_dictrr�
wrap_value�s 





z&_signature_fromstr.<locals>.wrap_valuecs4eZdZ�fdd�Z�fdd�ZdS)z,_signature_fromstr.<locals>.RewriteSymbolicscs�g}|}x/t|tj�r=|j|j�|j}qWt|tj�sYt��|j|j�dj	t
|��}�|�S)Nrr)rr�rOrAr�rM�Namer�rgr��reversed)r�r��arTrM)r�rr�visit_Attribute�s
	z<_signature_fromstr.<locals>.RewriteSymbolics.visit_Attributecs+t|jtj�st���|j�S)N)rZctxr�ZLoadrhrg)r�r�)r�rr�
visit_Name�s	z7_signature_fromstr.<locals>.RewriteSymbolics.visit_NameN)r}rwrxr�r�r)r�rr�RewriteSymbolics�sr�cs��|�}|�krdS|r�|tk	r�y%��j|�}tj|�}Wntk
rm�}YnX|�kr~dS|�k	r�|n|}�j�|�d|d���dS)Nr(r,)�_emptyZvisitr�Zliteral_evalrhrA)Z	name_nodeZdefault_noder(r]�o)�	Parameterr�r#�invalidr`r$r�rr�p�s
z_signature_fromstr.<locals>.p�	fillvaluer~r`r")'�_parameter_clsr�r��parse�SyntaxErrorrZModulerhriZbodyr#r
rCrtrurvr>ZNodeTransformerr�rr�	itertools�zip_longest�POSITIONAL_ONLY�POSITIONAL_OR_KEYWORDrAr�Zvararg�VAR_POSITIONAL�KEYWORD_ONLYrar
Zkw_defaultsrV�VAR_KEYWORDr�r
r�r7)rQr_r�rr�r�r�Zprogramr�reZmodule_namer�rrr�r�r]r(�_selfZself_isboundZ
self_ismoduler)
r�r�r#r�r`r�r$r�r�r�r�_signature_fromstrzsl	

				'	+

		(	
r�cCsat|�s!tdj|���t|dd�}|sNtdj|���t||||�S)zHPrivate helper function to get signature for
    builtin callables.
    z%{!r} is not a Python builtin function�__text_signature__Nz#no signature found for builtin {!r})r�r�rirCrhr�)rQrjrr�rrr�_signature_from_builtins	r�cCs�d}t|�s<t|�r'd}ntdj|���|j}|j}|j}|j}t|d|��}|j	}||||�}	|j
}
|j}|j}|r�t
|�}
nd}
g}||
}xI|d|�D]7}|
j|t�}|j||d|dt��q�Wx_t||d��D]G\}}|
j|t�}|j||d|dtd||��q<W|jt@r�|||}|
j|t�}|j||d|dt��xi|	D]a}t}|dk	r|j|t�}|
j|t�}|j||d|dtd|��q�W|jt@r�||}|jt@rm|d	7}||}|
j|t�}|j||d|dt��||d
|
jdt�d|�S)
zCPrivate helper: constructs Signature for the given python function.FTz{!r} is not a Python functionNrr,r`r(rr"r�__validate_parameters__)rr�r�rir�rr
rrWrr�r�r�rnrvr�rAr'rAr rr)r*rr+)rQrjZis_duck_functionr�Z	func_codeZ	pos_countZ	arg_namesrKZkeyword_only_countZkeyword_onlyr/rr0Zpos_default_countr$Znon_default_countr]r,�offsetr(rorrr�_signature_from_functionsj									
#








	r�rrc!Cs�t|�s!tdj|���t|tj�rht|jd|d|d|�}|rdt|�S|S|r�t	|ddd��}t|tj�r�t|d|d|d|�Sy
|j
}Wntk
r�Yn5X|dk	r
t|t�std	j|���|Sy
|j
}Wntk
r+Yn�Xt|tj�r�t|jd|d|d|�}t||d�}t|jj��d
}|jtjkr�|St|jj��}||d
k	s�t�|f|}	|jd|	�St|�st|�r
t||�St|�r,t||d|�St|tj�rlt|jd|d|d|�}t||�Sd}t|t �r�t!t |�d�}
|
dk	r�t|
d|d|d|�}nut!|d
�}|dk	r�t|d|d|d|�}n9t!|d�}|dk	r8t|d|d|d|�}|dkr�xS|j"dd�D]>}
y
|
j#}Wntk
rYqXX|rXt$|||�SqXWt |j"kr�|j%t&j%kr�|j't&j'kr�t(t&�St)dj|���n�t|t*�s�t!t |�d�}
|
dk	r�y"t|
d|d|d|�}WnCt)k
r�}z#dj|�}t)|�|�WYdd}~XnX|dk	r�|r�t|�S|St|tj+�r�dj|�}t)|��t)dj|���dS)zQPrivate helper function to get signature for arbitrary
    callable objects.
    z{!r} is not a callable objectrrrrccSs
t|d�S)N�
__signature__)r)rerrrr9�sz*_signature_from_callable.<locals>.<lambda>Nz1unexpected object {!r} in __signature__ attributerr$�__call__�__new__r�rz(no signature found for builtin type {!r}zno signature found for {!r}z,no signature found for builtin function {!r}z+callable {!r} is not supported by signature)Nrs),r�r�rirrrr r{r�rlr�rBr!�_partialmethod�	functools�
partialmethodrjr�rWr$r%r`r�r�r�r7rr�r�r�r�r�rr�rbr�r�r�r
r�r�rhr�r2)r_rrrr-r�r�Zfirst_wrapped_paramZ
sig_paramsr�Zcall�newZinitrJZtext_sigr.rRrrrr hs�			




		

		
	



"
r c@seZdZdZdS)r�z1A private marker - used in Parameter & Signature.N)r}rwrxr|rrrrr�0	sr�c@seZdZdZdS)r�z6Marker object for Signature.empty and Parameter.empty.N)r}rwrxr|rrrrr�4	sr�c@s:eZdZdZdZdZdZdZdd�ZdS)	�_ParameterKindrrr���cCs|jS)N)Z_name_)r�rrr�__str__?	sz_ParameterKind.__str__N)	r}rwrxr�r�r�r�r�r�rrrrr�8	sr�c
@seZdZdZd#ZeZeZe	Z
eZe
ZeZdededd	�Zd
d�Zdd
�Zedd��Zedd��Zedd��Zedd��Zdededededd�Zdd�Zdd�Zdd�Zd d!�Zd"S)$r�aRepresents a parameter in a function signature.

    Has the following public attributes:

    * name : str
        The name of the parameter as a string.
    * default : object
        The default value for the parameter if specified.  If the
        parameter has no default value, this attribute is set to
        `Parameter.empty`.
    * annotation
        The annotation for the parameter if specified.  If the
        parameter has no annotation, this attribute is set to
        `Parameter.empty`.
    * kind : str
        Describes how argument values are bound to the parameter.
        Possible values: `Parameter.POSITIONAL_ONLY`,
        `Parameter.POSITIONAL_OR_KEYWORD`, `Parameter.VAR_POSITIONAL`,
        `Parameter.KEYWORD_ONLY`, `Parameter.VAR_KEYWORD`.
    �_name�_kind�_default�_annotationr(r,cCs�|tttttfkr'td��||_|tk	ri|ttfkridj|�}t|��||_	||_
|tkr�td��t|t�s�t
dj|���|j�s�tdj|���||_dS)Nz,invalid value for 'Parameter.kind' attributez({} parameters cannot have default valuesz*name is a required attribute for Parameterzname must be a str, not a {!r}z"{!r} is not a valid parameter name)r&r'r)r*r+rhrr�rirrrr�r��isidentifierr�)r�r]r`r(r,rRrrrr�j	s"				zParameter.__init__cCs1t|�|j|jfd|jd|jifS)Nrr)rr�rrr)r�rrr�
__reduce__�	s		zParameter.__reduce__cCs|d|_|d|_dS)Nrr)rr)r��staterrr�__setstate__�	s
zParameter.__setstate__cCs|jS)N)r�)r�rrrr]�	szParameter.namecCs|jS)N)r)r�rrrr(�	szParameter.defaultcCs|jS)N)r)r�rrrr,�	szParameter.annotationcCs|jS)N)r)r�rrrr`�	szParameter.kindr]r`cCss|tkr|j}|tkr*|j}|tkr?|j}|tkrT|j}t|�||d|d|�S)z+Creates a customized copy of the Parameter.r(r,)r�r�rrrr)r�r]r`r,r(rrrr7�	s				zParameter.replacecCs�|j}|j}|jtk	r<dj|t|j��}|jtk	rfdj|t|j��}|tkrd|}n|t	kr�d|}|S)Nz{}:{}z{}={}r;z**)
r`r�rr�rir8rr6r)r+)r�r`�	formattedrrrr��	s			

zParameter.__str__cCsdj|jj|�S)Nz	<{} "{}">)rirr})r�rrr�__repr__�	szParameter.__repr__cCs"t|j|j|j|jf�S)N)�hashr]r`r,r()r�rrr�__hash__�	szParameter.__hash__cCsi||krdSt|t�s#tS|j|jkoh|j|jkoh|j|jkoh|j|jkS)NT)rr��NotImplementedr�rrr)r��otherrrr�__eq__�	szParameter.__eq__N)r�rrr)r}rwrxr|�	__slots__r&r�r'r�r)r�r*r�r+r�r�r#r�rrrTr]r(r,r`r�r7r�rr
r
rrrrr�J	s*r�c@s�eZdZdZdZdd�Zedd��Zed	d
��Zedd��Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�BoundArgumentsaResult of `Signature.bind` call.  Holds the mapping of arguments
    to the function's parameters.

    Has the following public attributes:

    * arguments : OrderedDict
        An ordered mutable mapping of parameters' names to arguments' values.
        Does not contain arguments' default values.
    * signature : Signature
        The Signature object that created this instance.
    * args : tuple
        Tuple of positional arguments values.
    * kwargs : dict
        Dict of keyword arguments values.
    r��
_signature�__weakref__cCs||_||_dS)N)r�r)r�r�r�rrrr��	s	zBoundArguments.__init__cCs|jS)N)r)r�rrrr��	szBoundArguments.signaturecCs�g}x�|jjj�D]u\}}|jttfkr;Py|j|}Wntk
raPYqX|jtkr�|j	|�q|j
|�qWt|�S)N)rr$r?r`r+r*r�rer)�extendrArW)r�rr�r1r>rrrr�	s
zBoundArguments.argscCs�i}d}x�|jjj�D]�\}}|sg|jttfkrOd}n||jkrgd}q|spqy|j|}Wntk
r�YqX|jtkr�|j|�q|||<qW|S)NFT)	rr$r?r`r+r*r�re�update)r��kwargsZkwargs_startedr�r1r>rrrr
s&	
zBoundArguments.kwargscCs�|j}g}x�|jjj�D]�\}}y|j|||f�Wq"tk
r�|jtk	rt|j}n3|jt	kr�f}n|jt
kr�i}nw"|j||f�Yq"Xq"Wt|�|_dS)z�Set default values for missing arguments.

        For variable-positional arguments (*args) the default is an
        empty tuple.

        For variable-keyword arguments (**kwargs) the default is an
        empty dict.
        N)r�rr$r?rArer(r�r`r)r+r)r�r�Z
new_argumentsr]r1�valrrr�apply_defaults#
s		
		zBoundArguments.apply_defaultscCsE||krdSt|t�s#tS|j|jkoD|j|jkS)NT)rrrr�r�)r�rrrrr
?
szBoundArguments.__eq__cCs|d|_|d|_dS)Nrr�)rr�)r�rrrrrG
s
zBoundArguments.__setstate__cCsd|jd|jiS)Nrr�)rr�)r�rrr�__getstate__K
szBoundArguments.__getstate__cCs^g}x6|jj�D]%\}}|jdj||��qWdj|jjdj|��S)Nz{}={!r}z	<{} ({})>z, )r�r?rArirr}r�)r�rr>rMrrrrN
szBoundArguments.__repr__N)r�rr)r}rwrxr|rr�rTr�rrrr
rrrrrrrr�	src@s?eZdZdZd.ZeZeZe	Z
dde	dddd	�Zed
d��Z
edd
��Zedddd��Zedd��Zedd��Zdededd�Zdd�Zdd�Zdd�Zddd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�ZdS)/r!aA Signature object represents the overall signature of a function.
    It stores a Parameter object for each parameter accepted by the
    function, as well as information specific to the function itself.

    A Signature object has the following public attributes and methods:

    * parameters : OrderedDict
        An ordered mapping of parameters' names to the corresponding
        Parameter objects (keyword-only arguments are in the same order
        as listed in `code.co_varnames`).
    * return_annotation : object
        The annotation for the return type of the function if specified.
        If the function has no annotation for its return type, this
        attribute is set to `Signature.empty`.
    * bind(*args, **kwargs) -> BoundArguments
        Creates a mapping from positional and keyword arguments to
        parameters.
    * bind_partial(*args, **kwargs) -> BoundArguments
        Creates a partial mapping from positional and keyword arguments
        to parameters (simulating 'functools.partial' behavior.)
    �_return_annotation�_parametersNr"r�TcCs[|dkrt�}n$|r#t�}t}d}xt|�D]�\}}|j}	|j}
|	|kr�d}|j||	�}t|��n|	|kr�d}|	}|	ttfkr�|jt	kr�|r�d}t|��nd}|
|krdj|
�}t|��|||
<q@Wntdd�|D��}t
j|�|_||_
dS)	z�Constructs Signature from the given list of Parameter
        objects and 'return_annotation'.  All arguments are optional.
        NFz'wrong parameter order: {!r} before {!r}z-non-default argument follows default argumentTzduplicate parameter name: {!r}css|]}|j|fVqdS)N)r])rPr1rrrr��
sz%Signature.__init__.<locals>.<genexpr>)rr&rAr`r]rirhr'r(r�r�MappingProxyTyperr)r�r$r"r�r�Ztop_kindZ
kind_defaults�idxr1r`r]rRrrrr�s
s<			
zSignature.__init__cCs#tjdtdd�t||�S)z3Constructs Signature for the given python function.zNinspect.Signature.from_function() is deprecated, use Signature.from_callable()rr�)r�r�r�r�)rQrjrrr�
from_function�
s	
zSignature.from_functioncCs#tjdtdd�t||�S)z4Constructs Signature for the given builtin function.zMinspect.Signature.from_builtin() is deprecated, use Signature.from_callable()rr�)r�r�r�r�)rQrjrrr�from_builtin�
s	
zSignature.from_builtin�follow_wrappedcCst|d|d|�S)z3Constructs Signature for the given callable object.rr)r )rQr_rrrr�
from_callable�
szSignature.from_callablecCs|jS)N)r)r�rrrr$�
szSignature.parameterscCs|jS)N)r)r�rrrr"�
szSignature.return_annotationr$cCsF|tkr|jj�}|tkr0|j}t|�|d|�S)z�Creates a customized copy of the Signature.
        Pass 'parameters' and/or 'return_annotation' arguments
        to override them in the new copy.
        r")r�r$r%rr)r�r$r"rrrr7�
s	zSignature.replacecCsNtdd�|jj�D��}dd�|jj�D�}|||jfS)Ncss$|]}|jtkr|VqdS)N)r`r*)rPr1rrrr��
sz(Signature._hash_basis.<locals>.<genexpr>cSs+i|]!}|jtkr||j�qSr)r`r*r])rPr1rrrr[�
s	z)Signature._hash_basis.<locals>.<dictcomp>)rWr$r%r")r�r��
kwo_paramsrrr�_hash_basis�
s"zSignature._hash_basiscCs:|j�\}}}t|j��}t|||f�S)N)r!�	frozensetr%r	)r�r�r r"rrrr
�
szSignature.__hash__cCs9||krdSt|t�s#tS|j�|j�kS)NT)rr!rr!)r�rrrrr
�
s
zSignature.__eq__r�FcCset�}t|jj��}f}t|�}x�yt|�}Wntk
rMyt|�}	Wntk
rxPYn�X|	jtkr�Pn�|	j|kr�|	jt	kr�d}
|
j
d|	j�}
t|
�d�|	f}Pnh|	jtks�|	j
tk	r|	f}Pn=|r|	f}Pn*d}
|
j
d|	j�}
t|
�d�Yq3Xyt|�}	Wn!tk
r�td�d�Yq3X|	jttfkr�td�d�|	jtkr�|g}|j|�t|�||	j<P|	j|krtdj
d|	j��d�|||	j<q3Wd}x�tj||�D]�}	|	jtkrT|	}q6|	jtkrfq6|	j}
y|j|
�}WnRtk
r�|r�|	jtkr�|	j
tkr�tdj
d|
��d�Yq6X|	jt	krtdj
d|	j���|||
<q6W|rU|dk	r1|||j<n$tdj
dtt|�����|j||�S)z#Private method. Don't use directly.zA{arg!r} parameter is positional only, but was passed as a keywordr>Nz$missing a required argument: {arg!r}ztoo many positional argumentsz$multiple values for argument {arg!r}z*got an unexpected keyword argument {arg!r})rr�r$r%r��
StopIterationr`r)r]r&rir�r+r(r�r*rrWr��chainr�re�_bound_arguments_cls)r�rrr�r�r$Z
parameters_exZarg_valsZarg_valr1rRr%Zkwargs_paramr�rrr�_bind�
s�	

			
	
		
	zSignature._bindcOs|dj|dd�|�S)z�Get a BoundArguments object, that maps the passed `args`
        and `kwargs` to the function's signature.  Raises `TypeError`
        if the passed arguments can not be bound.
        rrN)r&)rrrrr�bindmszSignature.bindcOs$|dj|dd�|dd�S)z�Get a BoundArguments object, that partially maps the
        passed `args` and `kwargs` to the function's signature.
        Raises `TypeError` if the passed arguments can not be bound.
        rrNr�T)r&)rrrrrr�tszSignature.bind_partialcCs.t|�t|jj��fd|jifS)Nr)rrWrr%r)r�rrrr{s	zSignature.__reduce__cCs|d|_dS)Nr)r)r�rrrrr�szSignature.__setstate__cCsdj|jj|�S)Nz<{} {}>)rirr})r�rrrr�szSignature.__repr__c	Csg}d}d}x�|jj�D]�}t|�}|j}|tkrRd}n|rk|jd�d}|tkr�d}n%|tkr�|r�|jd�d}|j|�q"W|r�|jd�djdj	|��}|j
tk	rt|j
�}|dj|�7}|S)NFTr�r;z({})z, z -> {})
r$r%r�r`r&rAr)r*rir�r"r�r8)	r�r\Zrender_pos_only_separatorZrender_kw_only_separatorr1rr`ZrenderedZannorrrr��s0		
	

zSignature.__str__)rr)r}rwrxr|rr�r�rr%r�r#r�r[rrrrTr$r"r�r7r!r
r
r&r'r�rrrr�rrrrr!U
s02			�r!rcCstj|d|�S)z/Get a signature object for the passed callable.r)r!r)r_rrrrr��sr�cCs^ddl}ddl}|j�}|jddd�|jdddd	dd
�|j�}|j}|jd�\}}}y|j|�}}	Wn`tk
r�}
z@dj	|t
|
�j|
�}t|d
t
j�td�WYdd}
~
XnX|r5|jd�}|	}x|D]}
t||
�}qW|	jt
jkrdtdd
t
j�td�|jrJtdj	|��tdj	t|	���tdj	|	j��||	kr�tdj	t|	j���t|	d�r=tdj	|	j��n>yt|�\}}Wntk
r)YnXtdj	|��td�ntt|��dS)z6 Logic for inspecting an object given at command line rNr
�helpzCThe object to be analysed. It supports the 'module:qualname' syntaxz-dz	--details�action�
store_truez9Display info about the module rather than its source coder�zFailed to import {} ({}: {})r�r�rrz#Can't get info for builtin modules.rz
Target: {}z
Origin: {}z
Cached: {}z
Loader: {}�__path__zSubmodule search path: {}zLine: {}r�)�argparser��ArgumentParser�add_argument�
parse_argsr
�	partition�
import_modulerXrirr}�printrt�stderr�exitryrC�builtin_module_namesZdetailsr��
__cached__r6r�rr+r�r�)r,r��parserr�targetZmod_nameZ	has_attrsZattrsr_r�r^rR�parts�part�__rnrrr�_main�sV			

	

r<r�)�r|�
__author__r�Zdis�collections.abcr(Zenum�importlib.machineryr�r�r�r�r�rtr�r�rr�r�r��operatorrrr�globalsZmod_dictZCOMPILER_FLAG_NAMESr?rKrLr6r
rrrrrrrrr!r"r$r&r+r-r/r1r3r4r7rNrOrar:rlrqrzr�r�r�r�r�r�r�r�r�r�r�r�r�r�rXr�r�r�r�r�r�rrrrrrrrr2r5r8r:r�rGrJrQrSrWrXrgrhrprq�_fieldsrrrvryr{r|r~r
r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�Z_WrapperDescriptor�allZ_MethodWrapperr�r>Z_ClassMethodWrapperr2r�r�r�r�r�r�r�r�r�r�r�r r�r�ZIntEnumr�r�r&r�r'r�r)r�r*r�r+r�rr!r�r<r}rrrr�<module>sP		
	

	
	,t!
;	.I-7


	[
							)		>5 			0LH�Q�					���`:

Hacked By AnonymousFox1.0, Coded By AnonymousFox