zfc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z yddl Z e Z Wne k rddl Z nXyddlZWn#e k rejZdZnXdZdZdZdZejdZd dd YZd Zd Zd ddYZdZdZdZdZdddYZdZddZ!e"dkre!ndS(sprogram/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.prefix, sys.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") iNcCstjddS(N(tsystsettracetNone(((s/usr/lib64/python2.7/trace.pyt _unsettraceHscCstj|tj|dS(N(t threadingRR(tfunc((s/usr/lib64/python2.7/trace.pyt _settraceKs cCstjdtjddS(N(RRRR(((s/usr/lib64/python2.7/trace.pyROs cCs|jdtjddS(Ns 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). i(twriteRtargv(toutfile((s/usr/lib64/python2.7/trace.pytusageSs*s#pragma NO COVERs ^\s*(#.*)?$tIgnorecBs eZdddZdZRS(cCsM|p g|_|pg|_ttjj|j|_idd6|_dS(Nis(t_modst_dirstmaptostpathtnormpatht_ignore(tselftmodulestdirs((s/usr/lib64/python2.7/trace.pyt__init__scCs||jkr|j|Sxk|jD]`}||krGd|j|s      "cCs|jrWHdGH|jj}|jx,|D]!\}}}d|||fGHq/Wn|jrHdGH|jj}|jd}} x|D]\\} } } \} }}| |krHdG| GdGH| }d} n| | kr| | krdG| GH| } nd| | ||fGHqWni}xN|jjD]=\}}|j|i}||<|j||f||s %s.%s -> %s.%sss >>>>> i(ii( R=R@RRCt enumerateRtrx_blanktmatchtPRAGMA_NOCOVERt expandtabstclose( RRtlinesRlRiR RDRpRotitlineRh((s/usr/lib64/python2.7/trace.pyRXes.          N( R!R"RRR>tTruetFalseRtRX(((s/usr/lib64/python2.7/trace.pyR3s   [cCsCi}x6tj|D]%\}}||krd||t find_lines(RRRtc((s/usr/lib64/python2.7/trace.pyRs cCsi}tj}t|}xtj|jD]\}}}}}|tjkr|tjkr|\} } |\} } x(t| | dD]} d|| |s1|r>td7n|pY|pY|pY|pY|sitd8n|r|rtd9n|r| rtd:n|rt|dkrtd;n|rtd<| d=| }|j| d |d>| n>|t_|d}tjj |dtjdt"k r}tdItjd|fnt#k rnX|j$}|s6|j| d |d>| ndS(JNiistcrRf:d:msC:lTgthelptversionRRktreports no-reportR[sfile=tmissingsignore-module=s ignore-dir=s coverdir=t listfuncst trackcallsRs%s: %s is%Try `%s --help' for more information s--helps --versions trace 2.0 s-Ts --trackcallss-ls --listfuncss-gs--timings-ts--traces-cs--counts-rs--reports-Rs --no-reports-fs--files-ms --missings-Cs --coverdirs-ss --summarys--ignore-modulet,s --ignore-dirs$prefixtlibtpythonis $exec_prefixs8cannot specify both --listfuncs and (--trace or --count)sLmust specify one of --trace, --count, --report, --listfuncs, or --trackcallss,cannot specify both --report and --no-reports--report requires a --filesmissing name of file to runR:R R\RRRRRRRR!t __package__t __cached__sCannot run file %r because: %s(%tgetoptRRRterrorRCRRRR tstdoutRtsplittappendtstripRtpathsepRt expandvarsR+RWtprefixRt exec_prefixRRRR3RtRR=RRRR@t SystemExitR(RRtoptst prog_argvRRRkRt no_reportt counts_fileRtignore_modulest ignore_dirsR\R[RRRtopttvalRtsRtprognametttfpRtglobsRD((s/usr/lib64/python2.7/trace.pytmains     !                      R((((#t__doc__RURtreRRRRRRRtcPickleR;t ImportErrorRRRRR RyRRwR R'R2R3RRRRTRRRR R!(((s/usr/lib64/python2.7/trace.pyt1sL                   -5