%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/trace.cpython-38.pyc

U

nat@sdZddgZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
ZddlZdZGdddZd	d
ZddZGd
ddZddZddZdddZddZGdddZddZedkredS)aprogram/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")
TraceCoverageResultsN)	monotonicz#pragma NO COVERc@seZdZdddZddZdS)_IgnoreNcCs:|s
tnt||_|sgndd|D|_ddi|_dS)NcSsg|]}tj|qS)ospathnormpath.0drr!/usr/local/lib/python3.8/trace.py
<listcomp>Gsz$_Ignore.__init__.<locals>.<listcomp>z<string>)set_mods_dirs_ignore)selfmodulesdirsrrr
__init__Es
z_Ignore.__init__cCs||jkr|j|S||jkr,d|j|<dS|jD]"}||dr2d|j|<dSq2|dkrld|j|<dS|jD]$}||tjrrd|j|<dSqrd|j|<dS)Nr.r)rr
startswithrrsep)rfilename
modulenamemodrrrr
namesKs$









z
_Ignore.names)NN)__name__
__module____qualname__rrrrrr
rDs
rcCs tj|}tj|\}}|S)z-Return a plausible module name for the patch.)rrbasenamesplitext)rbaserextrrr
_modnamevsr&cCstj|}d}tjD]@}tj|}||r|t|tjkrt|t|kr|}q|rr|t|dd}n|}tj|\}}|tjd}tj	r|tj	d}tj
|\}}|dS)z,Return a plausible module name for the path.rNr)rrnormcasesysrlenr
splitdrivereplacealtsepr#lstrip)rZcomparepathZlongestdirr$Zdriverr%rrr
_fullmodname}s 
r0c@s:eZdZdddZddZddZdd
dZddd
ZdS)rNc
Cs||_|jdkri|_|j|_||_|jdkr8i|_|j|_||_|jdkrZi|_|j|_||_||_|jrz@t|jd}t	|\}}}W5QRX|
||||Wn@tt
tfk
r}ztd|j|ftjdW5d}~XYnXdS)NrbzSkipping counts file %r: %sfile)countscopyZcountercalledfuncscallersinfileoutfileopenpickleloadupdate	__class__OSErrorEOFError
ValueErrorprintr)stderr)rr4r6r8r7r9ferrrrr
rs2


zCoverageResults.__init__cCs|do|dS)z_Return True if the filename does not refer to a file
        we want to have reported.
        <>)rendswith)rrrrr
is_ignored_filenamesz#CoverageResults.is_ignored_filenamec	Csn|j}|j}|j}|j}|j}|j}|D]}||d||||<q(|D]}d||<qJ|D]}d||<q\dS)z.Merge in the data from another CoverageResultsrrN)r4r6r7get)	rotherr4r6r7Zother_countsZother_calledfuncsZ
other_callerskeyrrr
r=s
zCoverageResults.updateTFc"
Cs|jr@ttd|j}t|D]\}}}td|||fq"|jrttdd}}	t|jD]h\\}
}}\}
}}|
|krttd|
d|
}d}	|
|
kr|	|
krtd|
|
}	td||||fqfi}|jD].\}}||i}||<|j||f||<qi}|D]\}}||r0q|drH|d	d
}|d	krpt	j
t	j
|}t
|}n$|}t	j
|st	|t|}|rt|}ni}t|}t	j
||d}t|d}t|j\}}W5QRX||||||\}}|r|rtd
||}||||f||<q|rt|rttdt|D]&}||\}}}}td||qL|jrz6t|jd } t|j|j|jf| dW5QRXWn6tk
r}!ztd|!tj dW5d	}!~!XYnXd	S)af
        Write the coverage results.

        :param show_missing: Show lines that had no hits.
        :param summary: Include coverage summary per module.
        :param coverdir: If None, the results of each module are placed in its
                         directory, otherwise it is included in the directory
                         specified.
        zfunctions called:z*filename: %s, modulename: %s, funcname: %szcalling relationships:r'z***z  -->z    %s.%s -> %s.%sz.pycNz.coverr1dzlines   cov%   module   (path)z%5d   %3d%%   %s   (%s)wbrz"Can't save counts files because %sr2)!r6rBsortedr7r4rJitemsrIrHrrdirnameabspathr&existsmakedirsr0_find_executable_linenos	linecachegetlinesjoinr:tokenizedetect_encodingreadlinewrite_results_fileintr9r;dumpr?r)rC)"rZshow_missingsummarycoverdirZcallsrrfuncnameZlastfileZ	lastcfileZpfileZpmodZpfunccfileZcmodZcfuncZper_filelineno	lines_hitZsumscountr/lnotabsourceZ	coverpathfpencoding_n_hitsn_linespercentmrDrErrr

write_resultss






zCoverageResults.write_resultsc
Cszt|d|d}Wn>tk
rP}z td||ftjdWYdSd}~XYnXd}d}	|t|dD]r\}
}|
|kr|d	||
|	d7}	|d7}n.|
|krt|kr|d
|d7}n
|d||dqjW5QRX|	|fS)
z'Return a coverage results file in path.wrjz3trace: Could not open %r for writing: %s - skippingr2)rrNrrz%5d: z>>>>>> z       )	r:r?rBr)rC	enumeratewritePRAGMA_NOCOVER
expandtabs)rrlinesrgrerjr9rErmrlrdlinerrr
r](s.



z"CoverageResults.write_results_file)NNNNN)TFN)N)rr r!rrIr=rpr]rrrr
rs

\cCs,i}t|D]\}}||krd||<q|S)z:Return dict where keys are lines in the line number table.r)disZfindlinestarts)codestrslinenosrkrdrrr
_find_lines_from_codeHs

r~cCs4t||}|jD]}t|r|t||q|S)z<Return lineno dict for all code objects reachable from code.)r~	co_constsinspectZiscoder=_find_lines)r{r|r}crrr
rRs



rc	Csi}tj}t||dj}t|j}|D]R\}}}}	}
|tjkrv|tjkrv|\}}|	\}
}t||
dD]}d||<qh|}q(W5QRX|S)zReturn 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.
    rrr)tokenINDENTr:rZgenerate_tokensr\STRINGrange)rrjrZ
prev_ttyperDtokZttypeZtstrstartendryZslineZscolZelineZecolirrr

_find_strings^s


rc
Csz(t|}|}|j}W5QRXWn@tk
rh}z"td||ftjdiWYSd}~XYnXt||d}t	||}t
||S)zAReturn dict where keys are line numbers in the line number table.z%Not printing coverage data for %r: %sr2Nexec)rZr:readrjr?rBr)rCcompilerr)rrDprogrjrEr{r|rrr
rVus
rVc	@sveZdZdddZdd	Zd d
dZdd
Zde_ddZddZ	ddZ
ddZddZddZ
ddZddZdS)!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)ax
        @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
        rNr)r8r9rignorer4Zpathtobasename	donothingtrace_calledfuncs_callers
_caller_cache
start_time_timeglobaltrace_trackcallersglobaltraceglobaltrace_countfuncsglobaltrace_ltlocaltrace_trace_and_count
localtracelocaltrace_tracelocaltrace_count)
rrfr
countfuncscountcallers
ignoremods
ignoredirsr8r9timingrrr
rs6




zTrace.__init__cCs ddl}|j}||||dS)Nr)__main____dict__runctx)rcmdrdictrrr
runsz	Trace.runc	Csh|dkri}|dkri}|js6t|jt|jzt|||W5|jsbtdtdXdS)N)r	threadingsettracerr)r)rrglobalslocalsrrr
rs
zTrace.runctxc	Ost|dkr|^}}}nV|s&tdnHd|krZ|d}|^}}ddl}|jdtddntdt|dd}|jst|j	z|||}W5|jstdX|S)	Nz8descriptor 'runfunc' of 'Trace' object needs an argumentfuncrz0Passing 'func' as keyword argument is deprecated)
stacklevelz7runfunc expected at least 1 positional argument, got %dr)
r*	TypeErrorpopwarningswarnDeprecationWarningrr)rr)argskwrrrresultrrr
runfuncs.


z
Trace.runfuncz($self, func, /, *args, **kw)c
Cs|j}|j}|rt|}nd}|j}d}||jkrL|j|dk	r|j|}nd|j|<ddt|D}t|dkrddt|dD}t|dkrddt|dD}	t|	dkr|	dj}||j|<|dk	rd||f}|||fS)NcSsg|]}t|r|qSr)rZ
isfunction)rrDrrr
rs
z1Trace.file_module_function_of.<locals>.<listcomp>rcSsg|]}t|tr|qSr)
isinstancerr
rrr
rs
rcSsg|]}t|dr|qS)	__bases__)hasattr)rrrrr
rs
z%s.%s)	f_codeco_filenamer&co_namergcZ
get_referrersr*r)
rframer{rrrbZclsnameZfuncsZdictsclassesrrr
file_module_function_ofs,




zTrace.file_module_function_ofcCs0|dkr,||}||j}d|j||f<dS)zkHandler for call events.

        Adds information about who called who to the self._callers dict.
        callrN)rf_backr)rrwhyarg	this_funcZparent_funcrrr
rs
zTrace.globaltrace_trackcallerscCs |dkr||}d|j|<dS)zoHandler for call events.

        Adds (filename, modulename, funcname) to the self._calledfuncs dict.
        rrN)rr)rrrrrrrr
rs
zTrace.globaltrace_countfuncscCsj|dkrf|j}|jdd}|rbt|}|dk	rf|j||}|sf|jrZtd||jf|j	SndSdS)zHandler for call events.

        If the code block being entered is to be ignored, returns `None',
        else returns self.localtrace.
        r__file__Nz! --- modulename: %s, funcname: %s)
r	f_globalsrJr&rrrrBrr)rrrrr{rrZ	ignore_itrrr
r szTrace.globaltrace_ltcCs|dkr~|jj}|j}||f}|j|dd|j|<|jrTtdt|jddtj	
|}td||t||fdd|j
S)	Nryrr%.2f r
%s(%d): %sr')rrf_linenor4rJrrBrrrr"rWgetliner)rrrrrrdrLbnamerrr
r7s
z Trace.localtrace_trace_and_countcCsd|dkr^|jj}|j}|jr4tdt|jddtj|}td||t	
||fdd|jS)Nryrrrrr')rrrrrBrrrr"rWrr)rrrrrrdrrrr
rFs
zTrace.localtrace_tracecCs<|dkr6|jj}|j}||f}|j|dd|j|<|jS)Nryrr)rrrr4rJr)rrrrrrdrLrrr
rSszTrace.localtrace_countcCst|j|j|j|j|jdS)N)r8r9r6r7)rr4r8r9rr)rrrr
results[s

z
Trace.results)	rrrrrrNNF)NN)rr r!rrrr__text_signature__rrrrrrrrrrrr
rs&
2

)	
csddl}|}|jdddd|dd}|jdd	d
dd|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|jd5d
d6d7d2|jd8d9d:d;|jd<|jd=d;|}|jrt	d>t	d?fd@dAdBdC|j
D|_
fdDdC|jD|_|jr|js|
dEt|j|jdF}||j|j|jSt|j|j|j|jgs |
dG|jrB|js8|jrB|
dH|jr\|js\|
dI|jdkrr|
dJt|j|j|j|j|j
|j|j|j|jdK	}z|jrddl}|j}||\}	}
}|jf|jt _!dL|j|
j"|
j#|
ddM}n^|jf|jt _!t$j%&|jt j%d<t'|jdN}
t(|
)|jdO}W5QRX|jdLdddP}|*|||WnPt+k
r}zt ,dQt j!d|fW5d}~XYnt-k
rYnX|.}|j/s||j|j|jdS)RNrz	--versionversionz	trace 2.0)actionrzMain optionsz(One of these (or --report) must be givenz-cz--count
store_truezCount 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.)rhelpz-tz--tracez3Print each line to sys.stdout before it is executedz-lz--listfuncszKeep 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--reportzGenerate 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)rz-Cz
--coverdirzDirectory where the report files go. The coverage report for <package>.<module> will be written to file <dir>/<package>/<module>.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-moduleappendzqIgnore the given module(s) and its submodules (if it is a package). Accepts comma separated list of module names.)rdefaultrz--ignore-dirzWIgnore files in the given directory (multiple directories can be joined by os.pathsep).z--moduleFzTrace a module. progname?zfile to run as main program)nargsr	argumentszarguments to the programZstdlibZ
platstdlibcs4tjtj|}|dd}tj|S)Nz$prefixz$exec_prefix)rr
expanduser
expandvarsr,r	)s)_exec_prefix_prefixrr
parse_ignore_dirszmain.<locals>.parse_ignore_dircSs$g|]}|dD]}|qqS),)splitstrip)rrrrrr
rszmain.<locals>.<listcomp>cs&g|]}|tjD]}|qqSr)rrpathsep)rrr)rrr
rsz-r/--report requires -f/--file)r8r9zLmust 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 --reportz3progname is missing: required with the main options)rrrrr8r9rr)rr__package__
__loader____spec__
__cached__r1r)rrrrzCannot run file %r because: %s)0argparseArgumentParseradd_argumentadd_argument_groupadd_mutually_exclusive_group	REMAINDER
parse_argsZ
ignore_dir	sysconfigZget_pathZ
ignore_moduleZreportr3errorrrpmissingr`raanyrrfZ	listfuncsZ
trackcallsrrrmodulerunpyZ_get_module_detailsrrr)argvparentloaderrrrRr:rrrr?exit
SystemExitrZ	no_report)rparsergrpZ_grpZoptsrtrmodule_nameZmod_nameZmod_specr{ZglobsrirEr)rrrr
mainas





















	(rr)N)__doc____all__rWrr)rrrZrrrzr;timerrrrvrr&r0rr~rrrVrrrrrrr
<module>s:20

_

Zerion Mini Shell 1.0