grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026î   fÿzã@sldZddgZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m ZyddlmZWn"ek rÒddlmZYnXyddlZWn'ek r ejZdd „ZYnXd d „Zd d „Zd d„ZdZejdƒZGdd„dƒZdd„Zdd„ZGdd„dƒZdd„Zdd„Z ddd„Z!dd„Z"Gd d„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/d0„Z+dd1d2„Z,d3d4„Z-e.d5krhe%ƒndS)6a·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)Ú monotonic)ÚtimecCstjdƒdS)N)ÚsysÚsettrace©r r ú*/opt/alt/python34/lib64/python3.4/trace.pyÚ _unsettraceHsr cCstj|ƒtj|ƒdS)N)Ú threadingrr)Úfuncr r r Ú _settraceKs rcCstjdƒtjdƒdS)N)rrr r r r r r Os 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)Úoutfiler r r Ú_usageSs*rz#pragma NO COVERz ^\s*(#.*)?$c@s.eZdZdddd„Zdd„ZdS)Ú_IgnoreNcCsT|stƒn t|ƒ|_|s*gndd„|Dƒ|_idd6|_dS)NcSs"g|]}tjj|ƒ‘qSr )ÚosÚpathÚnormpath)Ú.0Údr r r ú ˆs z$_Ignore.__init__..éz)ÚsetÚ_modsÚ_dirsÚ_ignore)ÚselfÚmodulesÚdirsr r r Ú__init__†s z_Ignore.__init__cCsÛ||jkr|j|S||jkr:d|j|)r$Úendswith)rr&r r r Úis_ignored_filenameõsz#CoverageResults.is_ignored_filenamec CsŸ|j}|j}|j}|j}|j}|j}x,|D]$}|j|dƒ||||z %s.%s -> %s.%sú.pycú.pyoNrz.coverr;édzlines cov% module (path)z%5d %3d%% %s (%s)Úwbz"Can't save counts files because %sr<)rTrUéÿÿÿÿ)!r?rJÚsortedr@r=rQÚitemsrPrOrrÚdirnameÚabspathr1ÚexistsÚmakedirsr:Ú_find_executable_linenosÚ linecacheÚgetlinesÚjoinrDÚtokenizeÚdetect_encodingÚreadlineÚwrite_results_fileÚintrrBÚdumprGrrK)!rZ show_missingÚsummaryÚcoverdirZcallsr&r'ÚfuncnameZlastfileZ lastcfileZpfileZpmodZpfuncÚcfileZcmodZcfuncZper_fileÚlinenoÚ lines_hitZsumsÚcountr9ÚlnotabÚsourceZ coverpathÚfpÚencodingÚ_Ún_hitsÚn_linesZpercentÚmrLr r r Ú write_results s|      +    !       zCoverageResults.write_resultsc CsNyt|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~W|j ƒ| |fS) z'Return a coverage results file in path.Úwrsz2trace: Could not open %r for writing: %s- skippingr<rNrz%5d: z z>>>>>> é)rr) rDrGrJrrKÚ enumeraterÚrx_blankÚmatchÚPRAGMA_NOCOVERÚ expandtabsÚclose) rrÚlinesrprnrsrrLrvrurmÚliner r r rfbs,       z"CoverageResults.write_results_file)r*r+r,r"rPrErxrfr r r r rÚs    UcCsCi}x6tj|ƒD]%\}}||krd||.rcSs%g|]}t|tƒr|‘qSr )Ú isinstancer´)rrr r r r%s rcSs%g|]}t|dƒr|‘qS)Ú __bases__)Úhasattr)rr‹r r r r(s z%s.%s) Úf_codeÚ co_filenamer1Úco_namer ÚgcZ get_referrersr4r*) rÚframer„r&r'rkZclsnameZfuncsZdictsZclassesr r r Úfile_module_function_ofs,        zTrace.file_module_function_ofcCsG|dkrC|j|ƒ}|j|jƒ}d|j||f| d?| ƒ}|j| d |d@| ƒnQ|t_|d}t jj |ƒdtjd| d?| d|ƒ}yft|ƒ�}t|jƒ|dEƒ}WdQXi|dF6dGdH6ddI6ddJ6}|j|||ƒWnQt k r?}z tdKtjd|fƒWYdd}~Xnt!k rPYnX|j"ƒ}|s|j| d |d@| ƒndS)LNrrztcrRf:d:msC:lTgÚhelpÚversionr�roÚreportz no-reportrizfile=Ú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_prefixzShould never get herez8cannot 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 runrArrjr«r¬r­r®r—rÊr°r*Ú __package__Ú __cached__zCannot run file %r because: %s)#ÚgetoptrrÚerrorrKrrÑrÚstdoutÚsplitÚappendÚstriprÚpathseprÚ expandvarsr6rbÚ base_prefixrÕÚbase_exec_prefixrÚAssertionErrorrÓr4rrxrrDr™r˜r²rGÚ SystemExitrÐ)rrßZoptsZ prog_argvrÒr�rorÖZ no_reportZ counts_filer×Zignore_modulesZ ignore_dirsrjrirØr¬r¯ZoptÚvalr(ÚsrÐZprognameÚtrrr„ZglobsrLr r r Úmain�sô     !                     -  rîcCstdtdƒt|ƒdS)Nz(The trace.usage() function is deprecatedé)Ú_warnÚDeprecationWarningr)rr r r Úusage0s ròc@s"eZdZdddd„ZdS)ÚIgnoreNcCs'tdtdƒtj|||ƒdS)Nz$The class trace.Ignore is deprecatedrï)rðrñrr")rr r!r r r r"6s zIgnore.__init__)r*r+r,r"r r r r ró5s rócCstdtdƒt|ƒS)Nz*The trace.modname() function is deprecatedrï)rðrñr1)rr r r Úmodname;s rôcCstdtdƒt|ƒS)Nz.The trace.fullmodname() function is deprecatedrï)rðrñr:)rr r r Ú fullmodname@s rõcCstdtdƒt||ƒS)Nz7The trace.find_lines_from_code() function is deprecatedrï)rðrñr‡)r„r…r r r Úfind_lines_from_codeEs röcCstdtdƒt||ƒS)Nz-The trace.find_lines() function is deprecatedrï)rðrñrŠ)r„r…r r r Ú find_linesJs r÷cCs tdtdƒt|ddƒS)Nz/The trace.find_strings() function is deprecatedrïrs)rðrñr–)r&rsr r r Ú find_stringsOs røcCstdtdƒt|ƒS)Nz:The trace.find_executable_linenos() function is deprecatedrï)rðrñr_)r&r r r Úfind_executable_linenosTs rùr°)/Ú__doc__Ú__all__r`rÚrerrŒrcr‰rÂrƒrBÚwarningsrrðrrr¢Ú ImportErrorr rrr rr~r™r|rr1r:rr‡rŠr–r_rrÓrîròrórôrõrör÷rørùr*r r r r Ú1s^                 -2  «  Ì