ACC SHELL

Path : /usr/lib/python/
File Upload :
Current File : //usr/lib/python/trace.pyc

oMc@stdZddkZddkZddkZddkZddkZddkZddkZddkZddk	Z	ddk
Z
yddkZeZWne
j
oddkZnXdZdZeidZdddYZdZd	Zd
ddYZdZd
ZdZdZdddYZdZddZedjoendS(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")
iNcCs|idtiddS(Ns	Usage: %s [OPTIONS] <file> [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 <module>.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>     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=<dir>  Directory where the report files.  The coverage
                      report for <package>.<module> is written to file
                      <dir>/<package>/<module>.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=<mod> Ignore the given module(s) and its submodules
                      (if it is a package).  Accepts comma separated
                      list of module names
--ignore-dir=<dir>    Ignore files in the given directory (multiple
                      directories can be joined by os.pathsep).
i(twritetsystargv(toutfile((s/usr/lib/python2.6/trace.pytusageDs*s#pragma NO COVERs^\s*(#.*)?$tIgnorecBs eZdddZdZRS(cCsO|pg|_|pg|_ttii|i|_hdd6|_dS(Nis<string>(t_modst_dirstmaptostpathtnormpatht_ignore(tselftmodulestdirs((s/usr/lib/python2.6/trace.pyt__init__wscCs|ii|o|i|Sxp|iD]e}||jod|i|<dSt|}||| jo#||djod|i|<dSq)W|djod|i|<dSx:|iD]/}|i|tiod|i|<dSqWd|i|<dS(Nit.i(	Rthas_keyRtlentNoneRt
startswithR	tsep(R
tfilenamet
modulenametmodtntd((s/usr/lib/python2.6/trace.pytnames~s*


"
	



	
N(t__name__t
__module__RRR(((s/usr/lib/python2.6/trace.pyRvscCs.tii|}tii|\}}|S(s-Return a plausible module name for the patch.(R	R
tbasenametsplitext(R
tbaseRtext((s/usr/lib/python2.6/trace.pytmodnamescCstii|}d}xttiD]i}tii|}|i|oA|t|tijo't|t|jo
|}qq"q"W|o|t|d}n|}|itid}tio|itid}ntii	|\}}|S(s,Return a plausible module name for the path.tiR(
R	R
tnormcaseRRRRtreplacetaltsepR (R
tcomparepathtlongesttdirR!RR"((s/usr/lib/python2.6/trace.pytfullmodnames 
*
tCoverageResultscBsDeZddddddZdZeeddZdZRS(cCsK||_|idjo
h|_n|ii|_||_|idjo
h|_n|ii|_||_|idjo
h|_n|ii|_||_||_|ioyDti	t
|id\}}}|i|i|||WqGt
ttfj
o#}tid|i|fIJqGXndS(NtrbsSkipping counts file %r: %s(tcountsRtcopytcountertcalledfuncstcallerstinfileRtpickletloadtopentupdatet	__class__tIOErrortEOFErrort
ValueErrorRtstderr(R
R.R1R3R2Rterr((s/usr/lib/python2.6/trace.pyRs*	
	
	
		
$ 
c	Cs|i}|i}|i}|i}|i}|i}x2|iD]$}|i|d||||<qCWx|iD]}d||<qxWx|iD]}d||<qWdS(s.Merge in the data from another CoverageResultsiiN(R.R1R2tkeystget(	R
totherR.R1R2tother_countstother_calledfuncst
other_callerstkey((s/usr/lib/python2.6/trace.pyR7s						
"

cCs|ioOHdGH|ii}|ix-|D]!\}}}d|||fGHq0Wn|ioHdGH|ii}|id}}	x|D]\\}
}}\}
}}|
|joHdG|
GdGH|
}d}	n|
|
jo |	|
jodG|
GH|
}	nd||||fGHqWnh}xN|iiD]=\}}|i|h}||<|i||f||<q<Wh}xs|iD]e\}}|djoqn|id	oqn|ido|d }n|djo.t
iit
ii
|}t|}n7|}t
ii|pt
i|nt|}|ot|}nh}ti|}t
ii||d
}|i||||\}}|o5|o.td||}||||f||<qqW|oZ|oS|i}|idGHx5|D])}||\}}}}d||GHq)Wn|ioby5ti|i|i|ift|iddWqtj
o}tid|IJqXndS(s!
        @param coverdir
        sfunctions called:s*filename: %s, modulename: %s, funcname: %sscalling relationships:R$s***s  -->s    %s.%s -> %s.%ss<string>s	<doctest s.pycs.pyois.coveridslines   cov%   module   (path)s%5d   %3d%%   %s   (%s)twbis"Can't save counts files because %sN(s.pycs.pyo(R1R>tsortR2R.R?t	iteritemsRtendswithRR	R
tdirnametabspathR#texiststmakedirsR+tfind_executable_linenost	linecachetgetlinestjointwrite_results_filetintRR4tdumpR6R9RR<(R
tshow_missingtsummarytcoverdirtcallsRRtfuncnametlastfilet	lastcfiletpfiletpmodtpfunctcfiletcmodtcfunctper_filetlinenot	lines_hittsumstcountR*tlnotabtsourcet	coverpathtn_hitstn_linestpercenttmodstmR=((s/usr/lib/python2.6/trace.pyt
write_resultss







	





cCsEyt|d}Wn-tj
o!}tid||fIJd	SXd}d}xt|D]\}	}
|	d}||jo-|id|||d7}|d7}nhti|
o|idnG||jo,t||	jo|id|d7}n|id|i||	i	dq\W|i
||fS(
s'Return a coverage results file in path.tws2trace: Could not open %r for writing: %s- skippingiis%5d: s       s>>>>>> i(ii(R6R9RR<t	enumerateRtrx_blanktmatchtPRAGMA_NOCOVERt
expandtabstclose(R
R
tlinesRfRcRR=RjRititlineRb((s/usr/lib/python2.6/trace.pyRQTs0








N(	RRRRR7tTruetFalseRnRQ(((s/usr/lib/python2.6/trace.pyR,s
		[c
Csh}g}|idddD]}|t|q!~}t|}t}|i}x3|D]+}	||	7}||jod||<q_q_W|S(s:Return dict where keys are lines in the line number table.iNi(t	co_lnotabtordRRztco_firstlineno(
tcodetstrstlinenost_[1]tctline_incrementsttable_lengtht	docstringRbtli((s/usr/lib/python2.6/trace.pytfind_lines_from_codexs7	

cCsTt||}x>|iD]3}t|tio|it||qqW|S(s<Return lineno dict for all code objects reachable from code.(Rt	co_constst
isinstancettypestCodeTypeR7t
find_lines(R~RRR((s/usr/lib/python2.6/trace.pyRs
cCsh}ti}t|}xti|iD]\}}}}}|tijoX|tijoD|\}	}
|\}}x)t|	|dD]}
d||
<qWqn|}q.W|i|S(sReturn a dict of possible docstring positions.

    The dict maps line numbers to strings.  There is an entry for
    line that contains only a string or a part of a triple-quoted
    string.
    i(	ttokentINDENTR6ttokenizetgenerate_tokenstreadlinetSTRINGtrangeRu(RRt
prev_ttypetftttypettstrtstarttendRxtslinetscoltelinetecolRw((s/usr/lib/python2.6/trace.pytfind_stringss	

cCstyt|di}Wn-tj
o!}tid||fIJhSXt||d}t|}t||S(sAReturn dict where keys are line numbers in the line number table.trUs%Not printing coverage data for %r: %stexec(R6treadR9RR<tcompileRR(RtprogR=R~R((s/usr/lib/python2.6/trace.pyRMs

tTracec
BseZdddddddded	ZdZdddZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZRS(iic

Cs:||_||_t|||_h|_h|_h|_d|_||_h|_	h|_
h|_d|_
|	oti|_
n|o|i|_n|o|i|_nz|o#|o|i|_|i|_nP|o|i|_|i|_n-|o|i|_|i|_n
d|_dS(sx
        @param count true iff it should count number of times each
                     line is executed
        @param trace true iff it should print out each line that is
                     being counted
        @param countfuncs true iff it should just output a list of
                     (filename, modulename, funcname,) for functions
                     that were called at least once;  This overrides
                     `count' and `trace'
        @param ignoremods a list of the names of modules to ignore
        @param ignoredirs a list of the names of directories to ignore
                     all of the (recursive) contents of
        @param infile file from which to read stored counts to be
                     added into the results
        @param outfile file in which to write the results
        @param timing true iff timing information be displayed
        iiN(R3RRtignoreR.tblabbedtpathtobasenamet	donothingttracet_calledfuncst_callerst
_caller_cacheRt
start_timettimetglobaltrace_trackcallerstglobaltracetglobaltrace_countfuncstglobaltrace_lttlocaltrace_trace_and_countt
localtracetlocaltrace_tracetlocaltrace_count(
R
ReRt
countfuncstcountcallerst
ignoremodst
ignoredirsR3Rttiming((s/usr/lib/python2.6/trace.pyRs8											cBsddk}|i}|ip$ei|iei|inz|||UWd|ipeideidnXdS(Ni(t__main__t__dict__RRtsettraceRt	threadingR(R
tcmdRtdict((s/usr/lib/python2.6/trace.pytruns	


cBs|djo
h}n|djo
h}n|ip$ei|iei|inz|||UWd|ipeideidnXdS(N(RRRRRR(R
Rtglobalstlocals((s/usr/lib/python2.6/trace.pytrunctxs






cOsZd}|ipti|inz|||}Wd|iptidnX|S(N(RRRRR(R
tfunctargstkwtresult((s/usr/lib/python2.6/trace.pytrunfuncs

c
Cs|i}|i}|ot|}nd}|i}d}||ijo)|i|dj	o|i|}qn2d|i|<g}ti|D]!}t|do||qq~}	t	|	djog}
ti|	dD]!}t
|to|
|qq~
}t	|djozg}
ti|dD]!}t|do|
|qBqB~
}t	|djo!t|d}||i|<qqn|dj	o6|i
dd}di|}d||f}n|||fS(Ntfunc_dociit	__bases__Rs%s.%s(tf_codetco_filenameR#Rtco_nameRtgct
get_referrersthasattrRRRtstrtsplitRP(R
tframeR~RRRXtclsnameRRtfuncst_[2]Rtdictst_[3]Rtclasses((s/usr/lib/python2.6/trace.pytfile_module_function_ofs6			
$$$
cCsI|djo8|i|}|i|i}d|i||f<ndS(skHandler for call events.

        Adds information about who called who to the self._callers dict.
        tcalliN(Rtf_backR(R
Rtwhytargt	this_functparent_func((s/usr/lib/python2.6/trace.pyR=s
cCs1|djo |i|}d|i|<ndS(soHandler for call events.

        Adds (filename, modulename, funcname) to the self._calledfuncs dict.
        RiN(RR(R
RRRR((s/usr/lib/python2.6/trace.pyRHs
cCs|djo|i}|iidd}|oet|}|dj	oH|ii||}|p(|iod||ifGHn|i	SqqdSndS(sHandler for call events.

        If the code block being entered is to be ignored, returns `None',
        else returns self.localtrace.
        Rt__file__s! --- modulename: %s, funcname: %sN(
Rt	f_globalsR?RR#RRRRR(R
RRRR~RRt	ignore_it((s/usr/lib/python2.6/trace.pyRQs
	

cCs|djo|ii}|i}||f}|ii|dd|i|<|iodti|iGntii	|}d||t
i||fGn|iS(NRxiis%.2fs
%s(%d): %s(
RRtf_linenoR.R?RRR	R
RRNtgetlineR(R
RRRRRbRDtbname((s/usr/lib/python2.6/trace.pyRhs
	 
	cCs|djok|ii}|i}|iodti|iGntii|}d||ti	||fGn|i
S(NRxs%.2fs
%s(%d): %s(RRRRRR	R
RRNRR(R
RRRRRbR((s/usr/lib/python2.6/trace.pyRws
	
	cCsY|djoE|ii}|i}||f}|ii|dd|i|<n|iS(NRxii(RRRR.R?R(R
RRRRRbRD((s/usr/lib/python2.6/trace.pyRs
	$c
Cs1t|id|id|id|id|iS(NR3RR1R2(R,R.R3RRR(R
((s/usr/lib/python2.6/trace.pytresultss		((N(RRRRzRRRRRRRRRRRR(((s/usr/lib/python2.6/trace.pyRs1	

		-						
	cCs2tiidtid|ftiddS(Ns%s: %s
ii(RR<RRtexit(tmsg((s/usr/lib/python2.6/trace.pyt	_err_exits!cCsKddk}|djo
ti}nyP|i|dddddddd	d
ddd
dddddg\}}Wna|ij
oR}tiidtid|ftiidtidtidnXd}d}d}d}d}	d}
g}g}d}
d}t}t}t}x8|D]0\}}|djot	ti
tidn|djo!ti
idtidn|djp
|djo
t}q/n|djp
|djo
t}q/n|djp
|djo
t}q/n|djp
|d jo
d}q/n|d!jp
|d"jo
d}q/n|d#jp
|d$jo
d}q/n|d%jp
|d&jo
d}q/n|d'jp
|d(jo
|}	q/n|d)jp
|d*jo
d}
q/n|d+jp
|d,jo
|}
q/n|d-jp
|d.jo
d}q/n|d/jo4x*|id0D]}|i
|iq^Wq/n|d1jox|itiD]}tii|}|id2tiititid3tid4 }|id5tiititid3tid4 }tii|}|i
|qWq/ndp
td6q/W|o|p|otd7n|p|p|p|p|ptd8n|o|otd9n|o|	otd:n|o!t|djotd;n|o2td<|	d=|	}|i|
d
|d>|
n|t_|d}tii|dtid<t||d?|d@|dA|dB|d<|	d=|	d|}y|i dC|fWnBt!j
o$}tdDtid|fnt"j
onX|i#}|p|i|
d
|d>|
ndS(ENiistcrRf:d:msC:lTgthelptversionRRetreports	no-reportRUsfile=tmissingsignore-module=signore-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$prefixtpythonis$exec_prefixsShould never get heres8cannot 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 runR3RRVRRRRsexecfile(%r)sCannot run file %r because: %s($tgetoptRRRterrorR<RRRzRtstdoutRyRtappendtstripR	tpathsepR
t
expandvarsR&RPtprefixtlibRtexec_prefixRtAssertionErrorRRR,RnRRR9t
SystemExitR(RRtoptst	prog_argvRRReRt	no_reporttcounts_fileRtignore_modulestignore_dirsRVRURRRtopttvalRtsRtprognamettR=((s/usr/lib/python2.6/trace.pytmains

	!




		#	
R((((t__doc__RNR	treRRRRRRRtcPickleR4tImportErrorRRsRRqRR#R+R,RRRRMRRRRR(((s/usr/lib/python2.6/trace.pyt<module>1s>
	-5							


ACC SHELL 2018