B hD* @sdZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlmZddlmZmZeZx"ejD]\ZZeede<qWdZddZd d Zd d Z d dZ!ddZ"e#edr ddZ$nddZ$e#edr*ddZ%nddZ%ddZ&ddZ'ddZ(dd Z)d!d"Z*d#d$Z+d%d&Z,d'd(Z-d)d*Z.d+d,Z/d-d.Z0d/d0Z1d1d2Z2d3d4Z3dd5d6Z4ed7d8Z5d9d:Z6d;d<Z7dd=d>d?Z8d@dAZ9dBdCZ:dDdEZ;dFdGZdLdMZ?dNdOZ@ddPdQZAiZBiZCddRdSZDdTdUZEdVdWZFGdXdYdYeGZHGdZd[d[ZId\d]ZJd^d_ZKd`daZLdbdcZMddedfZNedgdhZOdidjZPdkdlZQedmdnZRdodpZSedqdrZTdsdtZUedudvZVdwdxZWddydzZXd{d|ZYdddd}iieZd~dddddddeXf ddZ[eZddddddfddZ\ddZ]ddZ^ddZ_eddZ`ddZaeddZbdddZcddZdeddebjeZfdddZgdddZhddZidddZjdddZkelZmddZnddZoddZpddZqddZremfddZsdZtdZudZvdZwddZxddZydZzdZ{dZ|dZ}ddZ~dd„ZeejZeejZeejdZeeeejfZddńZdddDŽZddɄZdd˄Zdd̈́ZddτZddфZdddԄZdddքZdd؄ZdddٜddۄZGdd݄d݃ZGdd߄d߃ZGdddejZejZejZejZejZejZededededediZejZGdddZGdddZGdddZddddZddZedkredS()zKa-Ping Yee z'Yury Selivanov N) attrgetter) namedtuple OrderedDictZCO_icCs t|tjS)N) isinstancetypes ModuleType)objectr */opt/alt/python37/lib/python3.7/inspect.pyismodule?sr cCs t|tS)N)rtype)rr r r isclassHsr cCs t|tjS)N)rr MethodType)rr r r ismethodPsrcCs:t|st|st|rdSt|}t|do8t|d S)NF__get____set__)r r isfunctionr hasattr)rtpr r r ismethoddescriptorZsrcCs8t|st|st|rdSt|}t|do6t|dS)NFrr)r rrr r)rrr r r isdatadescriptornsrMemberDescriptorTypecCs t|tjS)N)rrr)rr r r ismemberdescriptor~srcCsdS)NFr )rr r r rsGetSetDescriptorTypecCs t|tjS)N)rrr)rr r r isgetsetdescriptorsrcCsdS)NFr )rr r r rscCs t|tjS)N)rr FunctionType)rr r r rs rcCs tt|st|o|jjt@S)N)boolrr__code__co_flagsZ CO_GENERATOR)rr r r isgeneratorfunctionsrcCs tt|st|o|jjt@S)N)rrrrrZ CO_COROUTINE)rr r r iscoroutinefunctionsr cCs tt|st|o|jjt@S)N)rrrrrZCO_ASYNC_GENERATOR)rr r r isasyncgenfunctionsr!cCs t|tjS)N)rrAsyncGeneratorType)rr r r isasyncgensr#cCs t|tjS)N)rr GeneratorType)rr r r isgeneratorsr%cCs t|tjS)N)rr CoroutineType)rr r r iscoroutinesr'cCs6t|tjp4t|tjr(t|jjt@p4t|tj j S)N) rrr&r$rgi_coderZCO_ITERABLE_COROUTINE collectionsabc Awaitable)rr r r isawaitables  r,cCs t|tjS)N)rr TracebackType)rr r r istracebacksr.cCs t|tjS)N)rr FrameType)rr r r isframes r0cCs t|tjS)N)rrCodeType)rr r r iscodesr2cCs t|tjS)N)rrBuiltinFunctionType)rr r r isbuiltinsr4cCs t|pt|pt|pt|S)N)r4rrr)rr r r isroutinesr5cCst|tsdS|jt@rdStt|tjs0dSt|dr>dSx&|j D]\}}t |ddrJdSqJWx@|j D]6}x0t |ddD] }t ||d}t |ddrdSqWqnWdS)NFT__abstractmethods____isabstractmethod__r ) rr __flags__TPFLAGS_IS_ABSTRACT issubclassr*ABCMetar__dict__itemsgetattr __bases__)rnamevaluebaser r r isabstract$s"        rCc Cs$t|r|ft|}nd}g}t}t|}yBx<|jD]2}x,|jD]\}}t|tj rH| |qHWq8WWnt k rYnXx|D]} yt || } | |krt Wn:t k rx$|D]}| |jkr|j| } PqWwYnX|r|| r| | | f| | qW|jddd|S)Nr cSs|dS)Nrr )Zpairr r r ezgetmembers..)key)r getmrosetdirr?r<r=rrDynamicClassAttributeappendAttributeErrorr>addsort) rZ predicatemroresults processednamesrBkvrFrAr r r getmembers<s:       rU Attributezname kind defining_class objectc Csht|}tt|}tdd|D}|f|}||}t|}x:|D]2}x,|jD]\}}t|tjrV| |qVWqFWg} t } x|D]} d} d} d}| | kry| dkrt dt || } Wn"t k r}zWdd}~XYnXt | d| } | |krd} d}x(|D] }t || d}|| kr|}qWxH|D]@}y| || }Wntk rhw:YnX|| kr:|}q:W|dk r|} x4|D],}| |jkr|j| }| |kr|} PqW| dkrq| dk r| n|}t|ttjfrd}|}nFt|ttjfrd}|}n*t|tr.d}|}nt|r>d }nd }| t| || || | qW| S) Ncss|]}|ttfkr|VqdS)N)r r).0clsr r r sz'classify_class_attrs..r<z)__dict__ is special, don't want the proxy __objclass__z static methodz class methodpropertymethoddata)rGr tuplerIr<r=rrrJrKrH Exceptionr> __getattr__rL staticmethodBuiltinMethodType classmethodClassMethodDescriptorTyper[r5rVrM)rXrOZmetamroZ class_basesZ all_basesrRrBrSrTresultrQr@ZhomeclsZget_objZdict_objexcZlast_clsZsrch_clsZsrch_objobjkindr r r classify_class_attrsjs                        ricCs|jS)N)__mro__)rXr r r rGsrG)stopcsdkrdd}n fdd}|}t||i}t}xD||rz|j}t|}||ksbt||krptd||||<q8W|S)NcSs t|dS)N __wrapped__)r)fr r r _is_wrapperszunwrap.._is_wrappercst|do| S)Nrl)r)rm)rkr r rnsz!wrapper loop when unwrapping {!r})idsysgetrecursionlimitrllen ValueErrorformat)funcrkrnrmZmemoZrecursion_limitZid_funcr )rkr unwraps     rvcCs|}t|t|S)N) expandtabsrrlstrip)lineZexpliner r r indentsizesrzcCsRtj|j}|dkrdSx&|jdddD]}t||}q0Wt|sNdS|S)N.)rpmodulesget __module__ __qualname__splitr>r )rurXr@r r r _findclass src Cst|rRxD|jD]:}|tk ry |j}Wntk r<wYnX|dk r|SqWdSt|r|jj}|j}t|rt t ||dd|jkr|}n|j }nt |r|j}t |}|dkst |||k rdSnt |r |j}|j}t|r|jd||jkr|}n|j }nzt|trL|j}|j}t |}|dksFt |||k rdSn:t|s`t|r|j}|j}t |||k rdSndSxJ|jD]@}yt ||j}Wntk rwYnX|dk r|SqWdS)N__func__r{)r rjr__doc__rLrr__name____self__r> __class__rrr4rrr[fgetrrrZ)rgrBdocr@selfrXrur r r _finddocsb         rc Csdy |j}Wntk rdSX|dkrNy t|}Wnttfk rLdSXt|ts\dSt|S)N)rrLr TypeErrorrstrcleandoc)rrr r r getdocRs   rcCsy|d}Wntk r&dSXtj}x:|ddD]*}t|}|rrrrtr rrpr}r~rrrrrr.tb_framer0f_coder2 co_filenamer r)rmoduler r r getfiles,   rcCsTtj|}ddtjD}|x&|D]\}}||r.|d|Sq.WdS)NcSsg|]}t| |fqSr )rr)rWsuffixr r r sz!getmodulename..)ospathbasename importlib machinery all_suffixesrNendswith)rZfnamesuffixesZneglenrr r r getmodulenames  rcst|tjjdd}|tjjdd7}tfdd|Dr`tjdtjj dntfddtjj Dr~dStj rSt t |dddk rStjkrSdS)Nc3s|]}|VqdS)N)r)rWs)filenamer r rYsz getsourcefile..rc3s|]}|VqdS)N)r)rWr)rr r rYs __loader__)rrrDEBUG_BYTECODE_SUFFIXESOPTIMIZED_BYTECODE_SUFFIXESanyrrsplitextSOURCE_SUFFIXESEXTENSION_SUFFIXESexistsr> getmodule linecachecache)rZall_bytecode_suffixesr )rr getsourcefiles   rcCs,|dkrt|pt|}tjtj|S)N)rrrrnormcaseabspath)r _filenamer r r getabsfilesrc Cst|r |St|dr$tj|jS|dk rD|tkrDtjt|Syt||}Wntk rfdSX|tkrtjt|Sxntj D]\\}}t|rt|dr|j }|t |dkrq|t |<t|}|j t|<ttj|<qW|tkr tjt|Stjd}t|ds$dSt||j rLt||j }||krL|Stjd}t||j r~t||j } | |kr~|SdS)Nrr__main__rbuiltins)r rrpr}r~r modulesbyfilerrcopyr=r_filesbymodnamerrrrealpathr>) rrfilemodnamerrmmainZ mainobjectZbuiltinZ builtinobjectr r r rsD         rc Cst|}|rt|n$t|}|dr4|dszsource code not availablezcould not get source coderz^(\s*)class\s*z\bcrzcould not find class definitionco_firstlinenoz"could not find function definitionz>^(\s*def\s)|(\s*async\s+def\s)|(.*(?yt|\}}Wnttfk r(dSXt|rd}|rR|ddddkrRd}x(|t|krz||dkrz|d}qTW|t|kr||dddkrg}|}x>|t|kr||dddkr||||d}qWd|SnH|dkr:t ||}|d}|dkr:|| dddkr:t |||kr:|| g}|dkr|d}|| }x\|dddkrt |||kr|g|dd<|d}|dkrP|| }q|Wx*|r|ddkrg|dd<qWx*|r.|ddkr.g|dd<qWd|SdS) Nrz#!r)#rrr|) rrrr rrstriprKrwrrzrx)rrrstartZcommentsendrcommentr r r getcommentsAsJ  "   $ & rc@s eZdZdS) EndOfBlockN)rrrr r r r rnsrc@seZdZddZddZdS) BlockFindercCs.d|_d|_d|_d|_d|_d|_d|_dS)NrFr)rislambdastartedpassline indecoratordecoratorhasargslast)rr r r __init__rszBlockFinder.__init__cCs|js@|js@|dkrd|_n|dkr8|dkr2d|_d|_d|_n|dkrV|jrTd|_n|dkrr|jrpd|_d|_n|tjkrd|_|d|_|jrt|jr|jsd|_nn|jrnf|tj kr|j d |_ d|_nH|tj kr|j d |_ |j dkrtn"|j dkr|tj tj fkrtdS) N@T)defclasslambdar()Frr)rrrrrtokenizeNEWLINErrINDENTrDEDENTCOMMENTNL)rr tokenZsrowcolZerowcolryr r r tokeneater{sB         zBlockFinder.tokeneaterN)rrrrrr r r r rps rc CsZt}y,tt|j}x|D]}|j|qWWnttfk rJYnX|d|jS)N) rrgenerate_tokensiter__next__rrIndentationErrorr)rZ blockfindertokensZ_tokenr r r getblocks rcCsbt|}t|\}}t|r"|j}t|s>t|rF|jjdkrF|dfSt||d|dfSdS)Nzrr) rvrr.rr r0rco_namer)rrrr r r getsourceliness rcCst|\}}d|S)Nr)rr)rrrr r r getsources rcCsVg}|jtdddx:|D]2}|||jf||kr|t||||qW|S)Nrr)rF)rNrrKr?walktree)classeschildrenparentrPrr r r rs rFcCsi}g}xn|D]f}|jrbxZ|jD]<}||kr4g||<|||krN||||r ||kr Pq Wq||kr||qWx|D]}||kr~||q~Wt||dS)N)r?rKr)runiquerrootsrrr r r getclasstrees"      r Argumentszargs, varargs, varkwcCs t|\}}}}t||||S)N) _getfullargsr)coargsvarargs kwonlyargsvarkwr r r getargssr c Cst|std||j}|j}|j}t|d|}t||||}d}||7}d}|jt@rx|j|}|d}d}|jt @r|j|}||||fS)Nz{!r} is not a code objectrr) r2rrt co_argcount co_varnamesco_kwonlyargcountlistr CO_VARARGSCO_VARKEYWORDS) rnargsrRZnkwargsrr steprr r r r rs"    rArgSpeczargs varargs keywords defaultscCsDtjdtddt|\}}}}}}}|s.|r6tdt||||S)Nzhinspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()r) stacklevelzdFunction has keyword-only parameters or annotations, use getfullargspec() API which can support them)warningswarnDeprecationWarninggetfullargspecrsr)rurrr defaultsr kwonlydefaultsannr r r getargspec s  r FullArgSpeczGargs, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotationsc Cs`yt|ddtd}Wn,tk r@}ztd|Wdd}~XYnXg}d}d}g}d}i}d}i} |j|jk rx|j|d<x|jD]} | j} | j } | t kr| | nv| t kr| | | j | jk r|| j f7}nJ| tkr| }n<| tkr| | | j | jk r| j | | <n| tkr| }| j| jk r| j|| <qW| sBd} |sLd}t|||||| |S)NF)follow_wrapper_chainsskip_bound_argsigclszunsupported callabler return)_signature_from_callable Signaturer_rreturn_annotationempty parametersvaluesrhr@_POSITIONAL_ONLYrK_POSITIONAL_OR_KEYWORDdefault_VAR_POSITIONAL _KEYWORD_ONLY _VAR_KEYWORD annotationr) rusigexrrr r r annotations kwdefaultsparamrhr@r r r rAsT            rArgInfozargs varargs keywords localscCs t|j\}}}t||||jS)N)r rr5f_locals)framerrr r r r getargvaluessr8cCsVt|dddkr t|ddSt|trN|jd|fkr>|jS|jd|jSt|S)Nrtypingztyping.rrr{)r>reprreplacerr rr)r/Z base_moduler r r formatannotations r<cst|ddfdd}|S)Nrcs t|S)N)r<)r/)rr r _formatannotationsz5formatannotationrelativeto.._formatannotation)r>)rr=r )rr formatannotationrelativetos  r>r cCsd|S)N*r )r@r r r rDrErDcCsd|S)Nz**r )r@r r r rDrEcCs dt|S)N=)r:)rAr r r rDrEcCsd|S)Nz -> r )textr r r rDrEc sDddlm} | dtddfdd}g}|rBt|t|}xFt|D]:\}}||}|r|||kr||| |||}||qLW|dk r||||n|r|d|rx:|D]2}||}|r||kr|| ||7}||qW|dk r|| ||d d |d }d kr@|| d 7}|S) Nr)rzc`formatargspec` is deprecated since Python 3.5. Use `signature` and the `Signature` object directlyr)rcs(|}|kr$|d|7}|S)Nz: r )argre)r2r< formatargr r formatargandannotationsz-formatargspec..formatargandannotationr?rz, rr")rrrrr enumeraterKr)rrr rr rr2rC formatvarargs formatvarkw formatvalueZ formatreturnsr<rrDspecsZ firstdefaultrrBspecZ kwonlyargrer )r2r<rCr formatargspecs:       rKcCsd|S)Nr?r )r@r r r rDrEcCsd|S)Nz**r )r@r r r rDrEcCs dt|S)Nr@)r:)rAr r r rDrEc Cs|||fdd}g} x&tt|D]} | ||| q"W|rZ| ||||||rx| |||||dd| dS)NcSs|||||S)Nr )r@localsrCrHr r r convertsz formatargvalues..convertrz, r)rrrrKr) rrr rLrCrFrGrHrMrIrr r r formatargvaluess rNcsfdd|D}t|}|dkr,|d}n>|dkr@dj|}n*dj|dd}|dd=d ||}td |||rzd nd |dkrd nd|fdS)Ncsg|]}|krt|qSr )r:)rWr@)r(r r r sz&_missing_arguments..rrrz {} and {}z , {} and {}z, z*%s() missing %i required %s argument%s: %s positionalz keyword-onlyrr)rrrtrr)f_nameZargnamesposr(rRmissingrtailr )r(r _missing_argumentss    rUc st||}tfdd|D}|r:|dk} d|f} n2|rTd} d|t|f} nt|dk} tt|} d} |rd} | |dkrd nd||dkrd ndf} td || | rd nd|| |dkr|sd nd fdS) Ncsg|]}|kr|qSr r )rWrB)r(r r rsz_too_many..rz at least %dTz from %d to %drz7 positional argument%s (and %d keyword-only argument%s)rz5%s() takes %s positional argument%s but %d%s %s givenZwasZwere)rrrr) rQrZkwonlyrZdefcountZgivenr(ZatleastZ kwonly_givenpluralr0Z kwonly_sigmsgr )r(r _too_manys$    rXcOs4|d}|dd}t|}|\}}}}} } } |j} i} t|rV|jdk rV|jf|}t|}t|}|rrt|nd}t||}x t|D]}||| ||<qW|rt||d| |<t|| }|ri| |<xd| D]X\}}||kr|st d| |f|| ||<q|| kr,t d| |f|| |<qW||kr\|s\t | || |||| ||kr|d||}x&|D]}|| kr|t | |d| q|Wx8t |||dD] \}}|| kr||| |<qWd}x>| D]6}|| kr| r|| kr| || |<n|d7}qW|r0t | | d| | S)Nrrz*%s() got an unexpected keyword argument %rz(%s() got multiple values for argument %rTF)rrrrrrrrr^rHr=rrXrUrE)Zfunc_and_positionalZnamedrurPrJrrr rr rrrQZ arg2valueZnum_posZnum_argsZ num_defaultsnrZpossible_kwargskwrAZreqrBrSkwargr r r getcallargs-sd                 r\ ClosureVarsz"nonlocals globals builtins unboundc Cst|r|j}t|s$td||j}|jdkr:i}nddt|j|jD}|j }| dt j }t |rt|j }i}i}t}xn|jD]d}|dkrqy||||<Wqtk ry||||<Wntk r||YnXYqXqWt||||S)Nz{!r} is not a Python functioncSsi|]\}}|j|qSr ) cell_contents)rWvarZcellr r r sz"getclosurevars.. __builtins__)NoneTrueFalse)rrrrrtr __closure__zip co_freevars __globals__r~rr<r rHco_namesKeyErrorrMr]) rucodeZ nonlocal_varsZ global_nsZ builtin_nsZ global_varsZ builtin_varsZ unbound_namesr@r r r getclosurevarsms8   rl Tracebackz+filename lineno function code_context indexrcCst|r|j}|j}n|j}t|s2td|t|p@t|}|dkr|d|d}yt |\}}Wnt k rd}}YqXt dt |t ||}||||}|d|}nd}}t|||jj||S)Nz'{!r} is not a frame or traceback objectrrr)r. tb_linenorf_linenor0rrtrrrrmaxrrrrmrr)r7contextlinenorrrrindexr r r getframeinfos$rtcCs|jS)N)ro)r7r r r getlinenosru FrameInfo)r7cCs6g}x,|r0|ft||}|t||j}qW|S)N)rtrKrvf_back)r7rq framelist frameinfor r r getouterframess  rzcCs8g}x.|r2|jft||}|t||j}qW|S)N)rrtrKrvtb_next)tbrqrxryr r r getinnerframess  r}cCsttdrtdSdS)N _getframer)rrpr~r r r r currentframesrcCsttd|S)Nr)rzrpr~)rqr r r stacksrcCsttd|S)Nr)r}rpexc_info)rqr r r tracesrcCstjd|S)Nrj)r r<r)klassr r r _static_getmrosrcCs8i}yt|d}Wntk r(YnXt||tS)Nr<)r__getattribute__rLdictr~ _sentinel)rgattrZ instance_dictr r r _check_instances rc CsFx@t|D]4}tt|tkr y |j|Stk r<Yq Xq WtS)N)r_shadowed_dictr rr<rj)rrentryr r r _check_classs  rcCs&y t|Wntk r dSXdS)NFT)rr)rgr r r _is_type s  rc Csntjd}x^t|D]R}y||d}Wntk r>YqXt|tjkrb|jdkrb|j|ks|SqWt S)Nr<) r r<rrrjrrrrZr)r dict_attrrZ class_dictr r r rs   rc Cst}t|s>t|}t|}|tks2t|tjkrBt||}n|}t||}|tk r|tk rtt|dtk rtt|dtk r|S|tk r|S|tk r|S||krxDtt|D]4}tt|tkry |j |St k rYqXqW|tk r|St |dS)Nrr) rrr rrrrrrr<rjrL)rgrr+Zinstance_resultrrZ klass_resultrr r r getattr_statics6     r GEN_CREATED GEN_RUNNING GEN_SUSPENDED GEN_CLOSEDcCs,|jr tS|jdkrtS|jjdkr(tStS)Nr|) gi_runningrgi_framerf_lastirr) generatorr r r getgeneratorstateSs   rcCs:t|std|t|dd}|dk r2|jjSiSdS)Nz{!r} is not a Python generatorr)r%rrtr>rr6)rr7r r r getgeneratorlocalses  r CORO_CREATED CORO_RUNNINGCORO_SUSPENDED CORO_CLOSEDcCs,|jr tS|jdkrtS|jjdkr(tStS)Nr|) cr_runningrcr_framerrrr) coroutiner r r getcoroutinestate}s   rcCs"t|dd}|dk r|jSiSdS)Nr)r>r6)rr7r r r getcoroutinelocalss r from_bytescCs6yt||}Wntk r"dSXt|ts2|SdS)N)r>rLr_NonUserDefinedCallables)rXZ method_nameZmethr r r "_signature_get_user_defined_methods  rc Cs|j}t|}|jpd}|jp$i}|r2||}y|j||}Wn6tk rx}zd|} t| |Wdd}~XYnXd} x |D]\} } y|j | } Wnt k rYnlX| j t kr| | q| j tkr| |krd} | j| d|| <n| | jq| j tkr"| j| d|| <| r| j tkrV|| jtd}||| <|| q| j ttfkrr|| q| j tkr| | jqW|j|dS)Nr z+partial object {!r} has incorrect argumentsFT)r+)rh)r')r'rr=rkeywords bind_partialrrtrs argumentsrjrhr)rr*r;r@r- move_to_endr.r,r() wrapped_sigpartialZ extra_argsZ old_params new_paramsZ partial_argsZpartial_keywordsZbar1rWZtransform_to_kwonly param_namer4Z arg_valueZ new_paramr r r _signature_get_partialsL              rcCslt|j}|r$|djttfkr,td|dj}|ttfkrP|dd}n|t k r`td|j |dS)Nrzinvalid method signaturerzinvalid argument type)r') r^r'r(rhr.r-rsr*r)r,r;)r0paramsrhr r r _signature_bound_methods  rcCs&t|p$t|p$t|tp$|ttfkS)N)r4rrrr r)rgr r r _signature_is_builtin!s rcCst|rt|rdSt|dd}t|dd}t|dt}t|dt}t|dd}t|tjot|to|dksxt|to|dkst|t ot|t S)NFrr __defaults____kwdefaults____annotations__) callabler r>_voidrrr1rr^r)rgr@rkrr3r2r r r _signature_is_functionlike-s       rcCs<|d}|dkr|d}|d}|d}|d|S)N,r|r:r@r)find)rJrRZcposr r r _signature_get_bound_paramFs    rcCs$|s|ddfSd}d}dd|dD}t|j}t|}d}d}g}|j} d} tj} tj} t|} x|D]} | j | j }}|| kr|dkr|rd}qnd}| d7} qn|d krd}| d}qn|| kr|d kr| }qn|rd}|| kr|d ks| d | ||dkrn| d qnWd |}|||fS)NcSsg|]}|dqS)ascii)encode)rWlr r r rpsz6_signature_strip_non_python_syntax..rFrrTr/$rz,  r) rrrrrKrOP ERRORTOKENnextr stringr) signatureself_parameterlast_positional_onlyrrZ token_streamZ delayed_commaZskip_next_commarArMZcurrent_parameterrrtr rclean_signaturer r r "_signature_strip_non_python_syntax]sP       rTc shddl|jt|\}}}d|d}y|}Wntk rNd}YnXt|jsjtd||j d} gj t d}it |dd} | rt j| d}|r|jt j fdd fdd  G fd d d jffd d } t| jj} t| jj} tj| | dd}|dk rJjnjx.parse_namec syt|}Wn>tk rLyt|}Wntk rFtYnXYnXt|trb|St|ttfrz|St|t r |S|dkr |StdS)N)TFN) eval NameError RuntimeErrorrrZStrintfloatZNumbytesZBytesZ NameConstant)rrA)r module_dictsys_module_dictr r wrap_values       z&_signature_fromstr..wrap_valuecs(eZdZfddZfddZdS)z,_signature_fromstr..RewriteSymbolicscs`g}|}x"t|jr*||j|j}q Wt|js>t||jdt |}|S)Nr{) rrVrKrrANamerrorreversed)rrarYrA)rrr r visit_Attributes    z<_signature_fromstr..RewriteSymbolics.visit_Attributecst|jjst|jS)N)rZctxZLoadrsro)rr)rrr r visit_Namesz7_signature_fromstr..RewriteSymbolics.visit_NameN)rrrrrr )rrr r RewriteSymbolicss rcs|}|krdS|rp|tk rpy|}|}Wntk rR}YnX|kr`dS|k rl|n|}||ddS)N)r+r/)_emptyZvisitZ literal_evalrsrK)Z name_nodeZ default_noder+r@o) Parameterrrr&invalidrhr'rr r ps   z_signature_fromstr..p) fillvaluer)rh)r%)'r_parameter_clsrparse SyntaxErrorrZModulersrtZbodyr&rr>rpr}r~r<rZNodeTransformerrrr itertools zip_longestPOSITIONAL_ONLYPOSITIONAL_OR_KEYWORDrErZvarargVAR_POSITIONAL KEYWORD_ONLYrfr Z kw_defaultsr[ VAR_KEYWORDr rr;)rXrgrr rrrZprogramrrmZ module_namerrrrrr@r+_selfZ self_isboundZ self_ismoduler ) rrrr&rrhrr'rrrr _signature_fromstrsl                  rcCsBt|std|t|dd}|s4td|t||||S)Nz%{!r} is not a Python builtin function__text_signature__z#no signature found for builtin {!r})rrrtr>rsr)rXrur rr r r _signature_from_builtin5s rc Csd}t|s(t|rd}ntd||j}|j}|j}|j}t|d|}|j }||||} |j } |j } |j } | rt | } nd} g}|| }x4|d|D]$}| |t}||||tdqWxBt||dD].\}}| |t}||||t| |dqW|jt@rH|||}| |t}||||tdxJ| D]B}t}| dk rl| |t}| |t}||||t|dqNW|jt@r||}|jt@r|d7}||}| |t}||||td||| dt|d S) NFTz{!r} is not a Python functionr)r/rh)r/rhr+rr")r%__validate_parameters__)rrrrtrrr r r^rrrrrrr~rrKr*rErrr,r-rr.)rXruZis_duck_functionrZ func_codeZ pos_countZ arg_namesrPZkeyword_only_countZ keyword_onlyr2rr3Zpos_default_countr'Znon_default_countr@r/offsetr+rsr r r _signature_from_functionEsj                     r)rr c Cst|std|t|tjrDt|j|||d}|r@t|S|S|rtt |ddd}t|tjrtt||||dSy |j }Wnt k rYn&X|dk rt|t std||Sy |j }Wnt k rYnvXt|tjrLt|j|||d}t||d}t|jd}|jtjkr(|St|j}|f|} |j| d St|s`t|rjt||St|rt|||d St|tjrt|j|||d}t||Sd}t|trt t|d } | dk rt| |||d}nJt |d } | dk r t| |||d}n$t |d } | dk r0t| |||d}|dkr.)rkz1unexpected object {!r} in __signature__ attribute)Nr)r')r __call____new__rr|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)+rrrtrrrr#rrrvrrLr$_partialmethod functools partialmethodrurr^r'r(rhrrr;rrrrrrr rrjrrrrr from_callablersrr3)rgrr r!r0rrZfirst_wrapped_paramZ sig_paramsrZcallnewZinitrBZtext_sigr1rWr r r r#s                              r#c@s eZdZdS)rN)rrrr r r r r_ src@s eZdZdS)rN)rrrr r r r rc src@s(eZdZdZdZdZdZdZddZdS) _ParameterKindrrrcCs|jS)N)_name_)rr r r __str__n sz_ParameterKind.__str__N) rrrrrrrrrr r r r rg s rzpositional-onlyzpositional or keywordzvariadic positionalz keyword-onlyzvariadic keywordc@seZdZdZeZeZeZ e Z e Z eZeedddZddZddZed d Zed d Zed dZeddZeeeedddZddZddZddZddZdS)r)_name_kind_default _annotation)r+r/cCs yt||_Wn$tk r2td|dYnX|tk rf|jttfkrfd}|t|j}t|||_||_ |tkrtdt |t sdt |j }t||ddkr|ddr|jtkrd }|t|j}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{rzLimplicit arguments must be passed as positional or keyword arguments, not {}z implicit{}z"{!r} is not a valid parameter name)rrrsrr,r.rt_get_paramkind_descrrrrrr rrisdigitr*r) isidentifierr)rr@rhr+r/rWr r r r s4   zParameter.__init__cCs t||j|jf|j|jdfS)N)rr)r rrrr)rr r r __reduce__ s zParameter.__reduce__cCs|d|_|d|_dS)Nrr)rr)rstater r r __setstate__ s zParameter.__setstate__cCs|jS)N)r)rr r r r@ szParameter.namecCs|jS)N)r)rr r r r+ szParameter.defaultcCs|jS)N)r)rr r r r/ szParameter.annotationcCs|jS)N)r)rr r r rh szParameter.kind)r@rhr/r+cCsL|tkr|j}|tkr|j}|tkr*|j}|tkr8|j}t|||||dS)N)r+r/)rrrrrr )rr@rhr/r+r r r r; szParameter.replacecCs|j}|j}|jtk r(d|t|j}|jtk rb|jtk rPd|t|j}nd|t|j}|tkrtd|}n|t krd|}|S)Nz{}: {}z{} = {}z{}={}r?z**) rhrrrrtr<rr:r,r.)rrh formattedr r r r s     zParameter.__str__cCsd|jj|S)Nz <{} "{}">)rtrr)rr r r __repr__ szParameter.__repr__cCst|j|j|j|jfS)N)hashr@rhr/r+)rr r r __hash__ szParameter.__hash__cCsJ||kr dSt|tstS|j|jkoH|j|jkoH|j|jkoH|j|jkS)NT)rrNotImplementedrrrr)rotherr r r __eq__ s    zParameter.__eq__N)rrr __slots__r)rr*rr,rr-rr.rrr&rr r r[r@r+r/rhrr;rr rrr r r r r s((    rc@sdeZdZdZddZeddZeddZedd Zd d Z d d Z ddZ ddZ ddZ dS)BoundArguments)r _signature __weakref__cCs||_||_dS)N)rr)rrrr r r r1 szBoundArguments.__init__cCs|jS)N)r)rr r r r5 szBoundArguments.signaturec Cs|g}xn|jjD]^\}}|jttfkr*Py|j|}Wntk rNPYqX|jtkrf| |q| |qWt |S)N) rr'r=rhr.r-rrjr,extendrKr^)rrrr4rBr r r r9 s  zBoundArguments.argsc Csi}d}x|jjD]x\}}|sF|jttfkr6d}n||jkrFd}q|sLqy|j|}Wntk rnYqX|jtkr||q|||<qW|S)NFT) rr'r=rhr.r-rrjupdate)rkwargsZkwargs_startedrr4rBr r r rP s&    zBoundArguments.kwargsc Cs|j}g}x|jjD]v\}}y||||fWqtk r|jtk rX|j}n"|jt krhd}n|jt krxi}nw|||fYqXqWt ||_dS)Nr ) rrr'r=rKrjr+rrhr,r.r)rrZ new_argumentsr@r4valr r r apply_defaultsn s    zBoundArguments.apply_defaultscCs2||kr dSt|tstS|j|jko0|j|jkS)NT)rrrrr)rrr r r r s   zBoundArguments.__eq__cCs|d|_|d|_dS)Nrr)rr)rr r r r r  s zBoundArguments.__setstate__cCs|j|jdS)N)rr)rr)rr r r __getstate__ szBoundArguments.__getstate__cCsDg}x(|jD]\}}|d||qWd|jjd|S)Nz{}={!r}z <{} ({})>z, )rr=rKrtrrr)rrrBrAr r r r  szBoundArguments.__repr__N)rrrrrr[rrrrrr rr r r r r r s   rc@seZdZdZeZeZeZ d+eddddZ e ddZ e d d Z e dd d d ZeddZeddZeedddZddZddZddZddddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*ZdS),r$)_return_annotation _parametersNT)r%rc Cs|dkrt}n|rt}t}d}xt|D]\}}|j} |j} | |krjd} | t|t| } t| n| |krzd}| }| ttfkr|j t kr|rd} t| nd}| |krd| } t| ||| <q,Wntdd|D}t ||_ ||_dS)NFz7wrong parameter order: {} parameter before {} parameterz-non-default argument follows default argumentTzduplicate parameter name: {!r}css|]}|j|fVqdS)N)r@)rWr4r r r rY sz%Signature.__init__..)rr)rErhr@rtrrsr*r+rrMappingProxyTyperr) rr'r%rrZtop_kindZ kind_defaultsidxr4rhr@rWr r r r s>         zSignature.__init__cCstjdtddt||S)Nz_inspect.Signature.from_function() is deprecated since Python 3.5, use Signature.from_callable()r)r)rrrr)rXrur r r from_function s zSignature.from_functioncCstjdtddt||S)Nz^inspect.Signature.from_builtin() is deprecated since Python 3.5, use Signature.from_callable()r)r)rrrr)rXrur r r from_builtin s zSignature.from_builtin)follow_wrappedcCst|||dS)N)r!r)r#)rXrgr#r r r r szSignature.from_callablecCs|jS)N)r)rr r r r' szSignature.parameterscCs|jS)N)r)rr r r r% szSignature.return_annotation)r'r%cCs0|tkr|j}|tkr |j}t|||dS)N)r%)rr'r(rr )rr'r%r r r r; s  zSignature.replacecCs8tdd|jD}dd|jD}|||jfS)Ncss|]}|jtkr|VqdS)N)rhr-)rWr4r r r rY+ sz(Signature._hash_basis..cSsi|]}|jtkr||jqSr )rhr-r@)rWr4r r r r`. sz)Signature._hash_basis..)r^r'r(r%)rr kwo_paramsr r r _hash_basis* szSignature._hash_basiscCs(|\}}}t|}t|||fS)N)r% frozensetr(r)rrr$r%r r r r3 s zSignature.__hash__cCs*||kr dSt|tstS||kS)NT)rr$rr%)rrr r r r8 s  zSignature.__eq__F)rc Cst}t|j}d}t|}xxy t|}Wntk ry t|} Wntk rbPYnX| jtkrrPn| j|kr| jt krd} | j | jd} t | d| f}PnH| jt ks| j tk r| f}Pn*|r| f}Pnd} | j | jd} t | dYq$Xy t|} Wn tk r&t ddYq$X| jt tfkrBt dd| jtkrn|g} | |t| || j<P| j|krt dj | jdd||| j<q$Wd} xt||D]} | jt kr| } q| jtkr֐q| j} y|| }WnFtk r0|s,| jtkr,| j tkr,t dj | ddYn(X| jt krPt dj | jd||| <qW|r| dk rz||| j<nt dj tt|d|||S)Nr zA{arg!r} parameter is positional only, but was passed as a keyword)rBz$missing a required argument: {arg!r}ztoo many positional argumentsz$multiple values for argument {arg!r}z*got an unexpected keyword argument {arg!r})rrr'r(r StopIterationrhr,r@r)rtrr.r+rr-rr^rchainrrj_bound_arguments_cls)rrrrrr'Z parameters_exZarg_valsZarg_valr4rWr(Z kwargs_paramrr r r _bind? s                   zSignature._bindcOs|d|dd|S)Nrr)r*)rrr r r bind szSignature.bindcOs|dj|dd|ddS)NrrT)r)r*)rrr r r r szSignature.bind_partialcCs t|t|jfd|jifS)Nr)r r^rr(r)rr r r r  szSignature.__reduce__cCs|d|_dS)Nr)r)rr r r r r  szSignature.__setstate__cCsd|jj|S)Nz<{} {}>)rtrr)rr r r r  szSignature.__repr__c Csg}d}d}xr|jD]d}t|}|j}|tkr8d}n|rJ|dd}|tkrXd}n|tkrr|rr|dd}||qW|r|ddd |}|j t k rt |j }|d|7}|S)NFTrr?z({})z, z -> {}) r'r(rrhr)rKr,r-rtrr%rr<) rreZrender_pos_only_separatorZrender_kw_only_separatorr4r rhZrenderedZannor r r r s0      zSignature.__str__)N)rrrrrrrr)rr&rrcr!r"rr[r'r%rr;r%rrr*r+rr r r rr r r r r$ s06    r$)r#cCstj||dS)N)r#)r$r)rgr#r r r r src Csddl}ddl}|}|jddd|jddddd |}|j}|d \}}}y||}} WnNtk r} z0d |t | j | } t | t jd t d Wdd} ~ XYnX|r|d} | }x| D]} t|| }qW| j t jkrt dt jd t d|jrt d |t d t| t d | j|| kr|t d t| jt| drt d | jn6yt|\}}Wntk rYnXt d |t dn t t|dS)NrrzCThe 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,rzFailed to import {} ({}: {}))rrr{z#Can't get info for builtin modules.rz Target: {}z Origin: {}z Cached: {}z Loader: {}__path__zSubmodule search path: {}zLine: {}r)argparserArgumentParser add_argument parse_argsr partition import_moduler_rtr rprintrpstderrexitrr>builtin_module_namesZdetailsr __cached__r:rrr/rr)r0rparserrtargetZmod_nameZ has_attrsZattrsrgrrfrWpartspart__rrr r r _main sV      r@r)N)N)N)F)N)r)r)r)r)r)r )T)T) __author__r*disZcollections.abcr)enumZimportlib.machineryrrrrrrprrrrrroperatorrrrglobalsZmod_dictZCOMPILER_FLAG_NAMESr=rSrTr9r r rrrrrrrrr r!r#r%r'r,r.r0r2r4r5rCrUrVrirGrvrzrrrrrrrrrrrrrr_rrrrrrrrr rrrrrr5r8r<r>rrKrNrUrXr\r]rlrmrtru_fieldsrvrzr}rrrrrrrrrrrrrrrrrrrrrrrr rZ_WrapperDescriptorallZ_MethodWrapperrr<Z_ClassMethodWrapperr3rrrrrrrrrrrr#rrIntEnumrrr)rr*rr,rr-rr.Z_PARAM_NAME_MAPPING __getitem__rrrr$rr@rr r r r s`            , t$ ;   .I-7      [   4> 5        0   L H  RH k: