???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................
]5{                 @   s:  d  d g Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z
 d d l m Z d d l m Z y d d l Z Wn' e k
 r e j Z d d   Z Yn Xd d	   Z d
 d   Z d d   Z d Z e j d  Z Gd d   d  Z d d   Z d d   Z Gd d   d  Z d d   Z d d   Z d d d  Z  d d   Z! Gd d    d   Z" d d    Z# d d! d"  Z$ d# d$   Z% Gd% d&   d& e  Z& d' d(   Z' d) d*   Z( d+ d,   Z) d- d.   Z* d d/ d0  Z+ d1 d2   Z, e- d3 k r6e$   d S)4TraceCoverageResults    N)warn)	monotonicc               C   s   t  j d   d  S)N)syssettrace r   r   */opt/alt/python35/lib64/python3.5/trace.py_unsettraceE   s    r
   c             C   s   t  j |   t j |   d  S)N)	threadingr   r   )funcr   r   r	   	_settraceH   s    r   c               C   s   t  j d   t j d   d  S)N)r   r   r   r   r   r   r	   r
   L   s    c             C   s   |  j  d t j d  d  S)Na	  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).
r   )writer   argv)outfiler   r   r	   _usageP   s    *r   z#pragma NO COVERz^\s*(#.*)?$c               @   s.   e  Z d  Z d d d d  Z d d   Z d S)_IgnoreNc             C   sS   | s t    n	 t  |  |  _ | s* g  n d d   | D |  _ d d i |  _ d  S)Nc             S   s"   g  |  ] } t  j j |   q Sr   )ospathnormpath).0dr   r   r	   
<listcomp>   s   	z$_Ignore.__init__.<locals>.<listcomp>z<string>   )set_mods_dirs_ignore)selfmodulesdirsr   r   r	   __init__   s    z_Ignore.__init__c             C   s   | |  j  k r |  j  | S| |  j k r: d |  j  | <d Sx5 |  j D]* } | j | d  rD d |  j  | <d SqD W| d  k r d |  j  | <d Sx8 |  j D]- } | j | t j  r d |  j  | <d Sq Wd |  j  | <d S)Nr   .r   )r   r   
startswithr   r   sep)r   filename
modulenamemodr   r   r   r	   names   s$    z_Ignore.names)__name__
__module____qualname__r!   r(   r   r   r   r	   r      s   r   c             C   s.   t  j j |   } t  j j |  \ } } | S)N)r   r   basenamesplitext)r   baser%   extr   r   r	   _modname   s    r0   c             C   s  t  j j |   } d } xi t j D]^ } t  j j |  } | j |  r" | t |  t  j k r" t |  t |  k r" | } q" W| r |  t |  d d   } n |  } t  j j |  \ } } | j t  j d  } t  j	 r | j t  j	 d  } t  j j
 |  \ } } | j d  S)N r   r"   )r   r   normcaser   r#   lenr$   
splitdrivereplacealtsepr-   lstrip)r   ZcomparepathZlongestdirr.   Zdriver%   r/   r   r   r	   _fullmodname   s     (
	r9   c               @   sg   e  Z d  Z d d d d d d d  Z d d   Z d d   Z d d	 d d
 d  Z d d d  Z d S)r   Nc             C   s]  | |  _  |  j  d  k r! i  |  _  |  j  j   |  _ | |  _ |  j d  k rT i  |  _ |  j j   |  _ | |  _ |  j d  k r i  |  _ |  j j   |  _ | |  _ | |  _ |  j rYyT t |  j d   } t j	 |  \ } } } Wd  QRX|  j
 |  j | | |   WnN t t t f k
 rX} z% t d |  j | f d t j WYd  d  } ~ Xn Xd  S)NrbzSkipping counts file %r: %sfile)countscopyZcountercalledfuncscallersinfiler   openpickleloadupdate	__class__OSErrorEOFError
ValueErrorprintr   stderr)r   r<   r>   r@   r?   r   ferrr   r   r	   r!      s,    									 zCoverageResults.__init__c             C   s   | j  d  o | j d  S)N<>)r#   endswith)r   r%   r   r   r	   is_ignored_filename   s    z#CoverageResults.is_ignored_filenamec       	      C   s   |  j  } |  j } |  j } | j  } | j } | j } x, | D]$ } | j | d  | | | | <q= Wx | D] } d | | <ql Wx | D] } d | | <q Wd  S)Nr   r   )r<   r>   r?   get)	r   otherr<   r>   r?   Zother_countsZother_calledfuncsZother_callerskeyr   r   r	   rD      s    						"zCoverageResults.updateTFc       !      C   s  |  j  rZ t   t d  |  j  } x4 t |  D]& \ } } } t d | | | f  q0 W|  j r$t   t d  d } }	 x t |  j  D] \ \ }
 } } \ } } } |
 | k r t   t d |
 d  |
 } d }	 | |
 k r|	 | k rt d |  | }	 t d | | | | f  q Wi  } xH |  j D]= \ } } | j | i   } | | <|  j | | f | | <q4Wi  } x| j   D]x\ } } |  j |  rq| j d  r| d  d  } | d  k rt	 j
 j t	 j
 j |   } t |  } n1 | } t	 j
 j |  s#t	 j |  t |  } | rDt |  } n i  } | rt j |  } t	 j
 j | | d
  } t | d   } t j | j  \ } } Wd  QRX|  j | | | | |  \ } } | r| rt d | |  } | | | | f | | <qW| rY| rYt d  x< t |  D]. } | | \ } } } } t d | |  q'W|  j ry5 t j |  j |  j  |  j f t |  j d  d	  Wn< t k
 r}  z t d |  d t j  WYd  d  }  ~  Xn Xd  S)Nzfunctions called:z*filename: %s, modulename: %s, funcname: %szcalling relationships:r1   z***z  -->z    %s.%s -> %s.%sz.pycr   z.coverr:   d   zlines   cov%   module   (path)z%5d   %3d%%   %s   (%s)wbz"Can't save counts files because %sr;   )!r>   rI   sortedr?   r<   rQ   itemsrP   rO   r   r   dirnameabspathr0   existsmakedirsr9   _find_executable_linenos	linecachegetlinesjoinrA   tokenizedetect_encodingreadlinewrite_results_fileintr   rB   dumprF   r   rJ   )!r   Zshow_missingsummarycoverdirZcallsr%   r&   funcnameZlastfileZ	lastcfileZpfileZpmodZpfunccfileZcmodZcfuncZper_filelineno	lines_hitZsumscountr8   lnotabsourceZ	coverpathfpencoding_n_hitsn_linespercentmrL   r   r   r	   write_results
  s~    	
		

+
	zCoverageResults.write_resultsc             C   sR  y t  | d d | } WnF t k
 ra } z& t d | | f d t j d SWYd  d  } ~ Xn Xd } d }	 |  x t | d  D] \ }
 } |
 | k r | j d | |
  |	 d 7}	 | d 7} n^ t j |  r | j d  n? |
 | k rt	 | k r| j d	  | d 7} n | j d  | j | j
 d
   q WWd  QRX|	 | f S)Nwrq   z2trace: Could not open %r for writing: %s- skippingr;   r   r   z%5d: z       z>>>>>>    )r   r   )rA   rF   rI   r   rJ   	enumerater   rx_blankmatchPRAGMA_NOCOVER
expandtabs)r   r   linesrn   rl   rq   r   rL   rt   rs   rk   liner   r   r	   rd   `  s,    
!z"CoverageResults.write_results_file)r)   r*   r+   r!   rP   rD   rw   rd   r   r   r   r	   r      s   	Vc             C   s@   i  } x3 t  j |   D]" \ } } | | k r d | | <q W| S)Nr   )disZfindlinestarts)codestrslinenosrr   rk   r   r   r	   _find_lines_from_code  s
    r   c             C   sL   t  |  |  } x6 |  j D]+ } t j |  r | j t | |   q W| S)N)r   	co_constsinspectZiscoderD   _find_lines)r   r   r   cr   r   r	   r     s
    r   c             C   s   i  } t  j } t |  d |  } t j | j  } x | D]y \ } } } }	 }
 | t  j k r | t  j k r | \ } } |	 \ } } x% t | | d  D] } d | | <q W| } q= WWd  QRX| S)Nrq   r   )tokenINDENTrA   ra   generate_tokensrc   STRINGrange)r%   rq   r   Z
prev_ttyperK   tokZttypeZtstrstartendr   ZslineZscolZelineZecolir   r   r	   _find_strings  s    	r   c             C   s   y2 t  j |    } | j   } | j } Wd  QRXWnF t k
 rz } z& t d |  | f d t j i  SWYd  d  } ~ Xn Xt | |  d  } t	 |  |  } t
 | |  S)Nz%Not printing coverage data for %r: %sr;   exec)ra   rA   readrq   rF   rI   r   rJ   compiler   r   )r%   rK   progrq   rL   r   r   r   r   r	   r]     s    r]   c               @   s   e  Z d  Z d d d d f  f  d d d d d 	 Z d d   Z d d d	 d
  Z d d   Z d d   Z d d   Z d d   Z	 d d   Z
 d d   Z d d   Z d d   Z d d   Z d S)r   r   r   NFc
       
      C   s  | |  _  | |  _ t | |  |  _ i  |  _ i  |  _ d |  _ | |  _ i  |  _ i  |  _	 i  |  _
 d  |  _ |	 r~ t   |  _ | r |  j |  _ n | r |  j |  _ nr | r | r |  j |  _ |  j |  _ nK | r |  j |  _ |  j |  _ n* | r|  j |  _ |  j |  _ n	 d |  _ d  S)Nr   r   )r@   r   r   ignorer<   Zpathtobasename	donothingtrace_calledfuncs_callers_caller_cache
start_time_timeglobaltrace_trackcallersglobaltraceglobaltrace_countfuncsglobaltrace_ltlocaltrace_trace_and_count
localtracelocaltrace_tracelocaltrace_count)
r   rm   r   
countfuncscountcallers
ignoremods
ignoredirsr@   r   timingr   r   r	   r!     s6    										zTrace.__init__c             C   s,   d d  l  } | j } |  j | | |  d  S)Nr   )__main____dict__runctx)r   cmdr   dictr   r   r	   run  s    	z	Trace.runc          
   C   sf   | d  k r i  } | d  k r$ i  } |  j  s: t |  j  z t | | |  Wd  |  j  sa t   Xd  S)N)r   r   r   r   r
   )r   r   globalslocalsr   r   r	   r     s      		zTrace.runctxc             O   sP   d  } |  j  s t j |  j  z | | |   } Wd  |  j  sK t j d   X| S)N)r   r   r   r   )r   r   argskwresultr   r   r	   runfunc  s    		zTrace.runfuncc       
      C   sP  | j  } | j } | r' t |  } n d  } | j } d  } | |  j k rn |  j | d  k	 r'|  j | } n d  |  j | <d d   t j |  D } t |  d k r'd d   t j | d  D } t |  d k r'd d   t j | d  D }	 t |	  d k r'|	 d j } | |  j | <| d  k	 rCd | | f } | | | f S)Nc             S   s%   g  |  ] } t  j |  r |  q Sr   )r   Z
isfunction)r   rK   r   r   r	   r     s   	 z1Trace.file_module_function_of.<locals>.<listcomp>r   c             S   s%   g  |  ] } t  | t  r |  q Sr   )
isinstancer   )r   r   r   r   r	   r   #  s   	 r   c             S   s%   g  |  ] } t  | d   r |  q S)	__bases__)hasattr)r   r   r   r   r	   r   &  s   	 z%s.%s)	f_codeco_filenamer0   co_namer   gcZget_referrersr3   r)   )
r   framer   r%   r&   ri   ZclsnameZfuncsZdictsclassesr   r   r	   file_module_function_of  s,    			  zTrace.file_module_function_ofc             C   sD   | d k r@ |  j  |  } |  j  | j  } d |  j | | f <d  S)Ncallr   )r   f_backr   )r   r   whyarg	this_funcZparent_funcr   r   r	   r   5  s    zTrace.globaltrace_trackcallersc             C   s,   | d k r( |  j  |  } d |  j | <d  S)Nr   r   )r   r   )r   r   r   r   r   r   r   r	   r   @  s    zTrace.globaltrace_countfuncsc             C   s   | d k r | j  } | j j d d   } | r t |  } | d  k	 r |  j j | |  } | s |  j r t d | | j f  |  j	 Sn d  Sd  S)Nr   __file__z! --- modulename: %s, funcname: %s)
r   	f_globalsrQ   r0   r   r(   r   rI   r   r   )r   r   r   r   r   r%   r&   Z	ignore_itr   r   r	   r   I  s    		
zTrace.globaltrace_ltc             C   s   | d k r | j  j } | j } | | f } |  j j | d  d |  j | <|  j rt t d t   |  j d d t j	 j
 |  } t d | | t j | |  f d d |  j S)	Nr   r   r   z%.2fr    z
%s(%d): %sr1   )r   r   f_linenor<   rQ   r   rI   r   r   r   r,   r^   getliner   )r   r   r   r   r%   rk   rS   bnamer   r   r	   r   `  s    	 	z Trace.localtrace_trace_and_countc             C   s   | d k r | j  j } | j } |  j rH t d t   |  j d d t j j |  } t d | | t	 j
 | |  f d d |  j S)Nr   z%.2fr   r   z
%s(%d): %sr1   )r   r   r   r   rI   r   r   r   r,   r^   r   r   )r   r   r   r   r%   rk   r   r   r   r	   r   o  s    		zTrace.localtrace_tracec             C   sT   | d k rM | j  j } | j } | | f } |  j j | d  d |  j | <|  j S)Nr   r   r   )r   r   r   r<   rQ   r   )r   r   r   r   r%   rk   rS   r   r   r	   r   |  s    	 zTrace.localtrace_countc          
   C   s1   t  |  j d |  j d |  j d |  j d |  j S)Nr@   r   r>   r?   )r   r<   r@   r   r   r   )r   r   r   r	   results  s    		zTrace.results)r)   r*   r+   r!   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r     s   0)	c             C   s2   t  j j d t  j d |  f  t  j d  d  S)Nz%s: %s
r   r   )r   rJ   r   r   exit)msgr   r   r	   	_err_exit  s    !r   c          #   C   s,  d d  l  } |  d  k r! t j }  yV | j  |  d d   d d d d d d d	 d
 d d d d d d d d g  \ } } Wnq | j k
 r } zN t j j d t j d | f  t j j d t j d  t j d  WYd  d  } ~ Xn Xd } d } d } d } d  }	 d }
 g  } g  } d  } d } d } d } d } x| D]\ } } | d k rrt t j  t j d  | d k rt j j d  t j d  | d k s| d k rd } q@| d k s| d k rd } q@| d k s| d k rd } q@| d  k s| d! k rd } q@| d" k s7| d# k r@d } q@| d$ k sX| d% k rad } q@| d& k sy| d' k rd } q@| d( k s| d) k r| }	 q@| d* k s| d+ k rd }
 q@| d, k s| d- k r| } q@| d. k s| d/ k rd } q@| d0 k rBx* | j	 d1  D] } | j
 | j    q"Wq@| d2 k r@x | j	 t j  D] } t j j |  } | j d3 t j j t j d4 d5 t j d  d6    } | j d7 t j j t j d4 d5 t j d  d6    } t j j |  } | j
 |  qaWq@q@W| r/| s%| r/t d8  | pJ| pJ| pJ| pJ| sWt d9  | rm| rmt d:  | r|	 rt d;  | rt |  d k rt d<  | rt d= |	 d> |	  } | j |
 d
 | d? | nK| t _ | d } t j j	 |  d t j d <t | | d@ | dA | dB | dC | d= |	 d> |	 d | } yc t |   } t | j   | dD  } Wd  QRXdE | dF dG dH d  dI d  i } | j | | |  WnQ t k
 r} z  t dJ t j d | f  WYd  d  } ~ Xn t  k
 rYn X| j!   } | s(| j |
 d
 | d? | d  S)KNr   r   ztcrRf:d:msC:lTghelpversionr   rm   reportz	no-reportrg   zfile=missingzignore-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 --filezmissing name of file to runr@   r   rh   r   r   r   r   r   r   r)   r   __package__
__cached__zCannot run file %r because: %s)"getoptr   r   errorrJ   r   r   r   stdoutsplitappendstripr   pathsepr   
expandvarsr5   r`   base_prefixr   base_exec_prefixr   r   r3   r   rw   r   rA   r   r   r   rF   
SystemExitr   )r   r   ZoptsZ	prog_argvr   r   rm   r   Z	no_reportZcounts_filer   Zignore_modulesZignore_dirsrh   rg   r   r   r   optvalr'   sr   Zprognametrp   r   ZglobsrL   r   r   r	   main  s    		! 		




	
-r   c             C   s   t  d t d  t |   d  S)Nz(The trace.usage() function is deprecated   )_warnDeprecationWarningr   )r   r   r   r	   usage.  s    
r   c               @   s"   e  Z d  Z d d d d  Z d S)IgnoreNc             C   s'   t  d t d  t j |  | |  d  S)Nz$The class trace.Ignore is deprecatedr   )r   r   r   r!   )r   r   r    r   r   r	   r!   4  s    
zIgnore.__init__)r)   r*   r+   r!   r   r   r   r	   r   3  s   r   c             C   s   t  d t d  t |   S)Nz*The trace.modname() function is deprecatedr   )r   r   r0   )r   r   r   r	   modname9  s    
r   c             C   s   t  d t d  t |   S)Nz.The trace.fullmodname() function is deprecatedr   )r   r   r9   )r   r   r   r	   fullmodname>  s    
r   c             C   s   t  d t d  t |  |  S)Nz7The trace.find_lines_from_code() function is deprecatedr   )r   r   r   )r   r   r   r   r	   find_lines_from_codeC  s    
r   c             C   s   t  d t d  t |  |  S)Nz-The trace.find_lines() function is deprecatedr   )r   r   r   )r   r   r   r   r	   
find_linesH  s    
r   c             C   s    t  d t d  t |  d d  S)Nz/The trace.find_strings() function is deprecatedr   rq   )r   r   r   )r%   rq   r   r   r	   find_stringsM  s    
r   c             C   s   t  d t d  t |   S)Nz:The trace.find_executable_linenos() function is deprecatedr   )r   r   r]   )r%   r   r   r	   find_executable_linenosR  s    
r   r   ).__all__r^   r   rer   r   ra   r   r   r   rB   warningsr   r   timer   r   r   ImportErrorr   r   r
   r   r}   r   r{   r   r0   r9   r   r   r   r   r]   r   r   r   r   r   r   r   r   r   r   r   r)   r   r   r   r	   <module>2   sV   	-2
