grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026 ”qcA{ã @s@dZddgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m ZddlmZyddlZWn'ek rãejZdd„ZYnXd d „Zd d„Zd d „ZdZejdƒZGdd„dƒZdd„Zdd„ZGdd„dƒZdd„Zdd„Z ddd„Z!dd„Z"Gdd„dƒZ#d d!„Z$dd"d#„Z%d$d%„Z&Gd&d'„d'eƒZ'd(d)„Z(d*d+„Z)d,d-„Z*d.d/„Z+dd0d1„Z,d2d3„Z-e.d4kr<e%ƒdS)5a·program/module to trace Python program or function execution Sample use, command line: trace.py -c -f counts --ignore-dir '$prefix' spam.py eggs trace.py -t --ignore-dir '$prefix' spam.py eggs trace.py --trackcalls spam.py eggs Sample use, programmatically import sys # create a Trace object, telling it what to ignore, and whether to # do tracing or line-counting or both. tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,], trace=0, count=1) # run the new command using the given tracer tracer.run('main()') # make a report, placing output in /tmp r = tracer.results() r.write_results(show_missing=True, coverdir="/tmp") ÚTraceÚCoverageResultséN)Úwarn)Ú monotoniccCstjdƒdS)N)ÚsysÚsettrace©rrú*/opt/alt/python35/lib64/python3.5/trace.pyÚ _unsettraceEsr cCstj|ƒtj|ƒdS)N)Ú threadingrr)Úfuncrrr Ú _settraceHs r cCstjdƒtjdƒdS)N)rrr rrrr r Ls cCs|jdtjdƒdS)Na Usage: %s [OPTIONS] [ARGS] Meta-options: --help Display this help then exit. --version Output version information then exit. Otherwise, exactly one of the following three options must be given: -t, --trace Print each line to sys.stdout before it is executed. -c, --count 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. -l, --listfuncs Keep track of which functions are executed at least once and write the results to sys.stdout after the program exits. -T, --trackcalls Keep track of caller/called pairs and write the results to sys.stdout after the program exits. -r, --report Generate a report from a counts file; do not execute any code. `--file' must specify the results file to read, which must have been created in a previous run with `--count --file=FILE'. Modifiers: -f, --file= File to accumulate counts over several runs. -R, --no-report Do not generate the coverage report files. Useful if you want to accumulate over several runs. -C, --coverdir= Directory where the report files. The coverage report for . is written to file //.cover. -m, --missing Annotate executable lines that were not executed with '>>>>>> '. -s, --summary Write a brief summary on stdout for each file. (Can only be used with --count or --report.) -g, --timing Prefix each line with the time since the program started. Only used while tracing. Filters, may be repeated multiple times: --ignore-module= Ignore the given module(s) and its submodules (if it is a package). Accepts comma separated list of module names --ignore-dir= Ignore files in the given directory (multiple directories can be joined by os.pathsep). r)ÚwriterÚargv)Úoutfilerrr Ú_usagePs*rz#pragma NO COVERz ^\s*(#.*)?$c@s.eZdZdddd„Zdd„ZdS)Ú_IgnoreNcCsS|stƒn t|ƒ|_|s*gndd„|Dƒ|_ddi|_dS)NcSs"g|]}tjj|ƒ‘qSr)ÚosÚpathÚnormpath)Ú.0Údrrr ú …s z$_Ignore.__init__..zé)ÚsetÚ_modsÚ_dirsÚ_ignore)ÚselfÚmodulesÚdirsrrr Ú__init__ƒs z_Ignore.__init__cCsÛ||jkr|j|S||jkr:d|j|r@r?rÚfÚerrrrr r!Øs,          zCoverageResults.__init__cCs|jdƒo|jdƒS)z_Return True if the filename does not refer to a file we want to have reported. ú<ú>)r#Úendswith)rr%rrr Úis_ignored_filenameòsz#CoverageResults.is_ignored_filenamec CsŸ|j}|j}|j}|j}|j}|j}x,|D]$}|j|dƒ||||r?Úget) rÚotherr<r>r?Z other_countsZother_calledfuncsZ other_callersÚkeyrrr rDøs       "  zCoverageResults.updateTFc!CsÚ|jrZtƒtdƒ|j}x4t|ƒD]&\}}}td|||fƒq0W|jr$tƒtdƒd}} x£t|jƒD]’\\} } } \} }}| |krÛtƒtd| dƒ| }d} | | kr| | krtd| ƒ| } td| | ||fƒqŽWi}xH|jD]=\}}|j|iƒ}||<|j||f||z %s.%s -> %s.%sz.pycNrz.coverr:édzlines cov% module (path)z%5d %3d%% %s (%s)Úwbz"Can't save counts files because %sr;éÿÿÿÿ)!r>rIÚsortedr?r<rQÚitemsrPrOrrÚdirnameÚabspathr0ÚexistsÚmakedirsr9Ú_find_executable_linenosÚ linecacheÚgetlinesÚjoinrAÚtokenizeÚdetect_encodingÚreadlineÚwrite_results_fileÚintrrBÚdumprFrrJ)!rZ show_missingÚsummaryÚcoverdirZcallsr%r&ÚfuncnameZlastfileZ lastcfileZpfileZpmodZpfuncÚcfileZcmodZcfuncZper_fileÚlinenoÚ lines_hitZsumsÚcountr8ÚlnotabÚsourceZ coverpathÚfpÚencodingÚ_Ún_hitsÚn_linesZpercentÚmrLrrr Ú write_results s~      +          zCoverageResults.write_resultsc CsRyt|dd|ƒ}WnFtk ra}z&td||fdtjƒd SWYdd}~XnXd}d} |�ÑxÉt|dƒD]¸\} } | |krÉ|jd|| ƒ| d7} |d7}n^tj| ƒrè|jd ƒn?| |krt | kr|jd ƒ|d7}n |jd ƒ|j| j d ƒƒq…WWdQRX| |fS) z'Return a coverage results file in path.Úwrqz2trace: Could not open %r for writing: %s- skippingr;rNrz%5d: z z>>>>>> é)rr) rArFrIrrJÚ enumeraterÚrx_blankÚmatchÚPRAGMA_NOCOVERÚ expandtabs) rrÚlinesrnrlrqrrLrtrsrkÚlinerrr rd`s,      !z"CoverageResults.write_results_file)r)r*r+r!rPrDrvrdrrrr r×s    VcCs@i}x3tj|ƒD]"\}}||krd||.rcSs%g|]}t|tƒr|‘qSr)Ú isinstancer°)rrrrr r#s rcSs%g|]}t|dƒr|‘qS)Ú __bases__)Úhasattr)rrˆrrr r&s z%s.%s) Úf_codeÚ co_filenamer0Úco_namerœÚgcZ get_referrersr3r)) rÚframer�r%r&riZclsnameZfuncsZdictsÚclassesrrr Úfile_module_function_of s,         zTrace.file_module_function_ofcCsD|dkr@|j|ƒ}|j|jƒ}d|j||fr?)rr<r@rršr›)rrrr Úresults„s  z Trace.results)r)r*r+r!r±r®r·rÁrŸr¡r¢r£r¥r¦rÍrrrr r¾s   0  )   cCs2tjjdtjd|fƒtjdƒdS)Nz%s: %s rr)rrJrrÚexit)Úmsgrrr Ú _err_exitŠs!rÐc#Cs,ddl}|dkr!tj}yV|j|dd…ddddddd d d d d dddddgƒ\}}Wnq|jk rê}zNtjjdtjd|fƒtjjdtjdƒtjdƒWYdd}~XnXd}d}d}d}d} d} g} g} d} d}d}d}d}x×|D]Ï\}}|dkrrttjƒtjdƒ|dkr›tjjdƒtjdƒ|dks³|dkr¼d}q@|dksÔ|dkrÝd}q@|dksõ|dkrþd}q@|d ks|d!krd}q@|d"ks7|d#kr@d}q@|d$ksX|d%krad}q@|d&ksy|d'kr‚d}q@|d(ksš|d)kr£|} q@|d*ks»|d+krÄd} q@|d,ksÜ|d-krå|} q@|d.ksý|d/krd}q@|d0krBx*|j d1ƒD]}| j |j ƒƒq"Wq@|d2kr@x»|j t j ƒD]§}t jj|ƒ}|jd3t jjtjd4d5tjdd6…ƒƒ}|jd7t jjtjd4d5tjdd6…ƒƒ}t jj|ƒ}| j |ƒqaWq@q@W|r/|s%|r/td8ƒ|pJ|pJ|pJ|pJ|sWtd9ƒ|rm|rmtd:ƒ|r„| r„td;ƒ|r¦t|ƒdkr¦td<ƒ|rÝtd=| d>| ƒ}|j| d |d?| ƒnK|t_|d}t jj |ƒdtjd| d|ƒ}yct|ƒ�}t|jƒ|dDƒ}WdQRXdE|dFdGdHddIdi}|j|||ƒWnQtk rë}z tdJtjd|fƒWYdd}~Xnt k rüYnX|j!ƒ}|s(|j| d |d?| ƒdS)KNrrztcrRf:d:msC:lTgÚhelpÚversionr™rmÚreportz no-reportrgzfile=Úmissingzignore-module=z ignore-dir=z coverdir=Ú listfuncsZ trackcallsr«z%s: %s z%Try `%s --help' for more information Fz--helpz --versionz trace 2.0 z-Tz --trackcallsTz-lz --listfuncsz-gz--timingz-tz--tracez-cz--countz-rz--reportz-Rz --no-reportz-fz--filez-mz --missingz-Cz --coverdirz-sz --summaryz--ignore-moduleú,z --ignore-dirz$prefixÚlibÚpythonéz $exec_prefixz8cannot specify both --listfuncs and (--trace or --count)zLmust specify one of --trace, --count, --report, --listfuncs, or --trackcallsz,cannot specify both --report and --no-reportz--report requires a --filezmissing name of file to runr@rrhr§r¨r©rªr“rÇr)r¬Ú __package__Ú __cached__zCannot run file %r because: %s)"ÚgetoptrrÚerrorrJrrÎrÚstdoutÚsplitÚappendÚstriprÚpathseprÚ expandvarsr5r`Ú base_prefixrÒÚbase_exec_prefixrrÐr3rrvrrAr•r”r®rFÚ SystemExitrÍ)rrÜZoptsZ prog_argvrÏr™rmrÓZ no_reportZ counts_filerÔZignore_modulesZ ignore_dirsrhrgrÕr¨r«ZoptÚvalr'ÚsrÍZprognameÚtrpr�ZglobsrLrrr ÚmainŽsò     !                       -  rêcCstdtdƒt|ƒdS)Nz(The trace.usage() function is deprecatedé)Ú_warnÚDeprecationWarningr)rrrr Úusage.s rîc@s"eZdZdddd„ZdS)ÚIgnoreNcCs'tdtdƒtj|||ƒdS)Nz$The class trace.Ignore is deprecatedrë)rìrírr!)rrr rrr r!4s zIgnore.__init__)r)r*r+r!rrrr rï3s rïcCstdtdƒt|ƒS)Nz*The trace.modname() function is deprecatedrë)rìrír0)rrrr Úmodname9s rðcCstdtdƒt|ƒS)Nz.The trace.fullmodname() function is deprecatedrë)rìrír9)rrrr Ú fullmodname>s rñcCstdtdƒt||ƒS)Nz7The trace.find_lines_from_code() function is deprecatedrë)rìrír„)r�r‚rrr Úfind_lines_from_codeCs ròcCstdtdƒt||ƒS)Nz-The trace.find_lines() function is deprecatedrë)rìrír‡)r�r‚rrr Ú find_linesHs rócCs tdtdƒt|ddƒS)Nz/The trace.find_strings() function is deprecatedrërq)rìrír’)r%rqrrr Ú find_stringsMs rôcCstdtdƒt|ƒS)Nz:The trace.find_executable_linenos() function is deprecatedrë)rìrír])r%rrr Úfind_executable_linenosRs rõr¬)/Ú__doc__Ú__all__r^rÚrerr‰rar†r¾r€rBÚwarningsrrìZtimerržr Ú ImportErrorrr r rr|r•rzrr0r9rr„r‡r’r]rrÐrêrîrïrðrñròrórôrõr)rrrr Ú1sX                -2  ¬  Ì