U e5dÏã @sŽdZdZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlmZddlmZmZeƒZej ¡D]\ZZeede<q´dZdd „Zd d „Z d d „Z!dd„Z"dd„Z#e$edƒ�r dd„Z%ndd„Z%e$edƒ�r*dd„Z&ndd„Z&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-„Z0d.d/„Z1d0d1„Z2d2d3„Z3d4d5„Z4d6d7„Z5dôd8d9„Z6ed:d;ƒZ7dd?„Z9dd@œdAdB„Z:dCdD„Z;dEdF„ZdKdL„Z?dMdN„Z@dOdP„ZAdQdR„ZBdõdSdT„ZCiZDiZEdödUdV„ZFdWdX„ZGdYdZ„ZHGd[d\„d\eIƒZJGd]d^„d^ƒZKd_d`„ZLdadb„ZMdcdd„ZNdedf„ZOd÷dhdi„ZPedjdkƒZQdldm„ZRedndoƒZSdpdq„ZTedrdsƒZUdtdu„ZVedvdwƒZWdxdy„ZXdødzd{„ZYd|d}„ZZdddd~iie[dd€„d�d€„d‚d€„dƒd€„eYf d„d…„Z\e[d†d€„d‡d€„dˆd€„fd‰dŠ„Z]d‹dŒ„Z^d�dŽ„Z_d�d�„Z`ed‘d’ƒZad“d”„Zbed•d–ƒZcdùd˜d™„Zddšd›„Zeedœd�ecjfƒZgdúdždŸ„Zhdûd d¡„Zid¢d£„Zjdüd¤d¥„Zkdýd¦d§„ZlemƒZnd¨d©„Zodªd«„Zpd¬d­„Zqd®d¯„Zrd°d±„Zsenfd²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‹dþdÇdÈ„ZŒdÉdÊ„Z�dËdÌ„ZŽdÍd΄Z�dÏdЄZ�dÑdÒ„Z‘dÿdÔ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(aGet 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 getargvalues(), getcallargs() - get info about function arguments getfullargspec() - same, with support for Python 3 features 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 z'Yury Selivanov éN)Ú attrgetter)Ú namedtupleÚ OrderedDictZCO_icCs t|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 ú/usr/lib64/python3.8/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Útyperr r r ÚisclassHsrcCs t|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Ú MethodTyperr r r ÚismethodPsrcCs:t|ƒst|ƒst|ƒrdSt|ƒ}t|dƒo8t|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 Útpr r r ÚismethoddescriptorZsrcCs8t|ƒst|ƒst|ƒrdSt|ƒ}t|dƒp6t|dƒS)a}Return true if the object is a data descriptor. Data descriptors have a __set__ or a __delete__ 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.FrÚ __delete__rrr r r ÚisdatadescriptornsrÚMemberDescriptorTypecCs t|tjƒS)ú�Return true if the object is a member descriptor. Member descriptors are specialized descriptors defined in extension modules.)rrrrr r r Úismemberdescriptor~srcCsdS)rFr rr r r r†sÚGetSetDescriptorTypecCs t|tjƒS)ú�Return true if the object is a getset descriptor. getset descriptors are specialized descriptors defined in extension modules.)rrrrr r r Úisgetsetdescriptor�sr cCsdS)rFr rr r r r —scCs t|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Ú FunctionTyperr r r ržs rcCs6t|ƒr|j}qt |¡}t|ƒs&dSt|jj|@ƒS)z¤Return true if ``f`` is a function (or a method or functools.partial wrapper wrapping a function) whose code object has the given ``flag`` set in its flags.F)rÚ__func__Ú functoolsÚ_unwrap_partialrÚboolÚ__code__Úco_flags)ÚfÚflagr r r Ú_has_code_flag«s  r*cCs t|tƒ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.)r*Z CO_GENERATOR©Úobjr r r Úisgeneratorfunction¶sr-cCs t|tƒS)zuReturn true if the object is a coroutine function. Coroutine functions are defined with "async def" syntax. )r*Z CO_COROUTINEr+r r r Úiscoroutinefunction½sr.cCs t|tƒS)z¿Return true if the object is an asynchronous generator function. Asynchronous generator functions are defined with "async def" syntax and have "yield" expressions in their body. )r*ZCO_ASYNC_GENERATORr+r r r ÚisasyncgenfunctionÄsr/cCs t|tjƒS)z7Return true if the object is an asynchronous generator.)rrÚAsyncGeneratorTyperr r r Ú isasyncgenÌsr1cCs t|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Ú GeneratorTyperr r r Ú isgeneratorÐsr3cCs t|tjƒS)z)Return true if the object is a coroutine.)rrÚ CoroutineTyperr r r Ú iscoroutineásr5cCs6t|tjƒp4t|tjƒr(t|jjt@ƒp4t|tj j ƒS)z?Return true if object can be passed to an ``await`` expression.) rrr4r2r%Úgi_coder'ZCO_ITERABLE_COROUTINEÚ collectionsÚabcÚ Awaitablerr r r Ú isawaitableås   þ ýr:cCs t|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Ú TracebackTyperr r r Ú istracebackìsr<cCs t|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Ú FrameTyperr r r Úisframeös r>cCs t|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 | 512=async_generator co_freevars tuple of names of free variables co_posonlyargcount number of positional only arguments 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ÚCodeTyperr r r Úiscodesr@cCs t|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ÚBuiltinFunctionTyperr r r Ú isbuiltinsrBcCs t|ƒpt|ƒpt|ƒpt|ƒS)zdS|j  ¡D]\}}t |ddƒrHdSqH|j D]6}t |ddƒD]$}t ||dƒ}t |ddƒrzdSqzqjdS)z:Return true if the object is an abstract base class (ABC).FTÚ__abstractmethods__Ú__isabstractmethod__r N) 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 k r|YnX|D]~} zt || ƒ} | |kržt ‚Wn:t k rÚ|D]}| |jkr´|j| } qÖq´Yq‚YnX|rè|| ƒrö|  | | f¡|  | ¡q‚|jdd„d�|S)zŠReturn all members of an object as (name, value) pairs sorted by name. Optionally, only return members that satisfy a given predicate.r cSs|dS)Nrr )Zpairr r r Únózgetmembers..©Úkey)rÚgetmroÚsetÚdirrMrJrKrrÚDynamicClassAttributeÚappendÚAttributeErrorrLÚaddÚsort) r Z predicateÚmroÚresultsÚ processedÚnamesrPÚkÚvrUrOr r r Ú getmembersEs:        rdÚ Attributezname kind defining_class objectc CsTt|ƒ}tt|ƒƒ}tdd„|Dƒƒ}|f|}||}t|ƒ}|D].}|j ¡D]\}}t|tjƒrR|  |¡qRqDg} t ƒ} |D�]Ê} d} d} d}| | k�rzz| dkr°t dƒ‚t || ƒ} Wn"t k rÞ}zW5d}~XYnœXt | d| ƒ} | |k�rzd} d}|D] }t || dƒ}|| k�r|}�q|D]B}z|  || ¡}Wntk �rXY�q(YnX|| k�r(|}�q(|dk �rz|} |D]0}| |jk�r~|j| }| |k�r¦|} �q°�q~| dk�r¼q‚| dk �rÊ| n|}t|ttjfƒ�rêd}|}nFt|ttjfƒ�rd}|}n*t|tƒ�rd }|}nt|ƒ�r,d }nd }|   t| || |ƒ¡|  | ¡q‚| 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|]}|ttfkr|VqdS©N)r r )Ú.0Úclsr r r Ú �s z'classify_class_attrs..NrJz)__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ÚClassMethodDescriptorTyperkrCrer\)rhr^ZmetamroZ class_basesZ all_basesrarPrbrcÚresultr`rNZhomeclsZget_objZdict_objÚexcZlast_clsZsrch_clsZsrch_objr,Úkindr r r Úclassify_class_attrsss€                    rxcCs|jS)zHReturn tuple of base classes (including cls) in method resolution order.)Ú__mro__)rhr r r rVçsrV©Ústopcs|ˆdkrdd„}n ‡fdd„}|}t|ƒ|i}t ¡}||ƒrx|j}t|ƒ}||ks`t|ƒ|krntd |¡ƒ‚|||<q6|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©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(ZmemoZrecursion_limitZid_funcr rzr Úunwrapís    rˆcCs| ¡}t|ƒt| ¡ƒS)zBReturn the indent size, in spaces, at the start of a line of text.)Ú expandtabsr„Úlstrip)ÚlineZexpliner r r Ú indentsizesrŒcCsNtj |j¡}|dkrdS|j d¡dd…D]}t||ƒ}q.t|ƒsJdS|S)NÚ.éÿÿÿÿ)r‚ÚmodulesÚgetÚ __module__Ú __qualname__ÚsplitrLr)r‡rhrNr r r Ú _findclasss r”c Cst|ƒrT|jD]@}|tk rz |j}Wntk r<YqYnX|dk r|SqdSt|ƒrš|jj}|j}t|ƒr�t t ||dƒdƒ|jkr�|}n|j }�n$t |ƒrÌ|j}t |ƒ}|dksÆt ||ƒ|k rÊdSnòt |ƒ�r|j}|j}t|ƒ�r|jd||jk�r|}n|j }n®t|tƒ�rP|j}|j}t |ƒ}|dk�sJt ||ƒ|k �r¾dSnnt|ƒ�sdt|ƒ�rº|j}|j}t ||ƒ|k �r„dSt|ƒ�r¾t |ddƒ}t|tƒ�r¾||k�r¾||SndS|jD]F}zt ||ƒj}Wntk �rôY�qÄYnX|dk �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 Cshz |j}Wntk r YdSX|dkrRz t|ƒ}Wnttfk rPYdSXt|tƒs`dSt|ƒ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–r[rŸÚ TypeErrorrÚstrÚcleandoc)r rœr r r Úgetdoc^s   r£cCsêz| ¡ d¡}Wntk r(YdSXtj}|dd…D]*}t| ¡ƒ}|rÚf_coder@Ú co_filenamer r—)r Úmoduler r r ÚgetfileŽs.   þr´cCsTtj |¡}dd„tj ¡Dƒ}| ¡|D]"\}}| |¡r,|d|…Sq,dS)z1Return the module name for a given file, or None.cSsg|]}t|ƒ |f‘qSr )r„)rgÚsuffixr r r Ú ¬sÿz!getmodulename..N)ÚosÚpathÚbasenameÚ importlibÚ machineryÚ all_suffixesr]Úendswith)r¸ZfnameÚ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ƒ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|]}ˆ |¡VqdSrf©r½©rgÚs©Úfilenamer r ri»sz getsourcefile..rc3s|]}ˆ |¡VqdSrfrÀrÁrÃr r ri¾sÚ __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,|dkrt|ƒpt|ƒ}tj tj |¡¡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 Ú _filenamer r r Ú getabsfileÊsrÔc Cs€t|ƒr |St|dƒr$tj |j¡S|dk rD|tkrDtj t|¡Szt||ƒ}Wntk rhYdSX|tkr‚tj t|¡Stj  ¡  ¡D]\\}}t|ƒr�t|dƒr�|j }|t  |d¡krÂq�|t |<t|ƒ}|j t|<ttj |¡<q�|tk�rtj t|¡Stjd}t|dƒ�s"dSt||j ƒ�rJt||j ƒ}||k�rJ|Stjd}t||j ƒ�r|t||j ƒ} | |k�r||SdS)zAReturn the module an object was defined in, or None if not found.r‘Nr¯Ú__main__r—Úbuiltins)r rr‚r�r�r‘Ú modulesbyfilerÔr ÚcopyrKr¯Ú_filesbymodnamer—r·r¸ÚrealpathrL) r rÓÚfileÚmodnamer³r(ÚmainZ mainobjectZbuiltinZ builtinobjectr r r rÍÖsJ ÿ  ÿ        rÍc Csøt|ƒ}|rt |¡n$t|ƒ}| d¡r4| d¡szsource code not availablezcould not get source coderz^(\s*)class\s*z\bÚcr¥zcould not find class definitionÚco_firstlinenoz"could not find function definitionz>^(\s*def\s)|(\s*async\s+def\s)|(.*(?r±r@rráÚ IndexError) r rÛr³r¬rNZpatZ candidatesr®rèÚlnumr‹r r r Ú findsourcesf                 rìc Cs.zt|ƒ\}}Wnttfk r*YdSXt|ƒrìd}|rT|ddd…dkrTd}|t|ƒkrz|| ¡dkrz|d}qT|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Ð|| ¡  ¡}�qt|�rø|d ¡dk�røg|dd…<�qÐ|�r |d  ¡dk�r g|d d…<�qød |¡SdS) zwGet lines of comments immediately preceding an object's source code. Returns None when source can't be found. Nréz#!r¥)Úú#rïrîrŽ) rìrär r r„ÚstriprZr‰r«rŒrŠ)r r¬rëÚstartZcommentsÚendr­Zcommentr r r Ú getcommentsRsL      $ÿ $ róc@s eZdZdS)Ú EndOfBlockN)r—r‘r’r r r r rôsrôc@s eZdZdZdd„Zdd„ZdS)Ú BlockFinderz@Provide a tokeneater() method to detect the end of a code block.cCs4d|_d|_d|_d|_d|_d|_d|_d|_dS)NrFr¥)r­ÚislambdaÚstartedÚpasslineÚ indecoratorÚdecoratorhasargsÚlastÚ body_col0©r�r r r Ú__init__ƒszBlockFinder.__init__cCsr|jsB|jsB|dkrd|_n|dkr8|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 dkrÚ|jrÚ|d |_ |j d |_ d|_n€|tj k�r|j d |_ |j dk�rnt‚nV|tj k�rL|j dk �rn|d |j k�rn|d|_n"|j dk�rn|tj tjfk�rnt‚dS) Nú@T)ÚdefÚclassÚlambdarú(ú)Frr¥)r÷rùrörørúÚtokenizeÚNEWLINErûrôÚINDENTrür­ÚDEDENTÚCOMMENTÚNL)r�r ÚtokenZsrowcolZerowcolr‹r r r Ú tokeneater�sL              zBlockFinder.tokeneaterN)r—r‘r’r–rþr r r r r rõ�s rõc CsVtƒ}z(t t|ƒj¡}|D]}|j|ŽqWnttfk rFYnX|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¬Z blockfinderÚtokensZ_tokenr r r Úgetblock¿srcCsbt|ƒ}t|ƒ\}}t|ƒr"|j}t|ƒs>t|ƒrF|jjdkrF|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.zrNr¥) rˆrìr<r°r r>r±Úco_namer©r r¬rër r r ÚgetsourcelinesÊs ÿ ÿrcCst|ƒ\}}d |¡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î)rr«rr r r Ú getsourceßs rcCsRg}|jtddƒd�|D]2}| ||jf¡||kr| t||||ƒ¡q|S)z-Recursive helper function for getclasstree().r‘r—rT)r]rrZrMÚwalktree)ÚclassesÚchildrenÚparentr_ràr r r résrFcCsši}g}|D]d}|jr^|jD]>}||kr0g||<|||krJ|| |¡|r||krqpqq ||kr | |¡q |D]}||krv| |¡qvt||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)rMrZr)rÚuniquerÚrootsràrr r r Ú getclasstreeós"      rÚ 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)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.z{!r} is not a code objectNrr¥) r@r r†Ú co_varnamesÚ co_argcountÚco_kwonlyargcountÚlistr'Ú CO_VARARGSÚCO_VARKEYWORDSr) ÚcoraÚnargsZnkwargsÚargsÚ kwonlyargsÚstepÚvarargsÚvarkwr r r Úgetargss"    r,ÚArgSpeczargs varargs keywords defaultscCsDtjdtdd�t|ƒ\}}}}}}}|s.|r6tdƒ‚t||||ƒS)aeGet the names and default values of a function's parameters. 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 ** parameters or None. 'defaults' is an n-tuple of the default values of the last n parameters. This function is deprecated, as it does not support annotations or keyword-only parameters and will raise ValueError if either is present on the supplied callable. For a more structured introspection API, use inspect.signature() instead. Alternatively, use getfullargspec() for an API with a similar namedtuple based interface, but full support for annotations and keyword-only parameters. Deprecated since Python 3.5, use `inspect.getfullargspec()`. zhinspect.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…r-)r‡r'r*r+Údefaultsr(ÚkwonlydefaultsÚannr r r Ú getargspec-sþÿr7Ú FullArgSpeczGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc Cs|zt|ddtd�}Wn,tk r@}ztdƒ|‚W5d}~XYnXg}d}d}g}g}d}i} d}i} |j|jk r||j| d<|j ¡D]È} | j} | j } | t krÂ|  | ¡| j | jk rÀ|| j f7}nv| t krî|  | ¡| j | jk rì|| j f7}nJ| tkrü| }n<| tk�r*|  | ¡| j | jk �r8| j | | <n| tk�r8| }| j| jk r†| j| | <q†| �sZd} |�sdd}t||||||| | ƒS)a$Get the names and default values of a callable object's parameters. A tuple of seven things is returned: (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations). 'args' is a list of the parameter names. 'varargs' and 'varkw' are the names of the * and ** parameters or None. 'defaults' is an n-tuple of the default values of the last n parameters. 'kwonlyargs' is a list of keyword-only parameter names. 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults. 'annotations' is a dictionary mapping parameter names to annotations. Notable differences from inspect.signature(): - the "self" parameter is always reported, even for bound methods - wrapper chains defined by __wrapped__ *not* unwrapped automatically F©Úfollow_wrapper_chainsÚskip_bound_argÚsigclszunsupported callableNr Úreturn)Ú_signature_from_callableÚ Signatureror Úreturn_annotationÚemptyÚ parametersÚvaluesrwrNÚ_POSITIONAL_ONLYrZÚdefaultÚ_POSITIONAL_OR_KEYWORDÚ_VAR_POSITIONALÚ _KEYWORD_ONLYÚ _VAR_KEYWORDÚ annotationr8)r‡ÚsigÚexr'r*r+Z posonlyargsr(r4Ú annotationsÚ kwdefaultsÚparamrwrNr r r r3Nsbý             ÿr3Ú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±rPÚf_locals)Úframer'r*r+r r r Ú getargvalues­srScCsVt|ddƒdkr t|ƒ dd¡St|tƒrN|jd|fkr>|jS|jd|jSt|ƒS)Nr‘Útypingztyping.rîrÖr�)rLÚreprÚreplacerr r‘r’)rJZ base_moduler r r Úformatannotation·s rWcst|ddƒ‰‡fdd„}|S)Nr‘cs t|ˆƒSrf)rW)rJ©r³r r Ú_formatannotationÂsz5formatannotationrelativeto.._formatannotation)rL)r rYr rXr ÚformatannotationrelativetoÀs  rZr cCsd|S©NÚ*r ©rNr r r rRÉrSrRcCsd|S©Nú**r r]r r r rRÊrScCs dt|ƒS©Nú=©rU©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|dk r¢| |||ƒƒ¡n|r°| d ¡|rì|D]2}||ƒ}|rà||krà|| ||ƒ7}| |¡q¸|dk �r| | ||ƒƒ¡d d  |¡d }d ˆk�r8|| ˆˆd ƒƒ7}|S)a÷Format an argument spec from the values returned by 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. Deprecated since Python 3.5: use the `signature` function and `Signature` objects. r)r1zc`formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directlyrír.cs(ˆ|ƒ}|ˆkr$|dˆˆ|ƒ7}|S)Nz: r )Úargru©rMrWÚ formatargr r Úformatargandannotationász-formatargspec..formatargandannotationNr\rú, rr=)r0r1r2r„Ú enumeraterZr«)r'r*r+r4r(r5rMrgÚ formatvarargsÚ formatvarkwÚ formatvalueZ formatreturnsrWr1rhÚspecsZ firstdefaultr®reÚspecZ kwonlyargrur rfr Ú formatargspecÆs< ý       rpcCsd|Sr[r r]r r r rRrScCsd|Sr^r r]r r r rRrScCs dt|ƒSr`rbrcr r r rRrSc Cs†|||fdd„}g} tt|ƒƒD]} |  ||| ƒ¡q |rV|  ||ƒ|||ƒ¡|rt|  ||ƒ|||ƒ¡dd | ¡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||ƒ|||ƒSrfr )rNÚlocalsrgrmr r r Úconvert sz formatargvalues..convertrrir)r©r„rZr«) r'r*r+rqrgrkrlrmrrrnr®r r r Úformatargvaluess ÿ rscs˜‡fdd„|Dƒ}t|ƒ}|dkr,|d}n>|dkr@dj|Ž}n*dj|dd…Ž}|dd…=d  |¡|}td |||rzd nd |dkrˆd nd|fƒ‚dS)Ncsg|]}|ˆkrt|ƒ‘qSr rb)rgrN©rCr r r¶sz&_missing_arguments..r¥rríz {} and {}z , {} and {}éþÿÿÿriz*%s() missing %i required %s argument%s: %sÚ positionalú keyword-onlyrîrÂ)r„r†r«r )Úf_nameZargnamesÚposrCraÚmissingrÂÚtailr rtr Ú_missing_argumentss     þÿ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|]}|ˆkr|‘qSr r )rgrertr r r¶)sz_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 ) rxr'Zkwonlyr*ZdefcountZgivenrCZatleastZ kwonly_givenZpluralrKZ kwonly_sigÚmsgr rtr Ú _too_many's*    ÿÿÿr~cOst|ƒ}|\}}}}}} } |j} i} t|ƒrB|jdk rB|jf|}t|ƒ} t|ƒ}|r^t|ƒnd}t| |ƒ}t|ƒD]}||| ||<qt|r¢t||d…ƒ| |<t||ƒ}|rºi| |<|  ¡D]T\}}||krô|sæt d| |fƒ‚|| ||<qÂ|| k�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 Úgetclosurevarszs>   þ ÿ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 k r†d}}YqÆXt dt |t |ƒ|ƒƒ}||||…}|d|}nd}}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 objectrr¥ríN)r<Ú tb_linenor°Úf_linenor>r r†rÐr´rìräÚmaxr¨r„r”r±r)rRÚcontextÚlinenorÄrñr¬rëÚindexr r r Ú getframeinfo±s$r›cCs|jS)zCGet the line number from a frame object, allowing for optimization.)r–©rRr r r Ú getlinenoÑsr�Ú FrameInforœcCs2g}|r.|ft||ƒ}| t|Ž¡|j}q|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.)r›rZržÚf_back)rRr˜Ú framelistÚ frameinfor r r ÚgetouterframesØs r¢cCs4g}|r0|jft||ƒ}| t|Ž¡|j}q|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°r›rZržÚtb_next)Útbr˜r r¡r r r Úgetinnerframesäs r¥cCsttdƒrt d¡SdS)z?Return the frame of the caller or None if this is not possible.Ú _getframer¥N)rr‚r¦r r r r Ú currentframeðsr§cCstt d¡|ƒS)z@Return a list of records for the stack above the caller's frame.r¥)r¢r‚r¦©r˜r r r Ústackôsr©cCstt ¡d|ƒS)zCReturn a list of records for the stack below the current exception.rí)r¥r‚Úexc_infor¨r r r Útraceøsr«cCstjd |¡S)Nry)r rJr)Úklassr r r Ú_static_getmrosr­cCs8i}zt |d¡}Wntk r(YnXt ||t¡S©NrJ)r Ú__getattribute__r[r›r�Ú _sentinel)r,ÚattrZ instance_dictr r r Ú_check_instances r²c CsHt|ƒD]:}tt|ƒƒtkrz|j|WStk r@YqXqtSrf)r­Ú_shadowed_dictr r°rJr‘)r¬r±Úentryr r r Ú _check_class s rµcCs(z t|ƒWntk r"YdSXdS©NFT)r­r r+r r r Ú_is_types  r·c Csntjd}t|ƒD]V}z| |¡d}Wntk r<YqXt|ƒtjkr`|jdkr`|j|ks|Sqt Sr®) r rJr­rr‘rrr—rjr°)r¬Ú dict_attrr´Z class_dictr r r r³s  ÿþ r³c Cst}t|ƒs>t|ƒ}t|ƒ}|tks2t|ƒtjkrBt||ƒ}n|}t||ƒ}|tk r„|tk r„tt|ƒdƒtk r„tt|ƒdƒtk r„|S|tk r�|S|tk rœ|S||krìtt|ƒƒD]:}tt|ƒƒtkr°z|j |WSt k rèYq°Xq°|tk rø|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·r r³rrr²rµr­rJr‘r[)r,r±rEZinstance_resultr¬r¸Z klass_resultr´r r r Úgetattr_static+s:  ÿ  ÿr¹Ú GEN_CREATEDÚ GEN_RUNNINGÚ GEN_SUSPENDEDÚ GEN_CLOSEDcCs,|jr tS|jdkrtS|jjdkr(tStS)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. NrŽ)Ú gi_runningr»Úgi_framer½Úf_lastirºr¼)Ú generatorr r r Úgetgeneratorstate`s   rÂcCs:t|ƒstd |¡ƒ‚t|ddƒ}|dk r2|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)r3r r†rLr¿rQ)rÁrRr r r Úgetgeneratorlocalsrs  rÃÚ CORO_CREATEDÚ CORO_RUNNINGÚCORO_SUSPENDEDÚ CORO_CLOSEDcCs,|jr tS|jdkrtS|jjdkr(tStS)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. NrŽ)Ú cr_runningrÅÚcr_framerÇrÀrÄrÆ)Ú coroutiner r r ÚgetcoroutinestateŠs   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)rLrQ)rÊrRr r r Úgetcoroutinelocalsœs rÌÚ from_bytescCs8zt||ƒ}Wntk r$YdSXt|tƒs4|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)rLr[rÚ_NonUserDefinedCallables)rhZ method_nameZmethr r r Ú"_signature_get_user_defined_method¸s  rÏc Cs’|j}t| ¡ƒ}|jpd}|jp$i}|r2||}z|j||Ž}Wn6tk rx}zd |¡} t| ƒ|‚W5d}~XYnXd} | ¡D]ú\} } z|j | } Wnt k r°YnjX| j t krÈ|  | ¡q†| j tkrþ| |krðd} | j| d�|| <n|  | j¡q†| j tk�r| j| d�|| <| r†| j tk�rN|| jtd�}||| <| | ¡q†| j ttfk�rj| | ¡q†| j tkr†|  | j¡q†|j| ¡d�S) z‘Private helper to calculate how 'wrapped_sig' signature will look like after applying a 'functools.partial' object (or alike) on it. r z+partial object {!r} has incorrect argumentsNFT)rE©rw©rB)rBrrKr'ÚkeywordsÚ bind_partialr r†r…Ú argumentsr‘rwrDrªrFrVrNrHÚ move_to_endrIrGrC)Ú wrapped_sigÚpartialZ extra_argsZ old_paramsÚ new_paramsZ partial_argsZpartial_keywordsZbarLr}Ztransform_to_kwonlyÚ param_namerOZ arg_valueZ new_paramr r r Ú_signature_get_partialÈsL              rÚcCslt|j ¡ƒ}|r$|djttfkr,tdƒ‚|dj}|ttfkrP|dd…}n|t k r`tdƒ‚|j |d�S)zWPrivate helper to transform signatures for unbound functions to bound methods. rzinvalid method signaturer¥Nzinvalid argument typerÑ) rnrBrCrwrIrHr…rFrDrGrV)rKÚparamsrwr r r Ú_signature_bound_methods  rÜcCs&t|ƒp$t|ƒp$t|tƒp$|ttfkS)zxPrivate helper to test if `obj` is a callable that might support Argument Clinic's __text_signature__ protocol. )rBrrrÎr r r+r r r Ú_signature_is_builtin.sÿþ ûrÝcCs”t|ƒrt|ƒrdSt|ddƒ}t|ddƒ}t|dtƒ}t|dtƒ}t|ddƒ}t|tjƒo’t|tƒo’|dksxt|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__) ÚcallablerrLÚ_voidrrr?r¡rnr›)r,rNr’r4rNrMr r r Ú_signature_is_functionlike:s       ÿþýürãcCs<| d¡}|dkr| d¡}| d¡}| d¡}|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. ú,rŽrú:rarí)Úfind)roryZcposr r r Ú_signature_get_bound_paramSs    rçcCs |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}| d 7} ql|d kr¼d}| d }ql|| krÒ|d krÒ| }ql|ròd}|| krê|d ksò| d ƒ| |ƒ|dkrl| dƒqld  |¡}|||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|]}| d¡‘qS)Úascii)Úencode)rgÚlr r r r¶}sz6_signature_strip_non_python_syntax..r¤FrräTr¥ú/ú$rriú rî) r“rrrrZr ÚOPÚ ERRORTOKENÚnextr Ústringr«)Ú signatureÚself_parameterÚlast_positional_onlyr¬rÁZ token_streamZ delayed_commaZskip_next_commardr\Zcurrent_parameterrîrïÚtr rñÚclean_signaturer r r Ú"_signature_strip_non_python_syntaxjsP      r÷Tc s`ddl‰|j‰t|ƒ\}}}d|d}zˆ |¡}Wntk rNd}YnXt|ˆjƒsjtd |¡ƒ‚|j d} g‰ˆj ‰t ƒ‰d}i‰t |ddƒ} | r´t j | d¡}|r´|j‰t j ¡‰ ‡fdd„‰‡‡‡ fd d „‰ G‡‡ fd d „d ˆjƒ‰ˆf‡‡‡‡‡‡‡‡fd d„ } t| jjƒ} t| jjƒ} tj| | dd�}|dk �rJˆj‰nˆj‰ttt|ƒƒƒD](\}\}}| ||ƒ||k�r`ˆj‰�q`| jj�r¨ˆj‰| | jjˆƒˆj‰t| jj | jj!ƒD]\}}| ||ƒ�qÀ| jj"�rôˆj#‰| | jj"ˆƒ|dk �rRt |ddƒ}|dk }t$|ƒ}|�r8|�s,|�r8ˆ %d¡nˆdj&ˆjd�} | ˆd<|ˆ|j d�S)zdPrivate helper to parse content of '__text_signature__' and return a Signature based on it. rNzdef fooz: passz"{!r} builtin has invalid signaturer‘cs|jdk rtdƒ‚|jS)Nz'Annotations are not currently supported)rJr…re)Únode)Úastr r Ú parse_nameØs z&_signature_fromstr..parse_namec s|zt|ˆƒ}Wn>tk rLzt|ˆƒ}Wntk rFtƒ‚YnXYnXt|tttttt dƒfƒrrˆ  |¡Stƒ‚dSrf) ÚevalÚ NameErrorÚ RuntimeErrorrr¡ÚintÚfloatÚbytesr%r ZConstant)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�) rrerZr±rOÚNamerýr�r«Úreversed)r�røÚarrO©rùrr r Úvisit_Attributeìs    z<_signature_fromstr..RewriteSymbolics.visit_Attributecst|jˆjƒstƒ‚ˆ|jƒSrf)rZctxZLoadr…r�)r�rørr r Ú visit_Nameøsz7_signature_fromstr..RewriteSymbolics.visit_NameN)r—r‘r’rr r rr r ÚRewriteSymbolicsës r csŠˆ|ƒ}|ˆkrdS|rp|tk rpzˆƒ |¡}ˆ |¡}Wntk rRˆ}YnX|ˆkr`dS|ˆk rl|n|}ˆ ˆ|ˆ|ˆd�¡dS)N©rErJ)Ú_emptyZvisitZ literal_evalr…rZ)Z name_nodeZ default_noderErNÚo)Ú Parameterr rùrAÚinvalidrwrBrúr r Úpýs   z_signature_fromstr..p)Ú fillvaluer˜rЩr@)'rùÚ_parameter_clsr÷ÚparseÚ SyntaxErrorrZModuler…r†ZbodyrAr rLr‚r�r�rJrØZNodeTransformerrr'r4Ú itertoolsÚ zip_longestÚPOSITIONAL_ONLYÚPOSITIONAL_OR_KEYWORDrjr"ZvarargÚVAR_POSITIONALÚ KEYWORD_ONLYr�r(Z kw_defaultsr�Ú VAR_KEYWORDr rªrV)rhr,rÂr;rörórôZprogramr³r(Z module_namerr'r4rr®rNrEZ_selfZ self_isboundZ self_ismoduler ) rr rùrArrwrrBrúrrr Ú_signature_fromstr²snÿ                   rcCsBt|ƒstd |¡ƒ‚t|ddƒ}|s4td |¡ƒ‚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 r†rLr…r)rhr‡r;rÂr r r Ú_signature_from_builtin<sÿ rc 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}|dk �r¼| |t¡}|  |t¡}| |||t|d �¡�qž|jt@�r2|| }|jt@�r |d7}||}|  |t¡}| |||td�¡|||  d t¡|d �S) zCPrivate helper: constructs Signature for the given python function.FTr„rNr)rJrwr¥)rJrwrEr=©r@Ú__validate_parameters__)rrãr r†rLrrr&r rÚco_posonlyargcountr!ràrÞrßr„rDrFr�r rZrjr'r#rGrHr$rI)rhr‡r;Zis_duck_functionrÂrZ func_codeZ pos_countZ arg_namesZ posonly_countrvZkeyword_only_countZ keyword_onlyrMr4rNZpos_default_countrBZnon_default_countZ posonly_leftrNrwrJÚoffsetrEršr r r Ú_signature_from_functionLsŒ      ÿ   þ     ÿ    þ     ÿ þr$)r:r;c CsŽt|ƒstd |¡ƒ‚t|tjƒrDt|j|||d�}|r@t|ƒS|S|rtt |dd„d�}t|tjƒrtt||||d�Sz |j }Wnt k r’Yn&X|dk r¸t|t ƒs´td |¡ƒ‚|Sz |j }Wnt k rÖYnvXt|tjƒ�rLt|j|||d�}t||dƒ}t|j ¡ƒd }|jtjk�r(|St|j ¡ƒ}|f|} |j| d �St|ƒ�s`t|ƒ�rnt|||d �St|ƒ�r†t|||d �St|tjƒ�r°t|j|||d�}t||ƒSd}t|tƒ�rÎt t|ƒd ƒ} | dk �rêt| |||d�}nJt |d ƒ} | dk �rt| |||d�}n$t |dƒ} | dk �r4t| |||d�}|dk�r@|j!dd…D]>} z | j"}Wnt k �rpYnX|�rLt#|||ƒS�qLt|j!k�r@|j$t%j$k�r¾|j&t%j&k�r¾| 't%¡St(d |¡ƒ‚nrt|t)ƒ�s@t t|ƒd ƒ} | dk �r@zt| |||d�}Wn8t(k �r>}zd |¡}t(|ƒ|‚W5d}~XYnX|dk �r\|�rXt|ƒS|St|tj*ƒ�r|d |¡}t(|ƒ‚t(d |¡ƒ‚dS)zQPrivate helper function to get signature for arbitrary callable objects. z{!r} is not a callable objectr9cSs t|dƒS)NÚ __signature__r~rr r r rRÆrSz*_signature_from_callable..rzNz1unexpected object {!r} in __signature__ attributerfrrÑ)r;Ú__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 r†rrrr>r"rÜrˆr%r[r?Ú_partialmethodr#Ú partialmethodr‡rÚrnrBrCrwrrrVrrãr$rÝrr×r rÏryrrrþr r'Ú from_callabler…rÎrA)r,r:r;r<rKr)rÖZfirst_wrapped_paramZ sig_paramsrØZcallÚnewZinitrPZtext_sigrLr}r r r r>ªs  ü ü  ÿÿ ü   ÿ ÿü   ü  ü  ü    ÿ ÿ  ü    r>c@seZdZdZdS)râz1A private marker - used in Parameter & Signature.N©r—r‘r’r–r r r r rât srâc@seZdZdZdS)r z6Marker object for Signature.empty and Parameter.empty.Nr,r r r r r x sr c@s4eZdZdZdZdZdZdZdd„Ze dd „ƒZ d S) Ú_ParameterKindrr¥ríéécCs|jSrf)Ú_name_rýr r r Ú__str__ƒ sz_ParameterKind.__str__cCst|Srf)Ú_PARAM_NAME_MAPPINGrýr r r Ú description† sz_ParameterKind.descriptionN) r—r‘r’rrrrrr1rkr3r r r r r-| sr-zpositional-onlyzpositional or keywordzvariadic positionalrwzvariadic keywordc@s°eZdZdZdZeZeZe Z e Z e ZeZeedœdd„Zdd„Zdd „Zed d „ƒZed d „ƒZedd„ƒZedd„ƒZeeeedœdd„Zdd„Zdd„Zdd„Zdd„ZdS)raRepresents 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 cCszt|ƒ|_Wn$tk r2td|›d�ƒ‚YnX|tk rd|jttfkrdd}| |jj¡}t|ƒ‚||_||_ |tkr€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)r-r5r…r rGrIr†r3r6r7rr¡r r—r ÚisdigitrFrDÚ isidentifierr4)r�rNrwrErJr}r r r rþ¹ s6  ÿ zParameter.__init__cCs t|ƒ|j|jf|j|jdœfS)N©r6r7)r r4r5r6r7rýr r r Ú __reduce__á s  ÿþzParameter.__reduce__cCs|d|_|d|_dS)Nr6r7r:©r�Ústater r r Ú __setstate__ç s zParameter.__setstate__cCs|jSrf)r4rýr r r rNë szParameter.namecCs|jSrf)r6rýr r r rEï szParameter.defaultcCs|jSrf)r7rýr r r rJó szParameter.annotationcCs|jSrf)r5rýr r r rw÷ szParameter.kind)rNrwrJrEcCsL|tkr|j}|tkr|j}|tkr*|j}|tkr8|j}t|ƒ||||d�S)z+Creates a customized copy of the Parameter.r )râr4r5r7r6r )r�rNrwrJrEr r r rVû szParameter.replacecCsˆ|j}|j}|jtk r(d |t|jƒ¡}|jtk rb|jtk rPd |t|jƒ¡}nd |t|jƒ¡}|tkrtd|}n|t kr„d|}|S)Nz{}: {}z{} = {}z{}={}r\r_) rwr4r7r r†rWr6rUrGrI)r�rwÚ formattedr r r r1 s ÿ   zParameter.__str__cCsd |jj|¡S)Nz <{} "{}">©r†r™r—rýr r r Ú__repr__# szParameter.__repr__cCst|j|j|j|jfƒSrf)ÚhashrNrwrJrErýr r r Ú__hash__& szParameter.__hash__cCsJ||kr dSt|tƒstS|j|jkoH|j|jkoH|j|jkoH|j|jkS©NT)rrÚNotImplementedr4r5r6r7©r�Úotherr r r Ú__eq__) s   ÿ þ ýzParameter.__eq__N)r—r‘r’r–r•rDrrFrrGrrHrrIrr rArþr;r>rkrNrErJrwrârVr1rArCrHr r r r r™ s6(    ÿ rc@sheZdZdZdZdd„Zedd„ƒZedd„ƒZed d „ƒZ d d „Z d d„Z dd„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||_||_dSrf)rÔrJ)r�ròrÔr r r rþG szBoundArguments.__init__cCs|jSrf)rJrýr r r ròK szBoundArguments.signaturec Cs~g}|jj ¡D]d\}}|jttfkr*qvz|j|}Wntk rRYqvYqX|jtkrj|  |¡q|  |¡qt |ƒSrf) rJrBrKrwrIrHrÔr‘rGÚextendrZrn)r�r'rÙrOrer r r r'O s    zBoundArguments.argsc Cs’i}d}|jj ¡D]x\}}|sD|jttfkr4d}n||jkrDd}q|sJqz|j|}Wntk rlYqX|jtkr„| |¡q|||<q|Sr¶) rJrBrKrwrIrHrÔr‘Úupdate)r�ÚkwargsZkwargs_startedrÙrOrer r r rNf s&    zBoundArguments.kwargsc Csž|j}g}|jj ¡D]x\}}z| |||f¡Wqtk rŒ|jtk rV|j}n$|jt krfd}n|jt krvi}nYq| ||f¡YqXqt |ƒ|_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. r N) rÔrJrBrKrZr‘rEr rwrGrIr)r�rÔZ new_argumentsrNrOÚvalr r r Úapply_defaults„ s    zBoundArguments.apply_defaultscCs2||kr 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)NrQrQrýr r r Ú __getstate__¬ szBoundArguments.__getstate__cCs@g}|j ¡D]\}}| d ||¡¡qd |jjd |¡¡S)Nz{}={!r}z <{} ({})>ri)rÔrKrZr†r™r—r«)r�r'rerOr r r rA¯ szBoundArguments.__repr__N)r—r‘r’r–r•rþrkròr'rNrPrHr>rRrAr r r r rI4 s   rIc@sÚeZdZdZdZeZeZe Z d,e ddœdd„Z e dd „ƒZ e d d „ƒZe dd œd d„ƒZedd„ƒZedd„ƒZeedœdd„Zdd„Zdd„Zdd„Zddœdd„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Ú _parametersNTr c Csî|dkrtƒ}nÈ|rÆtƒ}t}d}t|ƒD]˜\}}|j} |j} | |krdd} |  |j| j¡} t| ƒ‚n| |krtd}| }| ttfkr |j t krœ|r d} t| ƒ‚nd}| |krºd | ¡} t| ƒ‚||| <q*ntdd„|Dƒƒ}t   |¡|_ ||_dS) z„Constructs Signature from the given list of Parameter objects and 'return_annotation'. All arguments are optional. NFz7wrong parameter order: {} parameter before {} parameterz-non-default argument follows default argumentTzduplicate parameter name: {!r}css|]}|j|fVqdSrfr]©rgrOr r r ri sÿz%Signature.__init__..)rrDrjrwrNr†r3r…rFrEr rÚMappingProxyTyperTrS) r�rBr@r!rÛZtop_kindZ kind_defaultsÚidxrOrwrNr}r r r rþÔ sDÿÿ      ÿ zSignature.__init__cCstjdtdd�t||ƒS)zƒConstructs Signature for the given python function. Deprecated since Python 3.5, use `Signature.from_callable()`. z_inspect.Signature.from_function() is deprecated since Python 3.5, use Signature.from_callable()rír.)r0r1r2r$©rhr‡r r r Ú from_function s þzSignature.from_functioncCstjdtdd�t||ƒS)z„Constructs Signature for the given builtin function. Deprecated since Python 3.5, use `Signature.from_callable()`. z^inspect.Signature.from_builtin() is deprecated since Python 3.5, use Signature.from_callable()rír.)r0r1r2rrXr r r Ú from_builtin s þzSignature.from_builtin©Úfollow_wrappedcCst|||d�S)z3Constructs Signature for the given callable object.)r<r:)r>)rhr,r\r r r r*# sÿzSignature.from_callablecCs|jSrf)rTrýr r r rB) szSignature.parameterscCs|jSrf©rSrýr r r r@- szSignature.return_annotation)rBr@cCs0|tkr|j ¡}|tkr |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ârBrCrSr )r�rBr@r r r rV1 s ÿzSignature.replacecCs8tdd„|j ¡Dƒƒ}dd„|j ¡Dƒ}|||jfS)Ncss|]}|jtkr|VqdSrf)rwrHrUr r r riA s ÿz(Signature._hash_basis..cSsi|]}|jtkr|j|“qSr )rwrHrNrUr r r r‡D s ÿz)Signature._hash_basis..)rnrBrCr@)r�rÛÚ kwo_paramsr r r Ú _hash_basis@ szSignature._hash_basiscCs(| ¡\}}}t| ¡ƒ}t|||fƒSrf)r_Ú frozensetrCrB)r�rÛr^r@r r r rCI s zSignature.__hash__cCs*||kr dSt|tƒstS| ¡| ¡kSrD)rr?rEr_rFr r r rHN s  zSignature.__eq__F©r×c Csºtƒ}t|j ¡ƒ}d}t|ƒ}z t|ƒ}Wnàtk �r z t|ƒ} Wntk rfYY�q¼Yn¢X| jtkrzY�q¼nŽ| j|kr¸| jt krªd} | j | jd�} t | ƒd‚| f}Y�q¼nP| jt ksÌ| j tk rÚ| f}Y�q¼n.|rì| f}Y�q¼nd} | j | jd�} t | ƒd‚Yq Xz t|ƒ} Wn tk �r:t dƒd‚Yq X| jt tfk�rVt dƒd‚| jtk�r„|g} |  |¡t| ƒ|| j<�q¼| j|k�r°| jt k�r°t dj | jd�ƒd‚||| j<q d} t ||¡D]¬} | jt k�rä| } �qÌ| jtk�rô�qÌ| j} z| | ¡}WnFtk �rN|�sJ| jtk�rJ| j tk�rJt dj | d�ƒd‚Yn(X| jt k�rnt dj | jd�ƒ‚||| <�qÌ|�r®| dk �r–||| j<nt dj tt|ƒƒd�ƒ‚| ||¡S) z#Private method. Don't use directly.r zA{arg!r} parameter is positional only, but was passed as a keyword)reNz$missing a required argument: {arg!r}ztoo many positional argumentsz$multiple values for argument {arg!r}z*got an unexpected keyword argument {arg!r})rrrBrCrðÚ StopIterationrwrGrNrDr†r rIrEr rHrLrnrÚchainrªr‘Ú_bound_arguments_cls)r�r'rNr×rÔrBZ parameters_exZarg_valsZarg_valrOr}rCZ kwargs_paramrÙr r r Ú_bindU s°       ÿ ÿÿ  ÿÿþ   ÿÿÿ þ    ÿÿzSignature._bindcOs | ||¡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. ©re©r�r'rNr r r ÚbindØ szSignature.bindcOs|j||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. Trarfrgr r r rÓß szSignature.bind_partialcCs t|ƒt|j ¡ƒfd|jifS©NrS)r rnrTrCrSrýr r r r;æ sþzSignature.__reduce__cCs|d|_dSrir]r<r r r r>ë szSignature.__setstate__cCsd |jj|¡S)Nz<{} {}>r@rýr 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 k r¼t |j ƒ}|d |¡7}|S)NFTrër\z({})riz -> {}) rBrCr¡rwrDrZrGrHr†r«r@r rW) r�ruZrender_pos_only_separatorZrender_kw_only_separatorrOr?rwZrenderedZannor r r r1ñ s0       zSignature.__str__)N)r—r‘r’r–r•rrrIrdr rArþrsrYrZr*rkrBr@rârVr_rCrHrerhrÓr;r>rAr1r r r r r?¶ s<ÿ 7     r?r[cCstj||d�S)z/Get a signature object for the passed callable.r[)r?r*)r,r\r r r rò sròc CsÈddl}ddl}| ¡}|jddd�|jdddd d �| ¡}|j}| d ¡\}}}z| |¡}} WnNtk r¶} z0d   |t | ƒj | ¡} t | t jd �t  d¡W5d} ~ XYnX|rÞ| d¡} | }| D]} t|| ƒ}qÎ| j t jk�rt dt jd �t  d¡|j�r¸t d  |¡ƒt d  t| ƒ¡ƒt d  | j¡ƒ|| k�rxt d  t| jƒ¡ƒt| dƒ�r®t d  | j¡ƒn6zt|ƒ\}}Wntk �ržYnXt d  |¡ƒt dƒn t t|ƒƒdS)z6 Logic for inspecting an object given at command line rNr 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)ÚactionrjråzFailed to import {} ({}: {}))rÛrír�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†r r—Úprintr‚ÚstderrÚexitr“rLÚbuiltin_module_namesZdetailsrÐÚ __cached__rUrÅrrmrìr)rnrºÚparserr'ÚtargetZmod_nameZ has_attrsÚattrsr,r³rvr}ÚpartsÚpartÚ__r™r r r Ú_main$ s`þþþ      rrÕ)N)N)N)F)N)r¥)r¥)r¥)r¥)r¥)r )T)T)T)«r–Ú __author__r8ÚdisZcollections.abcr7ÚenumÚimportlib.machineryrºrrÎr·rær‚rr rr0r#rÖÚoperatorrrrÚglobalsZmod_dictZCOMPILER_FLAG_NAMESrKrbrcrGr rrrrrrr rr*r-r.r/r1r3r5r:r<r>r@rBrCrQrdrerxrVrˆrŒr”rŸr£r¢r´r¿rÐrÔr×rÙrÍrìrórorôrõrrrrrrr,r-r7r8r3rPrSrWrZr¡rprsr|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Ìr r&Z_WrapperDescriptorÚallZ_MethodWrapperrþrJZ_ClassMethodWrapperrArÎrÏrÚrÜrÝrãrçr÷rrr$r>râr ÚIntEnumr-rrDrrFrrGrrHrrIr2rrIr?ròrr—r r r r Úsz            , t$ >   .N->     ÿ]  ù ;ü < 5        0  ý L H   _þ Kû k: