AlkantarClanX12

Your IP : 18.119.161.216


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/inspect.cpython-34.pyo

�
h f���@s�dZddfZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZmZyddlmZWnNek
r8dd	f\ZZd
df\ZZdd
df\ZZZYn5Xe �Z!x(ej"�D]\Z#Z$e#e!de$<qOWdd>Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*e+ed�r�dd�Z,ndd�Z,e+ed�r�d d!�Z-nd"d!�Z-d#d$�Z.d%d&�Z/d'd(�Z0d)d*�Z1d+d,�Z2d-d.�Z3d/d0�Z4d1d2�Z5d3d4�Z6dd5d6�Z7ed7d8�Z8d9d:�Z9d;d<�Z:d=dd>d?�Z;d@dA�Z<dBdC�Z=dDdE�Z>dFdG�Z?edHdI�Z@dJdK�ZAdLdM�ZBdNdO�ZCddPdQ�ZDiZEiZFddRdS�ZGdTdU�ZHdVdW�ZIGdXdY�dYeJ�ZKGdZd[�d[�ZLd\d]�ZMd^d_�ZNd`da�ZOdbdc�ZPdddedf�ZQedgdh�ZRdidj�ZSdkdl�ZTedmdn�ZUdodp�ZVedqdr�ZWdsdt�ZXedudv�ZYdwdx�ZZddydz�Z[d{d|�Z\dddfiie]d}d~�dd~�d�d~�d�d~�e[d�d��Z^e]d�d~�d�d~�d�d~�d�d��Z_d�d��Z`d�d��Zad�d��Zbed�d��Zcd�d��Zded�d��Zedd�d��Zfd�d��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��Zze{e{j|�Z}e{e~j|�Ze{e�j�d��Z�e}ee�ej�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�d�d��Z�d�d��Z�Gd�d��d��Z�Gd�d��d��Z�Gd�d��d�e��Z�e�dd�d��Z�e�dd�d��Z�e�d	d�d��Z�e�d�d�d��Z�e�d
d�d��Z�Gd�d��d��Z�Gd�d��d��Z�Gd�d��d��Z�d�d��Z�e�d�kr�e��ndS)�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-3000 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�OrderedDict)�COMPILER_FLAG_NAMES������ �@ZCO_�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/python34/lib64/python3.4/inspect.py�ismoduleDsrcCs
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)rrrr�isclassMsrcCst|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)rrrr�ismethodUsrcCsQt|�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�ismethoddescriptor_s$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)rrrrr�isdatadescriptorss$r�MemberDescriptorTypecCst|tj�S)z�Return true if the object is a member descriptor.

        Member descriptors are specialized descriptors defined in extension
        modules.)rrr )rrrr�ismemberdescriptor�sr!cCsdS)z�Return true if the object is a member descriptor.

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

        getset descriptors are specialized descriptors defined in extension
        modules.)rrr")rrrr�isgetsetdescriptor�sr#cCsdS)z�Return true if the object is a getset descriptor.

        getset descriptors are specialized descriptors defined in extension
        modules.Fr)rrrrr#�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)rrrrr�srcCs,tt|�st|�o(|jjt@�S)z�Return true if the object is a user-defined generator function.

    Generator function objects provides same attributes as functions.

    See help(isfunction) for attributes listing.)�boolrr�__code__�co_flags�CO_GENERATOR)rrrr�isgeneratorfunction�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)rrrr�isgenerator�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)rrrr�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)rrrr�isframe�sr/cCst|tj�S)auReturn true if the object is a code object.

    Code objects provide these attributes:
        co_argcount     number of arguments (not including * or ** args)
        co_code         string of raw compiled bytecode
        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
        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)rrrr�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)rrrr�	isbuiltin�sr3cCs.t|�p-t|�p-t|�p-t|�S)z<Return true if the object is any kind of function or method.)r3rrr)rrrr�	isroutine�sr4cCs tt|t�o|jt@�S)z:Return true if the object is an abstract base class (ABC).)r%rr�	__flags__�TPFLAGS_IS_ABSTRACT)rrrr�
isabstractsr7cCs�t|�r"|ft|�}nf}g}t�}t|�}yZxS|jD]H}x?|jj�D].\}}t|tj	�rf|j
|�qfqfWqPWWntk
r�YnXx�|D]�}	y(t||	�}
|	|kr�t�nWnFtk
r/x1|D]&}|	|jkr�|j|	}
Pq�q�Ww�YnX|sC||
�rY|j
|	|
f�n|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>1szgetmembers.<locals>.<lambda>)r�getmro�set�dir�	__bases__�__dict__�itemsrr�DynamicClassAttribute�append�AttributeError�getattr�add�sort)rZ	predicate�mro�results�	processed�names�base�k�vr8�valuerrr�
getmemberss:	





rN�	Attributezname kind defining_class objectcCs$t|�}tt|��}tdd�|D��}|f|}||}t|�}xP|D]H}x?|jj�D].\}}t|tj�rw|j	|�qwqwWqaWg}	t
�}
xa|D]Y}d}d}
d}||
kry.|dkrtd��nt||�}
Wn%tk
r<}zWYdd}~XqXt|
d|�}||krd}d}x5|D]-}t||d�}||
krn|}qnqnWxQ|D]I}y|j
||�}Wntk
r�w�YnX||
kr�|}q�q�W|dk	r|}qqnxC|D];}||jkr|j|}||krL|}nPqqW|dkrfq�n|
dk	rx|
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>Ss	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_attrs6s�


	







					racCs|jS)zHReturn tuple of base classes (including cls) in method resolution order.)�__mro__)rQrrrr:�sr:�stopcs��dkrdd�}n�fdd�}|}t|�h}xV||�r�|j}t|�}||kr�tdj|���n|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)rcrrrf�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rqcCsCy
|j}Wntk
r%dSYnXt|t�s9dSt|�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)�__doc__rBr�str�cleandoc)r�docrrr�getdoc�s

	rvcCsOy|j�jd�}Wntk
r1dSYnXtj}xR|dd�D]@}t|j��}|rLt|�|}t||�}qLqLW|r�|dj�|d<n|tjkr�x8tdt|��D]}|||d�||<q�Wnx|r|dr|j	�q�Wx"|r=|dr=|j	d�qWdj
|�SdS)z�Clean up indentation from docstrings.

    Any whitespace that can be uniformly removed from the second line
    onwards is removed.�
Nrr���)rm�split�UnicodeError�sys�maxsizernro�min�range�pop�join)ru�linesZmarginrpZcontent�indent�irrrrt�s(
		rtcCs't|�r:t|d�r"|jStdj|���nt|�r�t|d�r�tjj|j	�}t|d�r�|jSntdj|���nt
|�r�|j}nt|�r�|j
}nt|�r�|j}nt|�r�|j}nt|�r|jStdj|���dS)z@Work out which source or compiled file an object was defined in.�__file__z{!r} is a built-in module�
__module__z{!r} is a built-in classzO{!r} is not a module, class, method, function, traceback, frame, or code objectN)rrr��	TypeErrorrirr{�modules�getr�r�__func__rr&r-�tb_framer/�f_coder1�co_filename)rrrr�getfiles,
	r��
ModuleInfozname suffix mode module_typecCs�tjdtd�tj��!tjdt�ddl}WdQXtjj	|�}dd�|j
�D�}|j�xM|D]E\}}}}||d�|kr~t|d|�|||�Sq~WdS)zDGet the module name, suffix, mode, and module type for a given file.z%inspect.getmoduleinfo() is deprecatedr�ignorerNcSs2g|](\}}}t|�|||f�qSr)rn)rP�suffix�mode�mtyperrrrR$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�
getmoduleinfos
	
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�rrrrR/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�rrr�As�
__loader__)r�r�r��DEBUG_BYTECODE_SUFFIXES�OPTIMIZED_BYTECODE_SUFFIXES�anyr�r��splitext�SOURCE_SUFFIXES�EXTENSION_SUFFIXES�existsrC�	getmodule�	linecache�cache)rZall_bytecode_suffixesr)r�r�
getsourcefile7s!r�cCsC|dkr't|�p!t|�}ntjjtjj|��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�
getabsfileMsr�c

Cst|�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�n|t|<t|�}|j
t|<ttjj|�<q�q�W|tkrltjjt|�Stjd}t|d�s�dSt||j
�r�t||j
�}||kr�|Sntjd}t||j
�rt||j
�}	|	|kr|SndS)zAReturn the module an object was defined in, or None if not found.r�Nr��__main__�__name__�builtins)rrr{r�r�r��
modulesbyfiler�r��listr?r��_filesbymodnamer�r�r��realpathrC)
rr��file�modname�modulere�mainZ
mainobjectZbuiltinZ
builtinobjectrrrr�YsD
	"	
(

r�c
Cs�t|�}|r"tj|�n9t|�}|jd�oI|jd�s[td��nt||�}|r�tj||j	�}ntj|�}|s�td��nt
|�r�|dfSt|�r�|j}t
jd|d�}g}xptt|��D]\}|j||�}|r||ddkrD||fS|j|jd	�|f�qqW|r�|j�||dd	fStd
��nt|�r�|j}nt|�r�|j}nt|�r�|j}nt|�r�|j}nt|�r|t|d�s"td��n|jd	}	t
jd
�}x1|	dkrq|j||	�rdPn|	d	}	qAW||	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)|(.*(?<!\w)lambda(:|\s))|^(\s*@)zcould not find code objectN) r�r��
checkcacher��
startswithr��OSErrorr��getlinesr>rrr��re�compiler~rn�matchrA�grouprErr�rr&r-r�r/r�r1rr�)
rr�r�r�r]ZpatZ
candidatesr�r��lnumrrr�
findsource�s^
	
#


r�cCs�yt|�\}}Wnttfk
r4dSYnXt|�rEd}|rp|ddd�dkrpd}nx6|t|�kr�||j�dkr�|d}qsW|t|�kr�||dd�dkr�g}|}xQ|t|�kr4||dd�dkr4|j||j��|d}q�Wdj|�Sn�|dkr�t	||�}|d}|dkr�||j
�dd�dkr�t	||�|kr�||j�j
�g}|dkrk|d}||j�j
�}xv|dd�dkrgt	||�|krg|g|dd�<|d}|dkrNPn||j�j
�}q�Wnx0|r�|dj�dkr�g|dd�<qnWx0|r�|d	j�dkr�g|d
d�<q�Wdj|�SndS)zwGet lines of comments immediately preceding an object's source code.

    Returns None when source can't be found.
    Nrrz#!r��#)r�r�rxrx)r�r�r�rrn�striprArmr�rqro)rr�r��startZcomments�endr�Zcommentrrr�getcomments�sJ	 	+,/
,
/
r�c@seZdZdS)�
EndOfBlockN)r�r��__qualname__rrrrr��sr�c@s.eZdZdZdd�Zdd�ZdS)�BlockFinderz@Provide a tokeneater() method to detect the end of a code block.cCs1d|_d|_d|_d|_d|_dS)NrFr)r��islambda�started�passline�last)�selfrrr�__init__s
				zBlockFinder.__init__cCs$|jsE|dkr9|dkr-d|_nd|_nd|_n�|tjkrd|_|d|_|jr t�q n�|jr�n�|tjkr�|jd|_d|_nj|tj	kr�|jd|_|jdkr t�q n0|jdkr |tj
tjfkr t�ndS)	N�def�class�lambdaTFrr)zdefzclasszlambda)r�r�r��tokenize�NEWLINEr�r��INDENTr��DEDENT�COMMENT�NL)r�r�tokenZsrowcolZerowcolrprrr�
tokeneaters,		
		'zBlockFinder.tokeneaterN)r�r�r�rrr�r�rrrrr��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�cCsJt|�\}}t|�r(|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)r�rr�)rr�r�rrr�getsourcelines1s
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�)rr�r�rrr�	getsource>sr�cCsvg}|jdtdd��xP|D]H}|j||jf�||kr&|jt||||��q&q&W|S)z-Recursive helper function for getclasstree().r8r�r�)rErrAr=�walktree)�classes�children�parentrGr�rrrr�Hs
$r�FcCs�i}g}x�|D]�}|jr�x�|jD]Y}||krKg||<n|||kro||j|�n|r,||kr,Pq,q,Wq||kr|j|�qqWx*|D]"}||kr�|j|�q�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�)r�Zuniquer��rootsr�r�rrr�getclasstreeRs"	
	

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�getargsosrc	Cs�t|�s$tdj|���n|j}|j}|j}t|d|��}t||||��}d}||7}d}|jt@r�|j|}|d}nd}|jt	@r�|j|}n||||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��nargsrIZnkwargsr�r��stepr�r�rrrr�ys"			




r��ArgSpeczargs varargs keywords defaultscCsOt|�\}}}}}}}|s-|r<td��nt||||�S)aSGet the names and default values of a function's arguments.

    A tuple of four things is returned: (args, varargs, varkw, defaults).
    'args' is a list of the argument names.
    'args' will include keyword-only 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.

    Use the getfullargspec() API for Python-3000 code, as annotations
    and keyword arguments are supported. getargspec() will raise ValueError
    if the func has either annotations or keyword arguments.
    zcFunction has keyword-only arguments or annotations, use getfullargspec() API which can support them)�getfullargspecrhr)rjr�r�r��defaultsr��kwonlydefaults�annrrr�
getargspec�s!r
�FullArgSpeczGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc
Cs�yt|dddd�}Wn4tk
rR}ztd�|�WYdd}~XnXg}d}d}g}f}i}f}i}	|j|jk	r�|j|d<nx|jj�D]�}
|
j}|
j}|t	kr�|j
|�n�|tkr*|j
|�|
j|
jk	r�||
jf7}q�nh|t
kr?|}nS|tkr}|j
|�|
j|
jk	r�|
j|	|<q�n|tkr�|}n|
j|
jk	r�|
j||<q�q�W|	s�d}	n|s�d}nt||||||	|�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().
    �follow_wrapper_chainsF�skip_bound_argzunsupported callableN�return)�_signature_internalrXr��return_annotation�empty�
parameters�valuesr`r]�_POSITIONAL_ONLYrA�_POSITIONAL_OR_KEYWORD�default�_VAR_POSITIONAL�
_KEYWORD_ONLY�_VAR_KEYWORD�
annotationr)
rj�sig�exr�r�r�r�r
�annotations�
kwdefaults�paramr`r]rrrr	�sR	
"		
	
			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.)rr�r#�f_locals)�framer�r�r�rrr�getargvalues	sr&cCsGt|t�r=|jd|fkr+|jS|jd|jSt|�S)Nr��.)rrr�r��repr)rZbase_modulerrr�formatannotations
r)cs(t|dd���fdd�}|S)Nr�cs
t|��S)N)r))r)r�rr�_formatannotationsz5formatannotationrelativeto.<locals>._formatannotation)rC)rr*r)r�r�formatannotationrelativetosr+cCsd|S)N�*r)r]rrrr9#sr9cCsd|S)Nz**r)r]rrrr9$scCsdt|�S)N�=)r()rMrrrr9%scCsd|S)Nz -> r)�textrrrr9&sc
s����fdd�}
g}|r=t|�t|�}nx`t|�D]R\}}|
|�}|r�||kr�||
|||�}n|j|�qJW|dk	r�|j||
|���n|r�|jd�n|r:xS|D]H}|
|�}|r&||kr&||
||�7}n|j|�q�Wn|dk	rb|j|	|
|���nddj|�d}d�kr�||��d��7}n|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.cs7�|�}|�kr3|d��|�7}n|S)Nz: r)�argr\)r r)�	formatargrr�formatargandannotation0sz-formatargspec.<locals>.formatargandannotationNr,�(z, �)r)rn�	enumeraterAr�)r�r�r�r
r�rr r0�
formatvarargs�formatvarkw�formatvalueZ
formatreturnsr)r1�specsZfirstdefaultr�r/�specZ	kwonlyargr\r)r r)r0r�
formatargspec s2
r:cCsd|S)Nr,r)r]rrrr9QscCsd|S)Nz**r)r]rrrr9RscCsdt|�S)Nr-)r()rMrrrr9SscCs�|||dd�}g}	x1tt|��D]}
|	j|||
��q.W|ry|	j||�|||��n|r�|	j||�|||��nddj|	�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]�localsr0r7rrr�convertZsz formatargvalues.<locals>.convertr2z, r3)r~rnrAr�)r�r�r�r;r0r5r6r7r<r8r�rrr�formatargvaluesOs$$r=cs��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)r()rPr])rrrrRgs	z&_missing_arguments.<locals>.<listcomp>rrrz	{} and {}z, {} and {}z, z*%s() missing %i required %s argument%s: %s�
positionalzkeyword-onlyr�r����r?)rnrir�r�)�f_nameZargnames�posrrI�missingr��tailr)rr�_missing_argumentsfs

rDc
	s1t|�|}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}ntd
||
|	r�d	nd|||dkr |r dndf��dS)
Ncs"g|]}|�kr|�qSrr)rPr/)rrrrRxs	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)rnrsr�)
r@r�Zkwonlyr�ZdefcountZgivenrZatleastZkwonly_givenZpluralrZ
kwonly_sig�msgr)rr�	_too_manyvs$rFcOs�|d}|dd�}t|�}|\}}}}}	}
}|j}i}
t|�r~|jdk	r~|jf|}nt|�}t|�}|r�t|�nd}t||�}x&t|�D]}|||
||<q�W|r	t||d��|
|<nt||	�}|r,i|
|<nx�|j	�D]z\}}||kr�|spt
d||f��n||
||<q9n||
kr�t
d||f��n||
|<q9W||kr�|r�t|||	||||
�n||kr�|d||�}x0|D](}||
krt||d|
�qqWxHt
|||d��D])\}}||
krW|||
|<qWqWWnd}xJ|	D]B}||
kr�|
r�||
kr�|
||
|<q�|d7}q�q�W|r�t||	d|
�n|
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)r	r�r�__self__rnr}r~rWr;r?r�rFrDr4)Zfunc_and_positionalZnamedrjr>r9r�r�r�r
r�rrr@Z	arg2valueZnum_posZnum_argsZnum_defaults�nr�Zpossible_kwargs�kwrMZreqr/rB�kwargrrr�getcallargs�sd
	


'
rK�ClosureVarsz"nonlocals globals builtins unboundc	Cs^t|�r|j}nt|�s<tdj|���n|j}|jdkr]i}n"dd�t|j|j�D�}|j	}|j
dtj�}t
|�r�|j}ni}i}t�}x~|jD]s}|d	kr�q�ny||||<Wq�tk
rFy||||<Wntk
rA|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>�s	z"getclosurevars.<locals>.<dictcomp>�__builtins__�None�True�False)zNonezTruezFalse)rr�rr�rir&�__closure__�zip�co_freevars�__globals__r�r�r>rr;�co_names�KeyErrorrDrL)	rj�codeZ
nonlocal_varsZ	global_nsZ
builtin_nsZglobal_varsZbuiltin_varsZ
unbound_namesr]rrr�getclosurevars�s8						

	r[�	Tracebackz+filename lineno function code_context indexcCs5t|�r!|j}|j}n	|j}t|�sNtdj|���nt|�pct|�}|dkr|d|d}yt	|�\}}Wnt
k
r�d}}YqXt|d�}tdt|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 objectrrrN)r-�	tb_linenor��f_linenor/r�rir�r�r�r��maxr}rnr\r��co_name)r%�context�linenor�r�r�r��indexrrr�getframeinfos&		
"
rdcCs|jS)zCGet the line number from a frame object, allowing for optimization.)r^)r%rrr�	getlineno#srecCs=g}x0|r8|j|ft||��|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.)rArd�f_back)r%ra�	framelistrrr�getouterframes(s
	
rhcCs@g}x3|r;|j|jft||��|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.)rAr�rd�tb_next)�tbrargrrr�getinnerframes3s
	 
rkcCs ttd�rtjd�SdS)z?Return the frame of the caller or None if this is not possible.�	_getframerN)rr{rlrrrr�currentframe>srmcCsttjd�|�S)z@Return a list of records for the stack above the caller's frame.r)rhr{rl)rarrr�stackBsrncCsttj�d|�S)zCReturn a list of records for the stack below the current exception.r)rkr{�exc_info)rarrr�traceFsrpcCstjdj|�S)Nrb)rr>r)�klassrrr�_static_getmroOsrrcCsDi}ytj|d�}Wntk
r0YnXtj||t�S)Nr>)r�__getattribute__rB�dictr��	_sentinel)r_�attrZ
instance_dictrrr�_check_instanceRs
rwcCsZxSt|�D]E}tt|��tkr
y|j|SWqRtk
rNYqRXq
q
WtS)N)rr�_shadowed_dictrrur>rY)rqrv�entryrrr�_check_class[s
rzcCs+yt|�Wntk
r&dSYnXdS)NFT)rrr�)r_rrr�_is_typeds

	r{cCs�tjd}xwt|�D]i}y|j|�d}Wntk
rKYqXt|�tjko||jdko||j|ks|SqWt	S)Nr>)
rr>rrrrYrr"r�rSru)rq�	dict_attrryZ
class_dictrrrrxks

rxcCsut}t|�s`t|�}t|�}|tksKt|�tjkrft||�}qfn|}t||�}|tk	r�|tk	r�tt|�d�tk	r�tt|�d�tk	r�|Sn|tk	r�|S|tk	r�|S||krUx\tt|��D]E}tt|��tkr	y|j	|SWqNt
k
rJYqNXq	q	Wn|tk	re|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)rur{rrxrr rwrzrrr>rYrB)r_rvrZinstance_resultrqr|Zklass_resultryrrr�getattr_staticys6
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.
    Nrrx)�
gi_runningr�gi_framer��f_lastir~r�)�	generatorrrr�getgeneratorstate�s		r�cCsTt|�s$tdj|���nt|dd�}|dk	rL|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�r$)r�r%rrr�getgeneratorlocals�s
r��
from_bytescCsCyt||�}Wntk
r+dSYnXt|t�s?|SdS)N)rCrBr�_NonUserDefinedCallables)rQZmethod_name�methrrr�"_signature_get_user_defined_method�s
	r�cCs0|j}t|j��}|jp'f}|jp6i}|rL||}ny|j||�}WnCtk
r�}z#dj|�}	t|	�|�WYdd}~XnXd}
xi|j�D][\}}y|j	|}
Wnt
k
r�Yn�X|jtkr|j
|�q�n|jtkr_||krId}
|jd|
�||<q_|j
|j�q�n|jtkr�|jd|
�||<n|
r�|jtkr�||jdt�}|||<|j|�q|jttfkr�|j|�q|jtkr|j
|j�qq�q�W|jd|j��S)Nz+partial object {!r} has incorrect argumentsFTrr`r)rrr?r��keywords�bind_partialr�rirh�	argumentsrYr`rrr�replacer]r�move_to_endrrr)�wrapped_sig�partialZ
extra_argsZ
old_params�
new_paramsZpartial_argsZpartial_keywordsZbarrEZtransform_to_kwonly�
param_namer"Z	arg_valueZ	new_paramrrr�_signature_get_partial�sL	
"



r�cCs�t|jj��}|s5|djttfkrDtd��n|dj}|ttfkrv|dd�}n|t	k	r�td��n|j
d|�S)Nrzinvalid method signaturerzinvalid argument typer)rWrrr`rrrhrrrr�)r�paramsr`rrr�_signature_bound_method6s 
r�cCs7t|�p6t|�p6t|t�p6|ttfkS)N)r3rrr�rr)r_rrr�_signature_is_builtinOs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)NFr�r&�__defaults__�__kwdefaults__�__annotations__)
�callablerrC�_voidrrr0rsrWrt)r_r]rZr
r!r rrr�_signature_is_functionlikeZsr�cCsY|jd�}|dkr-|jd�}n|jd�}|jd�}|d|�S)N�,rr3�:r-rrx)�find)r9rAZcposrrr�_signature_get_bound_paramrs	r�cCs�|s|ddfSd}d}dd�|jd�D�}t|�j}tj|�}d}d}g}|j}	d}
tj}tj}t|�}
x�|D]�}
|
j	|
j
}}||kr|dkr�|r�d}q�d}|
d	7}
q�n|d
krd}|
d	}q�qn||kr>|dkr>|
}q�n|rrd}||ko_|dksr|	d
�qrn|	|�|dkr�|	d�q�q�Wdj|�}|||fS)a�
    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�lrrrrR�s	z6_signature_strip_non_python_syntax.<locals>.<listcomp>rwFrr�Tr�/�$r3z, � r�)ryr�r�r�rAr��OP�
ERRORTOKEN�nextr�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_syntax�sP
			
	

	
r�TcsA|j�t|�\}}}d|d}ytj|�}Wntk
rYd}YnXt|tj�s�tdj|���n|j	d}	g��j
�t��d}i�t|dd�}
|
r�t
jj|
d�}|r�|j�q�nt
j�dd����fdd	��	G�	fd
d�dtj����������fdd
�}t|	jj�}t|	jj�}
tj||
dd�}|dk	r��j�n	�j�xQttt|���D]7\}\}}|||�||kr��j�q�q�W|	jjrC�j�||	jj��n�j�x6t|	jj|	jj �D]\}}|||�qhW|	jj!r��j"�||	jj!��n|dk	r.t|dd�}|dk	}t#|�}|r|s�|r�j$d�q.�dj%d�j�}|�d<n|�d|j
�S)Nzdef fooz: passz"{!r} builtin has invalid signaturerr�cSs%|jdkrtd��n|jS)Nz'Annotations are not currently supported)rrhr/)�noderrr�
parse_name�sz&_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�RuntimeErrorrrs�astZStr�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�s\t��n|j|j�dj	t
|��}�|�S)Nr')rr�rOrArvrM�Namer�rgr��reversed)r�r��arHrM)r�rr�visit_Attribute	s
z<_signature_fromstr.<locals>.RewriteSymbolics.visit_Attributecs.t|jtj�s!t��n�|j�S)N)rZctxr�ZLoadrhrg)r�r�)r�rr�
visit_Namesz7_signature_fromstr.<locals>.RewriteSymbolics.visit_NameN)r�r�r�r�r�r)r�rr�RewriteSymbolicssr�cs��|�}|�krdS|r�|tk	r�y%��j|�}tj|�}Wntk
rm�}YnX|�kr~dS|�k	r�|n|}n�j�|�d|d���dS)Nrr)�_emptyZvisitr�Zliteral_evalrhrA)Z	name_nodeZdefault_noderr]�o)�	Parameterr�r�invalidr`rr�rr�ps
z_signature_fromstr.<locals>.p�	fillvaluerGr`r)&�_parameter_clsr�r��parse�SyntaxErrorrZModulerhriZbodyrrrCr{r�r�r>ZNodeTransformerr�r�r
�	itertools�zip_longest�POSITIONAL_ONLY�POSITIONAL_OR_KEYWORDr4r�Zvararg�VAR_POSITIONAL�KEYWORD_ONLYrUr�Zkw_defaultsrJ�VAR_KEYWORDrrr�)rQr_r�rr�r�r�Zprogramr�reZmodule_namer�r�r
r�r�r]r�_selfZself_isboundZ
self_ismoduler)
r�r�rr�r`r�rr�r�r�r�_signature_fromstr�sj	

			'	+
		(	
r�cCsgt|�s$tdj|���nt|dd�}|sTtdj|���nt||||�S)Nz%{!r} is not a Python builtin function�__text_signature__z#no signature found for builtin {!r})r�r�rirCrhr�)rQrjrr�rrr�_signature_from_builtinYs	r�c!Cs[t|�s$tdj|���nt|tj�rbt|j||�}|r[t|�S|Sn|r�t	|ddd��}t|tj�r�t|d|d|�Sny
|j
}Wntk
r�Yn8X|dk	rt|t�stdj|���n|Sy
|j
}Wntk
r%YnXt|tj�r�t|j||�}t||d�}t|jj��d}|ft|jj��}|jd	|�St|�s�t|�r�tj|�St|�r�tt|d|�St|tj�rt|j||�}t||�Sd}t|t�r]tt|�d
�}|dk	rgt|||�}n`t|d�}	|	dk	r�t|	||�}n0t|d�}
|
dk	r�t|
||�}n|dkr�xS|jdd�D]>}y
|j}Wntk
rYq�X|r�t t||�Sq�Wt|jkrZ|j!t"j!krWt#t"�SqZq�n�t|t$�s�tt|�d
�}|dk	r�yt|||�}Wq�t%k
r�}
z#dj|�}t%|�|
�WYdd}
~
Xq�Xq�n|dk	r|rt|�S|Snt|tj&�rBdj|�}t%|��nt%dj|���dS)Nz{!r} is not a callable objectrccSs
t|d�S)N�
__signature__)r)rerrrr9ysz%_signature_internal.<locals>.<lambda>rrz1unexpected object {!r} in __signature__ attributerr�__call__�__new__r�rzno signature found for {!r}z,no signature found for builtin function {!r}z+callable {!r} is not supported by signature)Nrx)'r�r�rirrrrr�r�rlr�rB�	Signature�_partialmethod�	functools�
partialmethodrjr�rWrrr�rr��
from_functionr�r�r�rr�rbr�r�r�rr�r�rhr2)r_rrrr�r�Zfirst_wrapped_paramr��call�newZinitrJZtext_sigrrErrrrgs�		





		
		



(
rcCs
t|�S)z/Get a signature object for the passed callable.)r)r_rrrr�
sr�c@seZdZdZdS)r�z0A private marker - used in Parameter & SignatureN)r�r�r�rrrrrrr�sr�c@seZdZdS)r�N)r�r�r�rrrrr�sr�c@s4eZdZdd�Zdd�Zdd�ZdS)�_ParameterKindcGstj||�}||_|S)N)r�r��_name)r�r]r�r_rrrr�s	z_ParameterKind.__new__cCs|jS)N)r�)r�rrr�__str__ sz_ParameterKind.__str__cCsdj|j�S)Nz<_ParameterKind: {!r}>)rir�)r�rrr�__repr__#sz_ParameterKind.__repr__N)r�r�r�r�r�r�rrrrr�sr�r]r�r�r��r�r�c
@s�eZdZdZdZeZeZe	Z
eZe
ZeZdededd	�Zed
d��Zedd
��Zedd��Zedd��Zdededededd�Zdd�Zdd�Zdd�ZdS)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`.
    r��_kind�_default�_annotationrrcCs�|tttttfkr*td��n||_|tk	rr|ttfkrrdj|�}t|��qrn||_	||_
|tkr�td��nt|t�s�t
dj|���n|j�s�tdj|���n||_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)rrrrrrhr�r�rir�r�rrsr��isidentifierr�)r�r]r`rrrErrrr�Ns"				zParameter.__init__cCs|jS)N)r�)r�rrrr]gszParameter.namecCs|jS)N)r�)r�rrrrkszParameter.defaultcCs|jS)N)r�)r�rrrroszParameter.annotationcCs|jS)N)r�)r�rrrr`sszParameter.kindr]r`cCs|tkr|j}n|tkr0|j}n|tkrH|j}n|tkr`|j}nt|�||d|d|�S)z+Creates a customized copy of the Parameter.rr)r�r�r�r�r�r)r�r]r`rrrrrr�wszParameter.replacecCs�|j}|j}|jtk	r?dj|t|j��}n|jtk	rldj|t|j��}n|tkr�d|}n|t	kr�d|}n|S)Nz{}:{}z{}={}r,z**)
r`r�r�r�rir)r�r(rr)r�r`�	formattedrrrr��s			

zParameter.__str__cCs"dj|jjt|�|j�S)Nz<{} at {:#x} {!r}>)ri�	__class__r�rgr])r�rrrr��szParameter.__repr__cCsYt|t�stS|j|jkoX|j|jkoX|j|jkoX|j|jkS)N)rr��NotImplementedr�r�r�r�)r��otherrrr�__eq__�szParameter.__eq__N)z_namez_kindz_defaultz_annotation)r�r�r�rr�	__slots__rr�rr�rr�rr�rr�r�rr�rTr]rrr`r�r�r�r�r�rrrrr�.s$r�c@sdeZdZdZdd�Zedd��Zedd��Zedd	��Zd
d�Z	dS)
�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.
    cCs||_||_dS)N)r��
_signature)r�r�r�rrrr��s	zBoundArguments.__init__cCs|jS)N)r�)r�rrrr��szBoundArguments.signaturecCs�g}x�|jjj�D]x\}}|jttfkr>Pny|j|}Wntk
rdPYqX|jtkr�|j	|�q|j
|�qWt|�S)N)r�rr?r`rrr�rYr�extendrArW)r�r�r�r"r/rrrr��s
zBoundArguments.argscCs�i}d}x�|jjj�D]�\}}|sm|jttfkrOd}qm||jkrmd}qqmn|syqny|j|}Wntk
r�YqX|jtkr�|j|�q|||<qW|S)NFT)	r�rr?r`rrr�rY�update)r��kwargsZkwargs_startedr�r"r/rrrr��s&		
zBoundArguments.kwargscCs5t|t�stS|j|jko4|j|jkS)N)rr�r�r�r�)r�r�rrrr��szBoundArguments.__eq__N)
r�r�r�rrr�rTr�r�r�r�rrrrr��sr�c@s�eZdZdZd!ZeZeZe	Z
dde	dddd	�Zed
d��Z
edd
��Zedd��Zedd��Zdededd�Zdd�Zdddd�Zdd�Zdd�Zdd �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�__validate_parameters__TcCsg|dkrt�}n0|r/t�}t}d}xt|�D]�\}}|j}	|j}
|	|kr�d}|j||	�}t|��n|	|kr�d}|	}n|	ttfkr�|jt	kr�|r�d}t|��q�q�d}n|
|krdj|
�}t|��n|||
<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])rPr"rrrr�I	sz%Signature.__init__.<locals>.<genexpr>)rrr4r`r]rirhrrr�r�MappingProxyTyper�r�)r�rrr�r�Ztop_kindZ
kind_defaults�idxr"r`r]rErrrr�	s<					
zSignature.__init__cCs�d}t|�s?t|�r'd}q?tdj|���n|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��nxl|	D]d}t}|dk	r
|j|t�}n|
j|t�}|j||d|dtd|��q�W|jt@r�||}|jt@ry|d	7}n||}|
j|t�}|j||d|dt��n||d
|
jdt�d|�S)
z2Constructs Signature for the given python functionFTz{!r} is not a Python functionNrrr`rrrrr�)rr�r�rir�r&rrrWrr�r�r�rnr�r�rArr4r'rrrrr)rQrjZis_duck_functionr�Z	func_codeZ	pos_countZ	arg_namesr>Zkeyword_only_countZkeyword_onlyr r
r!Zpos_default_countrZnon_default_countr]r�offsetrrcrrrr�O	sj									
#








	zSignature.from_functioncCs
t||�S)N)r�)rQrjrrr�from_builtin�	szSignature.from_builtincCs|jS)N)r�)r�rrrr�	szSignature.parameterscCs|jS)N)r�)r�rrrr�	szSignature.return_annotationrcCsL|tkr|jj�}n|tkr6|j}nt|�|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�rrr�r)r�rrrrrr��	szSignature.replacecCs/t|t�stS|j|jksCt|j�t|j�krGdSdd�t|jj��D�}x�t|jj��D]�\}\}}|j	t
kr�y|j|}Wntk
r�dSYq'X||kr'dSqy||}Wntk
rdSYqX||ks#||j|krdSqWdS)NFcSsi|]\}}||�qSrr)rPr�r"rrrrO�	s	z$Signature.__eq__.<locals>.<dictcomp>T)rr�r�rrnrr4�keysr?r`rrY)r�r�Zother_positionsr�r�r"Zother_paramZ	other_idxrrrr��	s.	(
	
	zSignature.__eq__r�FcCsbt�}t|jj��}f}t|�}x�yt|�}Wntk
rPyt|�}	Wntk
rxPYn�X|	jtkr�Pn�|	j|kr�|	jt	kr�d}
|
j
d|	j�}
t|
�d�n|	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��n|	jtkr�|g}|j|�t|�||	j<Pn|	j|krtdj
d|	j���n|||	j<q3Wd}x�tj||�D]�}	|	jtkr]|	}q<n|	jtkrrq<n|	j}
y|j|
�}WnUtk
r�|r�|	jtkr�|	j
tkr�tdj
d|
��d�nYq<X|	jt	krtdj
d|	j���n|||
<q<W|rR|dk	rC|||j<qRtd��n|j||�S)z$Private method.  Don't use directly.zA{arg!r} parameter is positional only, but was passed as a keywordr/Nz'{arg!r} parameter lacking default valueztoo many positional argumentsz$multiple values for argument {arg!r}ztoo many keyword arguments)rr�rrr��
StopIterationr`rr]rrir�rrr�rr�rWr��chainrrY�_bound_arguments_cls)r�r�r�r�r�rZ
parameters_exZarg_valsZarg_valr"rErZ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)r�r�rrr�bindY
szSignature.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)r�r�rrrr�`
szSignature.bind_partialc	Cs"g}d}d}x�|jj�D]�}t|�}|j}|tkrRd}n|rn|jd�d}n|tkr�d}n(|tkr�|r�|jd�d}n|j|�q"W|r�|jd�ndjdj	|��}|j
tk	rt|j
�}|dj|�7}n|S)NFTr�r,z({})z, z -> {})
rrrsr`rrArrrir�rr�r))	r�r\Zrender_pos_only_separatorZrender_kw_only_separatorr"r�r`ZrenderedZannorrrr�g
s0		
		
	zSignature.__str__)z_return_annotationz_parameters)r�r�r�rrr�r�r�r�rr�rr�r[r�r�rTrrr�r�r�rrr�r�rrrrr��s"2Qr�cCsgddl}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|r8|jd�}|	}x |D]}
t||
�}qWn|	jt
jkrjtdd
t
j�td�n|jrStdj	|��tdj	t|	���tdj	|	j��||	krtdj	t|	j���t|	d�rFtdj	|	j��qFn>yt|�\}}Wntk
r2YnXt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�rr'z#Can't get info for builtin modules.rz
Target: {}z
Origin: {}z
Cached: {}z
Loader: {}�__path__zSubmodule search path: {}zLine: {}rw)�argparser��ArgumentParser�add_argument�
parse_argsr�	partition�
import_modulerXrirr��printr{�stderr�exitryrC�builtin_module_namesZdetailsr��
__cached__r(r�rrr�r�)rr��parserr��targetZmod_nameZ	has_attrsZattrsr_r�r^rE�parts�part�__rbrrr�_main�
sV			

	

rr�)�rr�
__author__r��importlib.machineryr�r�r�r�r�r{r�r�rr�r�r��operatorr�collectionsrrZdisrZ_flag_names�ImportErrorZCO_OPTIMIZEDZCO_NEWLOCALSrrZ	CO_NESTEDr(Z	CO_NOFREE�globalsZmod_dictr?rKrLr6rrrrrrr!r#rr)r+r-r/r1r3r4r7rNrOrar:rlrqrvrtr�r�r�r�r�r�r�r�r�r�r�rXr�r�r�r�r�r�r�r�rr�rr
rr	r#r&r)r+rsr:r=rDrFrKrLr[r\rdrerhrkrmrnrprrurrrwrzr{rxr}r~rr�r�r�r�rr�Z_WrapperDescriptor�allZ_MethodWrapperr�r>Z_ClassMethodWrapperr2r�r�r�r�r�r�r�r�r�r�rr�r�r�r�rrrrrr�r�r�rr�rrrr�<module>s8	
	
	

	
	,t!	.I-'



	X
						)		>5!			0KF��
{U��: