a �DOg��� @s�dZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlmZddlmZmZe�Zej��D]\ZZeede<q�dZdd�Zd d �Z d d �Z!d d�Z"dd�Z#e$ed��rdd�Z%ndd�Z%e$ed��r.dd�Z&ndd�Z&dd�Z'dd�Z(dd�Z)dd �Z*d!d"�Z+d#d$�Z,d%d&�Z-d'd(�Z.d)d*�Z/d+d,�Z0d-d.�Z1d/d0�Z2d1d2�Z3d3d4�Z4d5d6�Z5d�d7d8�Z6ed9d:�Z7d;d<�Z8d=d>�Z9dd?�d@dA�Z:dBdC�Z;dDdE�ZdJdK�Z?dLdM�Z@dNdO�ZAdPdQ�ZBd�dRdS�ZCiZDiZEd�dTdU�ZFGdVdW�dWeG�ZHGdXdY�dYejI�ZJdZd[�ZKd\d]�ZLGd^d_�d_eG�ZMGd`da�da�ZNdbdc�ZOddde�ZPdfdg�ZQdhdi�ZRd�dkdl�ZSedmdn�ZTdodp�ZUedqdr�ZVdsdt�ZWedudv�ZXdwdx�ZYedydz�ZZd{d|�Z[d�d}d~�Z\dd��Z]dddd�iie^d�d��d�d��d�d��d�d��e\f d�d��Z_e^d�d��d�d��d�d��fd�d��Z`d�d��Zad�d��Zbd�d��Zced�d��Zdd�d��Zeed�d��Zfd�d�d��Zgd�d��Zhed�d�efji�Zjd�d�d��Zkd�d�d��Zld�d��Zmd�d�d��Zn�dd�d��Zoep�Zqd�d��Zrd�d��Zsd�d��Ztd�d��Zud�d��Zveqfd�d��Zwd�Zxd�Zyd�Zzd�Z{d�d��Z|d�d��Z}d�Z~d�Zd�Z�d�Z�d�dĄZ�d�dƄZ�e�e�j��Z�e�e�j��Z�e�e�j�d��Z�e�e�e�ej�fZ�d�dɄZ��dd�d˄Z�d�d̈́Z�d�dτZ�d�dфZ�d�dӄZ�d�dՄZ��dd�d؄Z��dd�dڄZ��dd�d܄Z�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�e�d�e�d�e�d�e�d�e�d�iZ�Gd�d�d�Z�Gd�d�d�Z�Gd�d��d��Z�d�d�d�d�Z�d�d��Z�e�d�k�r�e��dS()zKa-Ping Yee z'Yury Selivanov �N)� attrgetter)� namedtuple� OrderedDictZCO_icCs t|tj�S�N)� isinstance�types� ModuleType��object�r �/usr/lib64/python3.9/inspect.py�ismodule@sr cCs t|t�Sr)r�typer r r r �isclassIsrcCs t|tj�Sr)rr� MethodTyper r r r �ismethodQsrcCs:t|�st|�st|�rdSt|�}t|d�o8t|d� S)NF�__get__�__set__�rr� isfunctionr�hasattr�r �tpr r r �ismethoddescriptor[srcCs8t|�st|�st|�rdSt|�}t|d�p6t|d�S)NFr� __delete__rrr r r �isdatadescriptorosr�MemberDescriptorTypecCs t|tj�Sr)rrrr r r r �ismemberdescriptorsrcCsdS�NFr r r r r r�s�GetSetDescriptorTypecCs t|tj�Sr)rrrr r r r �isgetsetdescriptor�sr cCsdSrr r r r r r �scCs t|tj�Sr)rr� FunctionTyper r r r r�s rcCs6t|�r|j}qt�|�}t|�s&dSt|jj|@�Sr)r�__func__� functools�_unwrap_partialr�bool�__code__�co_flags)�f�flagr r r �_has_code_flag�s  r*cCs t|t�Sr)r*Z CO_GENERATOR��objr r r �isgeneratorfunction�sr-cCs t|t�Sr)r*Z CO_COROUTINEr+r r r �iscoroutinefunction�sr.cCs t|t�Sr)r*ZCO_ASYNC_GENERATORr+r r r �isasyncgenfunction�sr/cCs t|tj�Sr)rr�AsyncGeneratorTyper r r r � isasyncgen�sr1cCs t|tj�Sr)rr� GeneratorTyper r r r � isgenerator�sr3cCs t|tj�Sr)rr� CoroutineTyper r r r � iscoroutine�sr5cCs6t|tj�p4t|tj�r(t|jjt@�p4t|tj j �Sr) rrr4r2r%�gi_coder'ZCO_ITERABLE_COROUTINE� collections�abc� Awaitabler r r r � isawaitable�s   � �r:cCs t|tj�Sr)rr� TracebackTyper r r r � istraceback�sr<cCs t|tj�Sr)rr� FrameTyper r r r �isframe�s r>cCs t|tj�Sr)rr�CodeTyper r r r �iscodesr@cCs t|tj�Sr)rr�BuiltinFunctionTyper r r r � isbuiltinsrBcCs t|�pt|�pt|�pt|�Sr)rBrrrr r r r � isroutine's���rCcCs�t|t�sdS|jt@rdStt|�tj�s0dSt|d�r>dS|j� �D]\}}t |dd�rHdSqH|j D]6}t |dd�D]$}t ||d�}t |dd�rzdSqzqjdS)NFT�__abstractmethods__�__isabstractmethod__r ) rr� __flags__�TPFLAGS_IS_ABSTRACT� issubclassr8�ABCMetar�__dict__�items�getattr� __bases__)r �name�value�baser r r � isabstract.s"        rQc Cst|�r|ft|�}nd}g}t�}t|�}z:|jD].}|j��D]\}}t|tj �rD|� |�qDq6Wnt yzYn0|D]|} zt || �} | |vr�t �Wn8t y�|D]}| |jvr�|j| } q�q�Yq�Yn0|r�|| �r�|� | | f�|� | �q�|jdd�d�|S)Nr cSs|dS)Nrr )Zpairr r r �o�zgetmembers..��key)r�getmro�set�dirrMrJrKrr�DynamicClassAttribute�append�AttributeErrorrL�add�sort) r � predicate�mro�results� processed�namesrP�k�vrUrOr r r � getmembersFs:          re� Attributezname kind defining_class objectc CsTt|�}tt|��}tdd�|D��}|f|}||}t|�}|D].}|j��D]\}}t|tj�rR|� |�qRqDg} t �} |D�]�} d} d} d}| | v�rzz| dkr�t d��t || �} Wn$t y�}z WYd}~n�d}~00t | d| �} | |v�rzd} d}|D] }t || d�}|| u�r|}�q|D]@}z|� || �}Wnt�yXY�q*Yn0|| u�r*|}�q*|du�rz|} |D]0}| |jv�r~|j| }| |v�r�|} �q��q~| du�r�q�| du�r�| n|}t|ttjf��r�d}|}nFt|ttjf��rd}|}n*t|t��rd}|}nt|��r,d }nd }| � t| || |��| �| �q�| S) Ncss|]}|ttfvr|VqdSr)rr )�.0�clsr r r � �rSz'classify_class_attrs..rJz)__dict__ is special, don't want the proxy� __objclass__z static methodz class method�property�method�data)rVr�tuplerXrJrKrrrYrZrW� ExceptionrL� __getattr__r[� staticmethod�BuiltinMethodType� classmethod�ClassMethodDescriptorTyperkrCrfr\)rhr_ZmetamroZ class_basesZ all_basesrbrPrcrd�resultrarNZhomeclsZget_objZdict_obj�excZlast_clsZsrch_clsZsrch_objr,�kindr r r �classify_class_attrsts�                    rxcCs|jSr)�__mro__)rhr r r rV�srV��stopcs|�durdd�}n �fdd�}|}t|�|i}t��}||�rx|j}t|�}||vs`t|�|krntd�|���|||<q6|S)NcSs t|d�S�N� __wrapped__�r�r(r r r � _is_wrapper�szunwrap.._is_wrappercst|d�o�|� Sr|r~rrzr r r�sz!wrapper loop when unwrapping {!r})�id�sys�getrecursionlimitr}�len� ValueError�format)�funcr{r�r(�memoZrecursion_limitZid_funcr rzr �unwrap�s    r�cCs|��}t|�t|���Sr)� expandtabsr��lstrip)�lineZexpliner r r � indentsizesr�cCsNtj�|j�}|durdS|j�d�dd�D]}t||�}q.t|�sJdS|S)N�.�����)r��modules�get� __module__� __qualname__�splitrLr)r�rhrNr r r � _findclasss r�c Cs t|�rR|jD]>}|turz |j}Wnty:YqYn0|dur|SqdSt|�r�|jj}|j}t|�r�t t ||d�d�|jur�|}n|j }�n$t |�r�|j}t |�}|dus�t ||�|ur�dSn�t |��r|j}|j}t|��r|jd||jk�r|}n|j }n�t|t��rN|j}|j}t |�}|du�sHt ||�|u�r�dSnnt|��sbt|��r�|j}|j}t ||�|u�r�dSt|��r�t |dd�}t|t��r�||v�r�||SndS|jD]D}zt ||�j}Wnt�y�Y�q�Yn0|du�r�|S�q�dS)Nr"r�� __slots__)rryr �__doc__r[rr"�__name__�__self__rL� __class__rr�rBr�rrk�fgetrrrjr�dict)r,rP�docrN�selfrhr��slotsr r r �_finddoc!sn     �   �        r�c Csdz |j}WntyYdS0|durNz t|�}WnttfyLYdS0t|t�s\dSt|�Sr)r�r[r�� TypeErrorr�str�cleandoc)r r�r r r �getdoc_s    r�cCs�z|���d�}Wnty&YdS0tj}|dd�D]*}t|���}|r:t|�|}t||�}q:|rz|d��|d<|tjkr�tdt|��D]}|||d�||<q�|r�|ds�|� �q�|r�|ds�|� d�q�d� |�SdS)N� �rr�) r�r�� UnicodeErrorr��maxsizer�r��min�range�pop�join)r��linesZmarginr�Zcontent�indent�ir r r r�rs&     (    r�cCs�t|�r(t|dd�r|jStd�|���t|�rht|d�rZtj� |j �}t|dd�rZ|jStd�|���t |�rv|j }t |�r�|j}t|�r�|j}t|�r�|j}t|�r�|jStd�t|�j���dS)N�__file__z{!r} is a built-in moduler�z{!r} is a built-in classzVmodule, class, method, function, traceback, frame, or code object was expected, got {})r rLr�r�r�rrr�r�r�r�rr"rr&r<�tb_framer>�f_coder@� co_filenamerr�)r �moduler r r �getfile�s.   �r�cCsTtj�|�}dd�tj��D�}|��|D]"\}}|�|�r,|d|�Sq,dS)NcSsg|]}t|� |f�qSr )r�)rg�suffixr r r � �s�z!getmodulename..)�os�path�basename� importlib� machinery� all_suffixesr]�endswith)r��fname�suffixesZneglenr�r r r � getmodulename�s �  r�cs�t|��tjjdd�}|tjjdd�7}t�fdd�|D��r`tj���dtjj d�nt�fdd�tjj D��r~dStj� ��r��St t |��dd�dur��S�tjvr��SdS)Nc3s|]}��|�VqdSr�r��rg�s��filenamer r ri�rSz getsourcefile..rc3s|]}��|�VqdSrr�r�r�r r ri�rS� __loader__)r�r�r��DEBUG_BYTECODE_SUFFIXES�OPTIMIZED_BYTECODE_SUFFIXES�anyr�r��splitext�SOURCE_SUFFIXES�EXTENSION_SUFFIXES�existsrL� getmodule� linecache�cache)r Zall_bytecode_suffixesr r�r � getsourcefile�s" � �  r�cCs,|durt|�pt|�}tj�tj�|��Sr)r�r�r�r��normcase�abspath)r � _filenamer r r � getabsfile�sr�c Cs�t|�r |St|d�r$tj�|j�S|durD|tvrDtj�t|�Szt||�}Wntt fyjYdS0|tvr�tj�t|�Stj� �� �D]\\}}t|�r�t|d�r�|j }|t �|d�kr�q�|t |<t|�}|jt|<ttj�|�<q�|tv�r tj�t|�Stjd}t|d��s$dSt||j��rLt||j�}||u�rL|Stjd}t||j��r~t||j�} | |u�r~|SdS)Nr�r��__main__r��builtins)r rr�r�r�r�� modulesbyfiler�r��FileNotFoundError�copyrKr��_filesbymodnamer�r�r��realpathrL) r r��file�modnamer�r(�mainZ mainobjectZbuiltinZ builtinobjectr r r r��sJ �  �        r�c@s eZdZdS)�ClassFoundExceptionN�r�r�r�r r r r r�sr�c@s(eZdZdd�Zdd�ZeZdd�ZdS)� _ClassFindercCsg|_||_dSr)�stack�qualname)r�r�r r r �__init__ sz_ClassFinder.__init__cCs<|j�|j�|j�d�|�|�|j��|j��dS)Nz)r�rZrN� generic_visitr��r��noder r r �visit_FunctionDefs    z_ClassFinder.visit_FunctionDefcCsb|j�|j�|jd�|j�krJ|jr4|jdj}n|j}|d8}t|��|�|�|j� �dS)Nr�rr�) r�rZrNr�r��decorator_list�linenor�r�r�)r�r�� line_numberr r r �visit_ClassDefs z_ClassFinder.visit_ClassDefN)r�r�r�r�r�Zvisit_AsyncFunctionDefr�r r r r r� sr�c Cs�t|�}|rt�|�n$t|�}|�d�r4|�d�szsource code not availablezcould not get source coder�zcould not find class definition�co_firstlinenoz"could not find function definitionr�z>^(\s*def\s)|(\s*async\s+def\s)|(.*(?r�r@rr��re�compile� IndexError�match) r r�r�r�r��sourceZtreeZ class_finder�er��lnum�patr�r r r � findsource)s`                   rc Cs,zt|�\}}Wnttfy(YdS0t|�r�d}|rR|ddd�dkrRd}|t|�krx||��dvrx|d}qR|t|�kr�||dd�dkr�g}|}|t|�kr�||dd�dkr�|�||���|d}q�d�|�S�n>|dk�r(t ||�}|d}|dk�r(||� �dd�dk�r(t ||�|k�r(||��� �g}|dk�r�|d}||��� �}|dd�dk�r�t ||�|k�r�|g|dd�<|d}|dk�r��q�||��� �}�qr|�r�|d��dk�r�g|dd�<�q�|�r|d��dk�rg|dd�<�q�d�|�SdS) Nr�z#!r�)r��#rr�r�) rr�r�r r��striprZr�r�r�r�)r r�r�startZcomments�endr�Zcommentr r r � getcommentsmsH      $� $r c@s eZdZdS)� EndOfBlockNr�r r r r r �rSr c@seZdZdd�Zdd�ZdS)� BlockFindercCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)NrFr�)r��islambda�started�passline� indecorator�decoratorhasargs�last� body_col0�r�r r r r��szBlockFinder.__init__cCsr|jsB|jsB|dkrd|_n|dvr8|dkr2d|_d|_d|_�n,|dkrZ|jrVd|_�n|dkrv|jrtd|_d|_n�|tjkr�d|_|d|_|jr�t�|jr�|js�d|_n�|jr�n�|tj kr�|j dur�|jr�|d |_ |j d |_ d|_n�|tj k�r|j d |_ |j dk�rnt�nV|tj k�rL|j du�rn|d |j k�rn|d|_n"|j dk�rn|tj tjfv�rnt�dS) N�@T)�def�class�lambdar�(�)Frr�)r rr rr�tokenize�NEWLINErr �INDENTrr��DEDENT�COMMENT�NL)r�r�tokenZsrowcolZerowcolr�r r r � tokeneater�sL              zBlockFinder.tokeneaterN)r�r�r�r�r!r r r r r �s r c CsTt�}z(t�t|�j�}|D]}|j|�qWnttfyDYn0|d|j�Sr) r r�generate_tokens�iter�__next__r!r �IndentationErrorr)r�Z blockfinder�tokensZ_tokenr r r �getblock�sr'cCsbt|�}t|�\}}t|�r"|j}t|�s>t|�rF|jjdkrF|dfSt||d��|dfSdS)Nzrr�) r�rr<r�r r>r��co_namer'�r r�rr r r �getsourcelines�s � �r*cCst|�\}}d�|�S)Nr�)r*r�r)r r r � getsource�s r+cCsRg}|jtdd�d�|D]2}|�||jf�||vr|�t||||��q|S)Nr�r�rT)r]rrZrM�walktree)�classes�children�parentr`�cr r r r,sr,FcCs�i}g}|D]d}|jr^|jD]>}||vr0g||<|||vrJ||�|�|r||vrqpqq ||vr |�|�q |D]}||vrv|�|�qvt||d�Sr)rMrZr,)r-�uniquer.�rootsr0r/r r r � getclasstrees     r3� Argumentszargs, varargs, varkwc Cs�t|�std�|���|j}|j}|j}t|d|��}t||||��}d}||7}d}|jt@rx|j|}|d}d}|jt @r�|j|}t ||||�S)Nz{!r} is not a code objectrr�) r@r�r�� co_varnames� co_argcount�co_kwonlyargcount�listr'� CO_VARARGS�CO_VARKEYWORDSr4) �corb�nargsZnkwargsr�� kwonlyargs�step�varargs�varkwr r r �getargs+s"    rA�ArgSpeczargs varargs keywords defaultscCsDtjdtdd�t|�\}}}}}}}|s.|r6td��t||||�S)Nzhinspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()r�� stacklevelzgFunction has keyword-only parameters or annotations, use inspect.signature() API which can support them)�warnings�warn�DeprecationWarning�getfullargspecr�rB)r�r�r?r@�defaultsr=�kwonlydefaults�annr r r � getargspecHs��rL� FullArgSpeczGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc Cszzt|ddtd�}Wn.tyB}ztd�|�WYd}~n d}~00g}d}d}g}g}i}d} i} |j|jurz|j|d<|j��D]�} | j} | j } | t ur�|� | �| j | jur�| | j f7} nv| t ur�|� | �| j | jur�| | j f7} nJ| tur�| }n<| tu�r(|� | �| j | ju�r6| j | | <n| tu�r6| }| j| jur�| j|| <q�| �sXd} | �sbd} t||||| || |�S)NF��follow_wrapper_chains�skip_bound_arg�sigclszunsupported callabler �return)�_signature_from_callable� Signatureror��return_annotation�empty� parameters�valuesrwrN�_POSITIONAL_ONLYrZ�default�_POSITIONAL_OR_KEYWORD�_VAR_POSITIONAL� _KEYWORD_ONLY� _VAR_KEYWORD� annotationrM)r��sig�exr�r?r@� posonlyargsr=� annotationsrI� kwdefaults�paramrwrNr r r rHis\�              �rH�ArgInfozargs varargs keywords localscCs t|j�\}}}t||||j�Sr)rAr�rf�f_locals)�framer�r?r@r r r � getargvalues�sricCsjt|dd�dkr t|��dd�St|tj�r4t|�St|t�rb|jd|fvrR|j S|jd|j St|�S)Nr��typingztyping.r�r�r�) rL�repr�replacerr� GenericAliasr�rr�r�)r_Z base_moduler r r �formatannotation�s  rncst|dd���fdd�}|S)Nr�cs t|��Sr)rn)r_�r�r r �_formatannotation�sz5formatannotationrelativeto.._formatannotation)rL)r rpr ror �formatannotationrelativeto�s  rqr cCsd|S�N�*r �rNr r r rR�rSrRcCsd|S�N�**r rtr r r rR�rScCs dt|�S�N�=�rk�rOr r r rR�rScCsd|S)Nz -> r )�textr r r rR�rSc s<ddlm} | dtdd����fdd�}g}|rBt|�t|�}t|�D]:\}}||�}|rz||krz|| |||�}|�|�qJ|dur�|�|||���n|r�|�d�|r�|D]2}||�}|r�||vr�|| ||�7}|�|�q�|du�r|�| ||���d d �|�d }d �v�r8|| ��d ��7}|S) Nr)rFzc`formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directlyrrCcs(�|�}|�vr$|d��|�7}|S)Nz: r )�argru�rcrn� formatargr r �formatargandannotation�sz-formatargspec..formatargandannotationrsr�, rrR)rErFrGr�� enumeraterZr�)r�r?r@rIr=rJrcr~� formatvarargs� formatvarkw� formatvalueZ formatreturnsrnrFr�specsZ firstdefaultr�r|�specZ kwonlyargrur r}r � formatargspec�s< �       r�cCsd|Srrr rtr r r rRrScCsd|Srur rtr r r rRrScCs dt|�Srwryrzr r r rR rSc Cs�|||fdd�}g} tt|��D]} | �||| ��q |rV| �||�|||��|rt| �||�|||��dd�| �dS)NcSs||�|||�Srr )rN�localsr~r�r r r �convert'sz formatargvalues..convertrr�r)r�r�rZr�) r�r?r@r�r~r�r�r�r�r�r�r r r �formatargvaluess � r�cs��fdd�|D�}t|�}|dkr,|d}n>|dkr@dj|�}n*dj|dd��}|dd�=d �|�|}td |||rzd nd |dkr�d nd|f��dS)Ncsg|]}|�vrt|��qSr ry)rgrN�rXr r r�4rSz&_missing_arguments..r�rrz {} and {}z , {} and {}�����r�z*%s() missing %i required %s argument%s: %s� positional� keyword-onlyr�r�)r�r�r�r�)�f_nameZargnames�posrXrb�missingr��tailr r�r �_missing_arguments3s    ��r�c s�t|�|}t�fdd�|D��}|r:|dk} d|f} n2|rTd} d|t|�f} nt|�dk} tt|��} d} |r�d} | |dkr�d nd||dkr�d ndf} td || | r�d nd|| |dkr�|s�d nd f��dS) Ncsg|]}|�vr|�qSr r )rgr|r�r r r�ErSz_too_many..r�z at 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)r�r�r�) r�r�Zkwonlyr?ZdefcountZgivenrXZatleastZ kwonly_given�pluralr`Z kwonly_sig�msgr r�r � _too_manyCs*    ���r�cOst|�}|\}}}}}} } |j} i} t|�rB|jdurB|jf|}t|�} t|�}|r^t|�nd}t| |�}t|�D]}||| ||<qt|r�t||d��| |<t||�}|r�i| |<|� �D]T\}}||vr�|s�t d| |f��|| ||<q�|| v�rt d| |f��|| |<q�| |k�r<|�s�s�z"getclosurevars..� __builtins__)�None�True�False)rr"rr�r�r&� __closure__�zip� co_freevars� __globals__r�r�rJr rW�co_names�KeyErrorr\r�) r��codeZ nonlocal_varsZ global_nsZ builtin_nsZ global_varsZ builtin_varsZ unbound_namesrNr r r �getclosurevars�s<   �   �r�� Tracebackz+filename lineno function code_context indexr�cCs�t|�r|j}|j}n|j}t|�s2td�|���t|�p@t|�}|dkr�|d|d}zt |�\}}Wnt y�d}}Yq�0t dt |t |�|��}||||�}|d|}nd}}t|||jj||�S)Nz'{!r} is not a frame or traceback objectrr�r)r<� tb_linenor��f_linenor>r�r�r�r�rr��maxr�r�r�r�r()rh�contextr�r�rr�r�indexr r r � getframeinfo�s$ r�cCs|jSr)r��rhr r r � getlineno�sr�� FrameInfor�cCs2g}|r.|ft||�}|�t|��|j}q|Sr)r�rZr��f_back)rhr�� framelist� frameinfor r r �getouterframes�s r�cCs4g}|r0|jft||�}|�t|��|j}q|Sr)r�r�rZr��tb_next)�tbr�r�r�r r r �getinnerframess r�cCsttd�rt�d�SdS)N� _getframer�)rr�r�r r r r � currentframe sr�cCstt�d�|�S)Nr�)r�r�r��r�r r r r�sr�cCstt��d|�S)Nr)r�r��exc_infor�r r r �tracesr�cCstjd�|�S)Nry)rrJr)�klassr r r �_static_getmrosr�cCs6i}zt�|d�}Wnty&Yn0t�||t�S�NrJ)r �__getattribute__r[r�r�� _sentinel)r,�attrZ instance_dictr r r �_check_instance s  r�c CsFt|�D]8}tt|��turz|j|WSty>Yq0qtSr)r��_shadowed_dictrr�rJr�)r�r��entryr r r � _check_class)s  r�cCs&z t|�Wnty YdS0dS�NFT)r�r�r+r r r �_is_type2s   r�c Csltjd}t|�D]T}z|�|�d}Wnty:Yq0t|�tjur^|jdkr^|j|us|Sqt Sr�) rrJr�rr�rrr�rjr�)r�� dict_attrr�Z class_dictr r r r�9s   �� r�c Cst}t|�s>t|�}t|�}|tus2t|�tjurBt||�}n|}t||�}|tur�|tur�tt|�d�tur�tt|�d�tur�|S|tur�|S|tur�|S||ur�tt|��D]8}tt|��tur�z|j |WSt y�Yq�0q�|tur�|St |��dS)Nrr) r�r�rr�rrr�r�r�rJr�r[)r,r�rZZinstance_resultr�r�Z klass_resultr�r r r �getattr_staticGs:  �  � r�� GEN_CREATED� GEN_RUNNING� GEN_SUSPENDED� GEN_CLOSEDcCs,|jr tS|jdurtS|jjdkr(tStS�Nr�)� gi_runningr��gi_framer��f_lastir�r�)� generatorr r r �getgeneratorstate|s   r�cCs:t|�std�|���t|dd�}|dur2|jjSiSdS)Nz{!r} is not a Python generatorr�)r3r�r�rLr�rg)r�rhr r r �getgeneratorlocals�s  r�� CORO_CREATED� CORO_RUNNING�CORO_SUSPENDED� CORO_CLOSEDcCs,|jr tS|jdurtS|jjdkr(tStSr�)� cr_runningr��cr_framer�r�r�r�)� coroutiner r r �getcoroutinestate�s   r�cCs"t|dd�}|dur|jSiSdS)Nr�)rLrg)r�rhr r r �getcoroutinelocals�s r�� from_bytescCs6zt||�}Wnty"YdS0t|t�s2|SdSr)rLr[r�_NonUserDefinedCallables)rhZ method_name�methr r r �"_signature_get_user_defined_method�s   r�c Cs�|j}t|���}|jpd}|jp$i}|r2||}z|j|i|��}Wn8ty~}z d�|�} t| �|�WYd}~n d}~00d} |��D]�\} } z|j | } Wnt y�Ynl0| j t ur�|� | �q�| j tu�r| |vr�d} | j| d�|| <n|� | j�q�| j tu�r | j| d�|| <| r�| j tu�rT|| jtd�}||| <|�| �q�| j ttfv�rp|�| �q�| j tur�|� | j�q�|j|��d�S)Nr z+partial object {!r} has incorrect argumentsFT)rZ�rw�rW)rWrrKr��keywords� bind_partialr�r�r�� argumentsr�rwrYr�r[rlrNr]� move_to_endr^r\rX)� wrapped_sig�partial� extra_argsZ old_params� new_paramsZ partial_argsZpartial_keywordsZbarar�Ztransform_to_kwonly� param_namereZ arg_valueZ new_paramr r r �_signature_get_partial�sL                r�cCslt|j���}|r$|djttfvr,td��|dj}|ttfvrP|dd�}n|t ur`td��|j |d�S)Nrzinvalid method signaturer�zinvalid argument typer�) rnrWrXrwr^r]r�r[rYr\rl)r`�paramsrwr r r �_signature_bound_method0s  r�cCs&t|�p$t|�p$t|t�p$|ttfvSr)rBrrr�rr r+r r r �_signature_is_builtinJs�� �r�cCs�t|�rt|�rdSt|dd�}t|dd�}t|dt�}t|dt�}t|dd�}t|tj�o�t|t�o�|dusxt|t�o�|dus�t|t �o�t|t �S)NFr�r&� __defaults__�__kwdefaults__�__annotations__) �callablerrL�_voidrrr?r�rnr�)r,rNr�rIrdrcr r r �_signature_is_functionlikeVs       ����r�cCs<|�d�}|dkr|�d�}|�d�}|�d�}|d|�S)N�,r�r�:rxr)�find)r�r�Zcposr r r �_signature_get_bound_paramos    rcCs |s|ddfSd}d}dd�|�d�D�}t|�j}t�|�}d}d}g}|j} d} tj} tj} t|�} |D]�} | j | j }}|| kr�|dkr�|r�d}qld}| d7} ql|d kr�d}| d}ql|| kr�|d kr�| }ql|r�d}|| kr�|d ks�| d �| |�|dkrl| d �qld� |�}|||fS)NcSsg|]}|�d��qS)�ascii)�encode)rg�lr r r r��rSz6_signature_strip_non_python_syntax..r�Frr�Tr��/�$rr�� r�) r�r#r$rrZr �OP� ERRORTOKEN�nextr�stringr�)� signature�self_parameter�last_positional_onlyr�r�Z token_streamZ delayed_commaZskip_next_commar{r\Zcurrent_parameterrr �trr �clean_signaturer r r �"_signature_strip_non_python_syntax�sP      rTc s^ddl�|j�t|�\}}}d|d}z��|�}WntyLd}Yn0t|�j�shtd�|���|j d} g��j �t ��d}i�t |dd�} | r�t j�| d�}|r�|j�t j��� �fdd����� fdd �� G�� fd d �d �j���f��������fd d � } t| jj�} t| jj�} tj| | dd�}|du�rH�j�n�j�ttt|���D](\}\}}| ||�||k�r^�j��q^| jj�r��j�| | jj���j�t| jj | jj!�D]\}}| ||��q�| jj"�r�j#�| | jj"��|du�rPt |dd�}|du}t$|�}|�r6|�s*|�r6��%d�n�dj&�jd�} | �d<|�|j d�S)Nrzdef fooz: passz"{!r} builtin has invalid signaturer�cs|jdurtd��|jS)Nz'Annotations are not currently supported)r_r�r|)r�)r�r r � parse_name�s z&_signature_fromstr..parse_namec sxzt|��}Wn:tyHzt|��}WntyBt��Yn0Yn0t|tttttt d�f�rn�� |�St��dSr) �eval� NameError� RuntimeErrorrr��int�float�bytesr%rZConstant)r�rO)r�� module_dict�sys_module_dictr r � wrap_value�s   z&_signature_fromstr..wrap_valuecs(eZdZ��fdd�Z��fdd�ZdS)z,_signature_fromstr..RewriteSymbolicscs\g}|}t|�j�r(|�|j�|j}qt|�j�s:t��|�|j�d�t |��}�|�S)Nr�) rrfrZr�rO�Namerr�r��reversed)r�r��ar�rO�r�rr r �visit_Attributes    z<_signature_fromstr..RewriteSymbolics.visit_Attributecst|j�j�st���|j�Sr)r�ctxZLoadr�r�r�rr r � visit_Namesz7_signature_fromstr..RewriteSymbolics.visit_NameN)r�r�r�r r"r rr r �RewriteSymbolicss r#cs��|�}|�urdS|rn|turnz���|�}��|�}WntyP�}Yn0|�ur^dS|�urj|n|}���|�|�d��dS�N�rZr_)�_emptyr�Z literal_evalr�rZ)Z name_nodeZ default_noderZrN�o)� Parameterr#r�rV�invalidrwrWrr r �ps    z_signature_fromstr..p)� fillvaluer�r��rU)'r��_parameter_clsrr�� SyntaxErrorrZModuler�r��bodyrVr rLr�r�r�rJr�ZNodeTransformerrr�rI� itertools� zip_longest�POSITIONAL_ONLY�POSITIONAL_OR_KEYWORDr�r8�vararg�VAR_POSITIONAL� KEYWORD_ONLYr�r=� kw_defaultsr�� VAR_KEYWORDr r�rl)rhr,r�rPrr rZprogramr�r(� module_namer*r�rIr#r�rNrZZ_selfZ self_isboundZ self_ismoduler ) r(r#r�rVr)rwrrWrrrr �_signature_fromstr�sn�                    r:cCsBt|�std�|���t|dd�}|s4td�|���t||||�S)Nz%{!r} is not a Python builtin function�__text_signature__z#no signature found for builtin {!r})r�r�r�rLr�r:)rhr�rPr�r r r �_signature_from_builtinXs� r<c CsHd}t|�s(t|�rd}ntd�|���t|dd�}|rFt||||�S|j}|j}|j}|j }|j } |d|�} |j } |||| �} |j } |j }|j}|r�t|�}nd}g}||}| }| d|�D]<}|r�tnt}| �|t�}|�||||d��|r�|d8}q�t| |d��D]L\}}|�r&tnt}| �|t�}|�||||||d��|�r|d8}�q|jt@�r�||| }| �|t�}|�|||td��| D]B}t}|du�r�|�|t�}| �|t�}|�|||t|d���q�|jt@�r2|| }|jt@�r |d7}||}| �|t�}|�|||td��||| �d t�|d �S) NFTr�r;r)r_rwr�)r_rwrZrR�rU�__validate_parameters__)rr�r�r�rLr:r-r&r6r5�co_posonlyargcountr7r�r�r�r�rYr[r�r&rZr�r'r9r\r]r:r^)rhr�rPZis_duck_functionr�r(Z func_code� pos_count� arg_namesZ posonly_countr�Zkeyword_only_countZ keyword_onlyrcrIrdZpos_default_countrWZnon_default_countZ posonly_leftrNrwr_�offsetrZr�r r r �_signature_from_functionhs�      �   �     �    �     � �rC)rOrPc Cs�tjt|||d�}t|�s(td�|���t|tj�rN||j �}|rJt |�S|S|rvt |dd�d�}t|tj�rv||�Sz |j }Wnt y�Yn&0|dur�t|t�s�td�|���|Sz |j}Wnt y�Ynn0t|tj��rB||j�}t||d�}t|j���d}|jtju�r|St|j���} |f| } |j| d �St|��sVt|��rdt|||d �St|��r|t|||d �St|tj��r�||j�}t||�Sd}t|t��r�t t|�d �} | du�r�|| �}nld} t |d �} t |d �}d |j!v�r�| } n0d |j!v�r |} n| du�r| } n|du�r*|} | du�r<|| �}|du�r@|j"dd�D]<}z |j#}Wnt �yvYn0|�rTt$|||�S�qTt|j"v�r@|j%t&j%u�r�|j't&j'u�r�|�(t&�St)d�|���nlt|t*��s@t t|�d �} | du�r@z || �}Wn:t)�y>}z d�|�}t)|�|�WYd}~n d}~00|du�r\|�rXt |�S|St|tj+��r|d�|�}t)|��t)d�|���dS)NrNz{!r} is not a callable objectcSs t|d�S)N� __signature__r~rr r r rR�rSz*_signature_from_callable..rzz1unexpected object {!r} in __signature__ attributerrr�)rP�__call__�__new__r�r�z(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),r#r�rSr�r�r�rrrr"r�r�rDr[rT�_partialmethod� partialmethodr�r�rnrWrXrwr(r5rlrr�rCr�r<rr�rJryr;r:r�r rF� from_callabler�r�rA)r,rOrPrQZ_get_signature_ofr`rHr�Zfirst_wrapped_paramZ sig_paramsr��callZfactory_method�new�initrPZtext_sigrar�r r r rS�s� �      ��      � �                � �       rSc@s eZdZdS)r�Nr�r r r r r�} sr�c@s eZdZdS)r&Nr�r r r r r&� sr&c@s4eZdZdZdZdZdZdZdd�Ze dd ��Z d S) �_ParameterKindrr�r��cCs|jSr)�_name_rr r r �__str__� sz_ParameterKind.__str__cCst|Sr)�_PARAM_NAME_MAPPINGrr r r � description� sz_ParameterKind.descriptionN) r�r�r�r2r3r5r6r8rQrkrSr r r r rM� srMzpositional-onlyzpositional or keywordzvariadic positionalr�zvariadic keywordc@s�eZdZdZeZeZeZ e Z e Z eZeed�dd�Zdd�Zdd�Zed d ��Zed d ��Zed d��Zedd��Zeeeed�dd�Zdd�Zdd�Zdd�Zdd�ZdS)r()�_name�_kind�_default� _annotationr%cCszt|�|_Wn"ty0td|�d���Yn0|turb|jttfvrbd}|�|jj�}t|��||_||_ |tur~td��t |t �s�d�t |�j �}t|��|ddkr�|dd���r�|jtkr�d }|�|jj�}t|��t|_d �|dd��}|���std �|���||_dS) Nzvalue z is not a valid Parameter.kindz({} parameters cannot have default valuesz*name is a required attribute for Parameterzname must be a str, not a {}rr�r�zLimplicit arguments must be passed as positional or keyword arguments, not {}z implicit{}z"{!r} is not a valid parameter name)rMrUr�r&r\r^r�rSrVrWrr�rr�r��isdigitr[rY� isidentifierrT)r�rNrwrZr_r�r r r r�� s6   � zParameter.__init__cCs t|�|j|jf|j|jd�fS)N�rVrW)rrTrUrVrWrr r r � __reduce__� s  ��zParameter.__reduce__cCs|d|_|d|_dS)NrVrWrZ�r��stater r r � __setstate__� s zParameter.__setstate__cCs|jSr)rTrr r r rN� szParameter.namecCs|jSr)rVrr r r rZ� szParameter.defaultcCs|jSr)rWrr r r r_� szParameter.annotationcCs|jSr)rUrr r r rw szParameter.kind)rNrwr_rZcCsL|tur|j}|tur|j}|tur*|j}|tur8|j}t|�||||d�Sr$)r�rTrUrWrVr)r�rNrwr_rZr r r rl szParameter.replacecCs�|j}|j}|jtur(d�|t|j��}|jturb|jturPd�|t|j��}nd�|t|j��}|tkrtd|}n|t kr�d|}|S)Nz{}: {}z{} = {}z{}={}rsrv) rwrTrWr&r�rnrVrkr\r^)r�rw� formattedr r r rQ s �   zParameter.__str__cCsd�|jj|�S)Nz <{} "{}">�r�r�r�rr r r �__repr__, szParameter.__repr__cCst|j|j|j|jf�Sr)�hashrNrwr_rZrr r r �__hash__/ szParameter.__hash__cCsJ||ur dSt|t�stS|j|jkoH|j|jkoH|j|jkoH|j|jkS�NT)rr(�NotImplementedrTrUrVrW�r��otherr r r �__eq__2 s   � � �zParameter.__eq__N)r�r�r�r�rYr2r[r3r\r5r]r6r^r8r&rVr�r[r^rkrNrZr_rwr�rlrQrarcrhr r r r r(� s2(    � r(c@sdeZdZdZdd�Zedd��Zedd��Zedd ��Zd d �Z d d �Z dd�Z dd�Z dd�Z dS)�BoundArguments)r�� _signature� __weakref__cCs||_||_dSr)r�rj)r�r r�r r r r�P szBoundArguments.__init__cCs|jSr)rjrr r r r T szBoundArguments.signaturec Cs|g}|jj��D]b\}}|jttfvr*qtz|j|}WntyPYqtYq0|jtkrh|� |�q|� |�qt |�Sr) rjrWrKrwr^r]r�r�r\�extendrZrn)r�r�r�rer|r r r r�X s     zBoundArguments.argsc Cs�i}d}|jj��D]v\}}|sD|jttfvr4d}n||jvrDd}q|sJqz|j|}WntyjYq0|jtkr�|�|�q|||<q|Sr�) rjrWrKrwr^r]r�r��update)r��kwargsZkwargs_startedr�rer|r r r rno s&     zBoundArguments.kwargsc Cs�|j}g}|jj��D]v\}}z|�|||f�Wqty�|jturT|j}n$|jt urdd}n|jt urti}nYq|�||f�Yq0qt |�|_dS)Nr ) r�rjrWrKrZr�rZr&rwr\r^r�)r�r�Z new_argumentsrNre�valr r r �apply_defaults� s     zBoundArguments.apply_defaultscCs2||ur dSt|t�stS|j|jko0|j|jkSrd)rrirer r�rfr r r rh� s   �zBoundArguments.__eq__cCs|d|_|d|_dS)Nrjr��rjr�r\r r r r^� s zBoundArguments.__setstate__cCs|j|jd�S)Nrqrqrr r r � __getstate__� szBoundArguments.__getstate__cCs@g}|j��D]\}}|�d�||��qd�|jjd�|��S)Nz{}={!r}z <{} ({})>r�)r�rKrZr�r�r�r�)r�r�r|rOr r r ra� szBoundArguments.__repr__N)r�r�r�r�r�rkr r�rnrprhr^rrrar r r r ri= s   ric@s�eZdZdZeZeZeZ d+edd�dd�Z e dd��Z e d d ��Z e dd �d d ��Zedd��Zedd��Zeed�dd�Zdd�Zdd�Zdd�Zdd�dd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS),rT)�_return_annotation� _parametersNTr=c Cs�|durt�}n�|r�t�}t}d}|D]�}|j}|j} ||kr\d} | �|j|j�} t| ��n||krld}|}|ttfvr�|jt ur�|r�d} t| ��nd}| |vr�d�| �} t| ��||| <q&ntdd�|D��}t � |�|_ ||_ dS)NFz7wrong parameter order: {} parameter before {} parameterz-non-default argument follows default argumentTzduplicate parameter name: {!r}css|]}|j|fVqdSrrt�rgrer r r ri rSz%Signature.__init__..)rrYrwrNr�rSr�r[rZr&r�MappingProxyTypertrs) r�rWrUr>r�Ztop_kindZ kind_defaultsrerwrNr�r r r r�� s@��       zSignature.__init__cCstjdtdd�t||�S)Nz_inspect.Signature.from_function() is deprecated since Python 3.5, use Signature.from_callable()rrC)rErFrGrC�rhr�r r r � from_function s�zSignature.from_functioncCstjdtdd�t||�S)Nz^inspect.Signature.from_builtin() is deprecated since Python 3.5, use Signature.from_callable()rrC)rErFrGr<rwr r r � from_builtin s�zSignature.from_builtin��follow_wrappedcCst|||d�S)N)rQrO)rS)rhr,r{r r r rI+ s�zSignature.from_callablecCs|jSr)rtrr r r rW1 szSignature.parameterscCs|jSr�rsrr r r rU5 szSignature.return_annotation)rWrUcCs0|tur|j��}|tur |j}t|�||d�S)Nr,)r�rWrXrsr)r�rWrUr r r rl9 s �zSignature.replacecCs8tdd�|j��D��}dd�|j��D�}|||jfS)Ncss|]}|jtkr|VqdSr)rwr]rur r r riI s �z(Signature._hash_basis..cSsi|]}|jtkr|j|�qSr )rwr]rNrur r r r�L s �z)Signature._hash_basis..)rnrWrXrU)r�r�� kwo_paramsr r r � _hash_basisH szSignature._hash_basiscCs(|��\}}}t|���}t|||f�Sr)r~� frozensetrXrb)r�r�r}rUr r r rcQ s zSignature.__hash__cCs*||ur dSt|t�stS|��|��kSrd)rrTrer~rfr r r rhV s  zSignature.__eq__F�r�c Cs�i}t|j���}d}t|�}z t|�}Wn�t�yz t|�} Wnty`YY�q�Yn�0| jtkrtY�q�n�| j|vr�| jtkr�d} | j | jd�} t | �d�| f}Y�q�nP| jt ks�| j t ur�| f}Y�q�n.|r�| f}Y�q�nd} | j | jd�} t | �d�Yq0z t|�} Wnt�y2t d�d�Yq0| jt tfv�rNt d�d�| jtk�r||g} | �|�t| �|| j<�q�| j|v�r�| jtk�r�t dj | jd��d�||| j<qd} t�||�D]�} | jt k�r�| } �q�| jtk�r�q�| j} z|�| �}WnDt�yD|�s@| jtk�r@| j t u�r@t dj | d��d�Yn(0| jtk�rdt dj | jd���||| <�q�|�r�| du�r�||| j<nt dj tt|��d���|�||�S)Nr zA{arg!r} parameter is positional only, but was passed as a keyword)r|z$missing a required argument: {arg!r}ztoo many positional argumentsz$multiple values for argument {arg!r}z*got an unexpected keyword argument {arg!r})r#rWrXr � StopIterationrwr\rNrYr�r�r^rZr&r]rlrnr0�chainr�r��_bound_arguments_cls)r�r�rnr�r�rWZ parameters_exZarg_valsZarg_valrer�rXZ kwargs_paramr�r r r �_bind] s�        � ��  ���   ��� �    ��zSignature._bindcOs |�||�Sr�r��r�r�rnr r r �bind� szSignature.bindcOs|j||dd�S)NTr�r�r�r r r r�� szSignature.bind_partialcCs t|�t|j���fd|jifS�Nrs)rrnrtrXrsrr r r r[� s�zSignature.__reduce__cCs|d|_dSr�r|r\r r r r^� szSignature.__setstate__cCsd�|jj|�S)Nz<{} {}>r`rr r r ra� szSignature.__repr__c Cs�g}d}d}|j��D]d}t|�}|j}|tkr6d}n|rH|�d�d}|tkrVd}n|tkrp|rp|�d�d}|�|�q|r�|�d�d�d� |��}|j t ur�t |j �}|d�|�7}|S)NFTrrsz({})r�z -> {}) rWrXr�rwrYrZr\r]r�r�rUr&rn) r�ruZrender_pos_only_separatorZrender_kw_only_separatorrer_rwZrenderedZannor r r rQ� s0       zSignature.__str__)N)r�r�r�r�r(r-rir�r&rVr�rsrxryrIrkrWrUr�rlr~rcrhr�r�r�r[r^rarQr r r r rT� s:� 6     rTrzcCstj||d�S)Nrz)rTrI)r,r{r r r r ' sr c Cs�ddl}ddl}|��}|jddd�|jddddd �|��}|j}|�d �\}}}z|�|�}} WnPty�} z8d � |t | �j | �} t | t jd �t �d �WYd} ~ n d} ~ 00|r�|�d�} | }| D]} t|| �}q�| j t jv�rt dt jd �t �d�|j�r�t d� |��t d� t| ���t d� | j��|| u�rzt d� t| j���t| d��r�t d� | j��n4zt|�\}}Wnt�y�Yn0t d� |��t d�n t t|��dS)Nrr zCThe object to be analysed. It supports the 'module:qualname' syntax)�helpz-dz --details� store_truez9Display info about the module rather than its source code)�actionr�r�zFailed to import {} ({}: {}))r�rr�z#Can't get info for builtin modules.r�z Target: {}z Origin: {}z Cached: {}z Loader: {}�__path__zSubmodule search path: {}zLine: {}r�)�argparser��ArgumentParser� add_argument� parse_argsr � partition� import_moduleror�rr��printr��stderr�exitr�rL�builtin_module_names�detailsr�� __cached__rkr�rr�rr+)r�r��parserr��target�mod_nameZ has_attrs�attrsr,r�rvr��parts�part�__r�r r r �_main, s\���       r�r�)N)N)N)F)N)r�)r�)r�)r�)r�)r )T)T)T)�� __author__r8r��dis�collections.abcr7�enum�importlib.machineryr�r0r�r�r�r�rr rrEr#r��operatorrrr�globalsZmod_dictZCOMPILER_FLAG_NAMESrKrcrdrGr rrrrrrr rr*r-r.r/r1r3r5r:r<r>r@rBrCrQrerfrxrVr�r�r�r�r�r�r�r�r�r�r�r�r�ror�Z NodeVisitorr�rr r r r'r*r+r,r3r4rArBrLrMrHrfrirnrqr�r�r�r�r�r�r�r�r�r�r��_fieldsr�r�r�r�r�r�r r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrEZ_WrapperDescriptor�allZ_MethodWrapperrrJZ_ClassMethodWrapperrAr�r�r�r�r�r�rrr:r<rCrSr�r&�IntEnumrMr2rYr3r[r5r\r6r]r8r^rRr(rirTr r�r�r r r r �sp            , t$ >   /D->     �\  � ;� < 5        0  � L H   _� 8� j: