grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026B øÂF¡!ûëã@sîddgZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m ZddlZdZGdd„dƒZdd „Zd d „ZGd d„dƒZd d„Zdd„Zddd„Zdd„ZGdd„dƒZdd„ZedkrêeƒdS)ÚTraceÚCoverageResultséN)Ú monotonicz#pragma NO COVERc@seZdZddd„Zdd„ZdS)Ú_IgnoreNcCs:|s tƒnt|ƒ|_|sgn dd„|Dƒ|_ddi|_dS)NcSsg|]}tj |¡‘qS©)ÚosÚpathÚnormpath)Ú.0Údrrú*/opt/alt/python37/lib64/python3.7/trace.pyú Hsz$_Ignore.__init__..zé)ÚsetÚ_modsÚ_dirsÚ_ignore)ÚselfÚmodulesÚdirsrrr Ú__init__Fs z_Ignore.__init__cCsª||jkr|j|S||jkr,d|j|<dSx*|jD] }| |d¡r4d|j|<dSq4W|dkrnd|j|<dSx,|jD]"}| |tj¡rvd|j|<dSqvWd|j|<dS)NrÚ.r)rrÚ startswithrrÚsep)rÚfilenameÚ modulenameÚmodr rrr ÚnamesLs$          z _Ignore.names)NN)Ú__name__Ú __module__Ú __qualname__rrrrrr rEs rcCs tj |¡}tj |¡\}}|S)N)rrÚbasenameÚsplitext)rÚbaserÚextrrr Ú_modnamews r%cCsÆtj |¡}d}xJtjD]@}tj |¡}| |¡r|t|ƒtjkrt|ƒt|ƒkr|}qW|rv|t|ƒdd…}n|}tj |¡\}}| tjd¡}tj r¬| tj d¡}tj  |¡\}}|  d¡S)NÚrr) rrÚnormcaseÚsysrÚlenrÚ splitdriveÚreplaceÚaltsepr"Úlstrip)rZ comparepathZlongestÚdirr#Zdriverr$rrr Ú _fullmodname~s    r/c@s:eZdZddd„Zdd„Zdd„Zdd d „Zdd d „ZdS)rNc Csþ||_|jdkri|_|j ¡|_||_|jdkr8i|_|j ¡|_||_|jdkrZi|_|j ¡|_||_||_|jrúy@t|jdƒ�}t  |¡\}}}WdQRX|  |  |||¡¡Wn@t t tfk rø}ztd|j|ftjd�Wdd}~XYnXdS)NÚrbzSkipping counts file %r: %s)Úfile)ÚcountsÚcopyZcounterÚ calledfuncsÚcallersÚinfileÚoutfileÚopenÚpickleÚloadÚupdateÚ __class__ÚOSErrorÚEOFErrorÚ ValueErrorÚprintr(Ústderr)rr2r4r6r5r7ÚfÚerrrrr r›s,      zCoverageResults.__init__cCs| d¡o| d¡S)Nú<ú>)rÚendswith)rrrrr Úis_ignored_filenameµsz#CoverageResults.is_ignored_filenamec Csz|j}|j}|j}|j}|j}|j}x$|D]}| |d¡||||<q*Wx|D] }d||<qPWx|D] }d||<qfWdS)Nrr)r2r4r5Úget) rÚotherr2r4r5Z other_countsZother_calledfuncsZ other_callersÚkeyrrr r;»s    zCoverageResults.updateTFc! Csô|jrDtƒtdƒ|j}x(t|ƒD]\}}}td|||fƒq$W|jrØtƒtdƒd}} xvt|jƒD]h\\} } } \} }}| |kr¢tƒtd| dƒ| }d} | | krÀ| | krÀtd| ƒ| } td| | ||fƒqlWi}x8|jD].\}}| |i¡}||<|j||f||<qäWi}�x$| ¡D�]\}}| |¡�r@�q&| d¡�rX|dd …}|dk�r€t j   t j   |¡¡}t |ƒ}n$|}t j  |¡�sœt  |¡t|ƒ}|�r´t|ƒ}ni}t |¡}t j  ||d ¡}t|d ƒ�}t |j¡\}}WdQRX| |||||¡\}}|�r&|�r&td ||ƒ}||||f||<�q&W|�rŠ|�rŠtd ƒx2t|ƒD]&}||\}}}}td||ƒ�q`W|j�rðy&t |j|j|jft|jdƒd¡Wn6tk �rî} ztd| tj d�Wdd} ~ XYnXdS)Nzfunctions called:z*filename: %s, modulename: %s, funcname: %szcalling relationships:r&z***z -->z %s.%s -> %s.%sz.pycéÿÿÿÿz.coverr0édzlines cov% module (path)z%5d %3d%% %s (%s)Úwbrz"Can't save counts files because %s)r1)!r4r@Úsortedr5r2rHÚitemsrGrFrrÚdirnameÚabspathr%ÚexistsÚmakedirsr/Ú_find_executable_linenosÚ linecacheÚgetlinesÚjoinr8ÚtokenizeÚdetect_encodingÚreadlineÚwrite_results_fileÚintr7r9Údumpr=r(rA)!rZ show_missingÚsummaryÚcoverdirZcallsrrÚfuncnameZlastfileZ lastcfileZpfileZpmodZpfuncÚcfileZcmodZcfuncZper_fileÚlinenoÚ lines_hitZsumsÚcountr.ÚlnotabÚsourceZ coverpathÚfpÚencodingÚ_Ún_hitsÚn_linesÚpercentÚmrCrrr Ú write_resultsÍs|              zCoverageResults.write_resultsc Csîyt|d|d�}Wn8tk rJ}ztd||ftjd�dSd}~XYnXd}d} |�ˆx€t|dƒD]r\} } | |krš| d|| ¡| d7} |d7}n.| |kr¾t| kr¾| d ¡|d7}n | d ¡| |  d ¡¡qfWWdQRX| |fS) NÚw)rhz3trace: Could not open %r for writing: %s - skipping)r1)rrrrz%5d: z>>>>>> z é) r8r=r@r(rAÚ enumerateÚwriteÚPRAGMA_NOCOVERÚ expandtabs) rrÚlinesrercrhr7rCrkrjrbÚlinerrr r[(s(    z"CoverageResults.write_results_file)NNNNN)TFN)N)rrr rrGr;rnr[rrrr ršs   [cCs0i}x&t |¡D]\}}||krd||<qW|S)Nr)ÚdisZfindlinestarts)ÚcodeÚstrsÚlinenosrirbrrr Ú_find_lines_from_codeHs  r{cCs8t||ƒ}x(|jD]}t |¡r| t||ƒ¡qW|S)N)r{Ú co_constsÚinspectZiscoder;Ú _find_lines)rxryrzÚcrrr r~Rs    r~c Cs’i}tj}t||d��r}t |j¡}x^|D]V\}}}} } |tjkr||tjkr||\} } | \} }xt| | dƒD] }d||<qlW|}q*WWdQRX|S)N)rhr)ÚtokenÚINDENTr8rXÚgenerate_tokensrZÚSTRINGÚrange)rrhr Z prev_ttyperBÚtokZttypeZtstrÚstartÚendrvZslineZscolZelineZecolÚirrr Ú _find_strings^s    r‰c Cs‚y(t |¡�}| ¡}|j}WdQRXWn8tk r`}ztd||ftjd�iSd}~XYnXt||dƒ}t ||ƒ}t ||ƒS)Nz%Not printing coverage data for %r: %s)r1Úexec) rXr8Úreadrhr=r@r(rAÚcompiler‰r~)rrBÚprogrhrCrxryrrr rTus   rTc @speZdZddd„Zdd „Zdd d „Zd d „Zdd„Zdd„Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„ZdS) rrrrNFc CsÀ||_||_t||ƒ|_i|_i|_d|_||_i|_i|_ i|_ d|_ | rTt ƒ|_ |rb|j |_nZ|rp|j|_nL|rŠ|rŠ|j|_|j|_n2|r |j|_|j|_n|r¶|j|_|j|_nd|_dS)Nrr)r6r7rÚignorer2ZpathtobasenameÚ donothingÚtraceÚ _calledfuncsÚ_callersÚ _caller_cacheÚ start_timeÚ_timeÚglobaltrace_trackcallersÚ globaltraceÚglobaltrace_countfuncsÚglobaltrace_ltÚlocaltrace_trace_and_countÚ localtraceÚlocaltrace_traceÚlocaltrace_count) rrdr�Ú countfuncsÚ countcallersÚ ignoremodsÚ ignoredirsr6r7Útimingrrr r„s6      zTrace.__init__cCs ddl}|j}| |||¡dS)Nr)Ú__main__Ú__dict__Úrunctx)rÚcmdr£Údictrrr Úrun¶sz Trace.runc Csh|dkr i}|dkri}|js6t |j¡t |j¡zt|||ƒWd|jsbt d¡t d¡XdS)N)r�Ú threadingÚsettracer—r(rŠ)rr¦ÚglobalsÚlocalsrrr r¥»s   z Trace.runctxc Os’t|ƒdkr|^}}}n>|s&tdƒ‚n0d|krB| d¡}|^}}ntdt|ƒdƒ‚d}|jslt |j¡z|||Ž}Wd|jsŒt d¡X|S)Néz8descriptor 'runfunc' of 'Trace' object needs an argumentÚfuncz7runfunc expected at least 1 positional argument, got %dr)r)Ú TypeErrorÚpopr�r(rªr—)ÚargsÚkwrr®Úresultrrr ÚrunfuncÈs"       z Trace.runfuncc Csð|j}|j}|rt|ƒ}nd}|j}d}||jkrL|j|dk rÒ|j|}n†d|j|<dd„t |¡Dƒ}t|ƒdkrÒdd„t |d¡Dƒ}t|ƒdkrÒdd„t |d¡Dƒ} t| ƒdkrÒ| dj}||j|<|dk ræd||f}|||fS)NcSsg|]}t |¡r|‘qSr)r}Z isfunction)r rBrrr r ðsz1Trace.file_module_function_of..rcSsg|]}t|tƒr|‘qSr)Ú isinstancer§)r r rrr r ösrcSsg|]}t|dƒr|‘qS)Ú __bases__)Úhasattr)r rrrr r ùsz%s.%s) Úf_codeÚ co_filenamer%Úco_namer“ÚgcZ get_referrersr)r) rÚframerxrrr`ZclsnameZfuncsZdictsÚclassesrrr Úfile_module_function_ofßs,          zTrace.file_module_function_ofcCs0|dkr,| |¡}| |j¡}d|j||f<dS)NÚcallr)r¾Úf_backr’)rr¼ÚwhyÚargÚ this_funcZ parent_funcrrr r–s  zTrace.globaltrace_trackcallerscCs |dkr| |¡}d|j|<dS)Nr¿r)r¾r‘)rr¼rÁrÂrÃrrr r˜s zTrace.globaltrace_countfuncscCsj|dkrf|j}|j dd¡}|rbt|ƒ}|dk rf|j ||¡}|sf|jrZtd||jfƒ|j SndSdS)Nr¿Ú__file__z! --- modulename: %s, funcname: %s) r¸Ú f_globalsrHr%rŽrr�r@rºr›)rr¼rÁrÂrxrrZ ignore_itrrr r™szTrace.globaltrace_ltcCs„|dkr~|jj}|j}||f}|j |d¡d|j|<|jrTtdtƒ|jdd�tj   |¡}td||t   ||¡fdd�|j S) Nrvrrz%.2fú )r‡z %s(%d): %sr&)r¸r¹Úf_linenor2rHr”r@r•rrr!rUÚgetliner›)rr¼rÁrÂrrbrJÚbnamerrr rš3s z Trace.localtrace_trace_and_countcCsd|dkr^|jj}|j}|jr4tdtƒ|jdd�tj |¡}td||t   ||¡fdd�|j S)Nrvz%.2frÆ)r‡z %s(%d): %sr&) r¸r¹rÇr”r@r•rrr!rUrÈr›)rr¼rÁrÂrrbrÉrrr rœBs zTrace.localtrace_tracecCs<|dkr6|jj}|j}||f}|j |d¡d|j|<|jS)Nrvrr)r¸r¹rÇr2rHr›)rr¼rÁrÂrrbrJrrr r�Os zTrace.localtrace_countcCst|j|j|j|j|jd�S)N)r6r7r4r5)rr2r6r7r‘r’)rrrr ÚresultsWs z Trace.results) rrrrrrNNF)NN)rrr rr¨r¥r´r¾r–r˜r™ršrœr�rÊrrrr rƒs 0 )   c stddl}| ¡}|jdddd�| dd¡}|jdd d d d �|jd dd dd �|jddd dd �|jddd dd �| d¡}| ¡}|jddd dd �|jddd dd �|jdddd �|jd!d"d#d �|jd$d%d d&d �|jd'd(d d)d �|jd*d+d d,d �| d-d.¡}|jd/d0gd1d2�|jd3d0gd4d2�|jd5d6d7d8�|jd9|jd:d8�| ¡}|j�rvt  d;¡‰t  d<¡‰‡‡fd=d>„‰d?d@„|j Dƒ|_ ‡fdAd@„|jDƒ|_|j �rê|j �sÆ|  dB¡t|j |j dC�}| |j|j|j¡St|j|j|j|jgƒ�s|  dD¡|j�r0|j�s&|j�r0|  dE¡|j�rJ|j�sJ|  dF¡|jdk�r`|  dG¡|jf|j•t_tj |j¡tjd<t|j|j|j|j|j |j|j |j |j dH� }yJt!|jƒ�}t"| #¡|jdIƒ}WdQRX|jdJdddKœ} | $|| | ¡WnPt%k �r6} zt &dLtjd| f¡Wdd} ~ XYnt'k �rJYnX| (¡}|j)�sp| |j|j|j¡dS)MNrz --versionÚversionz trace 2.0)ÚactionrËz Main optionsz(One of these (or --report) must be givenz-cz--countÚ store_truez»Count the number of times each line is executed and write the counts to .cover for each module executed, in the module's directory. See also --coverdir, --file, --no-report below.)rÌÚhelpz-tz--tracez3Print each line to sys.stdout before it is executedz-lz --listfuncsz§Keep track of which functions are executed at least once and write the results to sys.stdout after the program exits. Cannot be specified alongside --trace or --count.z-Tz --trackcallsz^Keep track of caller/called pairs and write the results to sys.stdout after the program exits.Z Modifiersz-rz--reportz¶Generate a report from a counts file; does not execute any code. --file must specify the results file to read, which must have been created in a previous run with --count --file=FILEz-Rz --no-reportz^Do not generate the coverage report files. Useful if you want to accumulate over several runs.z-fz--filez+File to accumulate counts over several runs)rÎz-Cz --coverdirz†Directory where the report files go. The coverage report for . will be written to file //.coverz-mz --missingz?Annotate executable lines that were not executed with ">>>>>> "z-sz --summaryz\Write a brief summary for each file to sys.stdout. Can only be used with --count or --reportz-gz--timingzQPrefix each line with the time since the program started. Only used while tracingZFilterszCan be specified multiple timesz--ignore-moduleÚappendzqIgnore the given module(s) and its submodules (if it is a package). Accepts comma separated list of module names.)rÌÚdefaultrÎz --ignore-dirzWIgnore files in the given directory (multiple directories can be joined by os.pathsep).rú?zfile to run as main program)ÚnargsrÎÚ argumentszarguments to the programZstdlibZ platstdlibcs4tj tj |¡¡}| dˆ¡ dˆ¡}tj |¡S)Nz$prefixz $exec_prefix)rrÚ expanduserÚ expandvarsr+r )Ús)Ú _exec_prefixÚ_prefixrr Úparse_ignore_dir¦szmain..parse_ignore_dircSs$g|]}| d¡D] }| ¡‘qqS)ú,)ÚsplitÚstrip)r rˆrrrr r «szmain..cs&g|]}| tj¡D] }ˆ|ƒ‘qqSr)rÛrÚpathsep)r rˆrÖ)rÙrr r ­sz-r/--report requires -f/--file)r6r7zLmust specify one of --trace, --count, --report, --listfuncs, or --trackcallsz8cannot specify both --listfuncs and (--trace or --count)z3--summary can only be used with --count or --reportz3filename is missing: required with the main options)ržrŸr r¡r6r7r¢rŠr£)rÄrÚ __package__Ú __cached__zCannot run file %r because: %s)*ÚargparseÚArgumentParserÚ add_argumentÚadd_argument_groupÚadd_mutually_exclusive_groupÚ REMAINDERÚ parse_argsZ ignore_dirÚ sysconfigZget_pathZ ignore_moduleZreportr1ÚerrorrrnÚmissingr^r_Úanyr�rdZ listfuncsZ trackcallsrrÓr(ÚargvrrrPrr¢r8rŒr‹r¥r=ÚexitÚ SystemExitrÊZ no_report) ràÚparserZgrpZ_grpZoptsrÊÚtrgrxZglobsrCr)r×rØrÙr Úmain]s¤                         (rðr£)N)Ú__all__rUrÚrer(rçr€rXr}r»rwr9Ztimerr•r©rsrr%r/rr{r~r‰rTrrðrrrrr Ú2s: 2/  [