B
    `x                 @   s  d Z ddlm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 ddlmZ ddlmZ ddlmZmZmZ dd	lmZ dd
lmZmZmZmZ ddlmZ G dd deZ G dd dej!eZ"G dd de"Z#G dd de"Z$e j%e j&e j'gZ(e$de j)e j*e j+e j,ge( ddde$de j-e j.ge( ddde$de(ddde$de(dd e$d!e(d"d#de$d$e j/e j)e j0e j*e j+e j,e j1e j2e j3e j4e j5e j6ge( dd%de$d&e j/e j0e j*e j+e j,e j7e j8e j2ge( dd'de$d(e j/e j0e j*e j+e j,e j1e j9e j:e j3e j4e j5ge( dd)de$d*e j-e j;e j<e j=e j+e j>e j,e j?e j@e jAe jBge( d+d,de$d-e j0e j*e j+e j,e jCe j5ge( dd.dd/
ZDdCd0d1ZEd2\ZFZGZHG d3d4 d4eZId5d6 ZJd7d8 ZKd9d:d;d<ZLdDd=d>ZMejNOd?d@ZPePrddAlQmRZR eMZSdEdBd>ZMdS )Fz%Command-line support for coverage.py.    )print_functionN)Coverage)env)CTracer)line_counts)info_formatterinfo_headershort_stack)PyRunner)BaseCoverageExceptionExceptionDuringRunNoSourceoutput_encoding)should_fail_underc            
   @   st  e Zd ZdZejdddddZejdddd	dZejdd
dddZdddddgZ	ejdddde	dd
e	 dZejddddddZejddddddZejdddd d!dZejdd"dd#d$d%d&Zejd'd(dd)dZejd*d+dd,dZejdd-dd.d/dZejd0d1dd2dZejd3dd4d5dZejd6d7dd8dZejd9dd:dZejd;d<d=d>d?Zejd@ddAdZejdBddCdZejddDdd.dEdZejddFddGdHdZejdIdddJdKdLdMZejdIdddJdKdNdMZejddOddPdZejdQdRddSdZejd6dTddUdZ ejddVddWe!dXd&Z"ejddYddZdZ#ejdd[dd\d]dZ$ejdd^dd_dZ%ejdd`ddadbdZ&ejddcddddZ'deS )fOptszBA namespace class for individual options we'll build parsers from.z-az--append
store_truezGAppend coverage data to .coverage, otherwise it starts clean each time.)actionhelp z--keepz9Keep original coverage files, otherwise they are deleted.z--branchz:Measure branch coverage in addition to statement coverage.threadZgeventZgreenletZeventletmultiprocessingz--concurrencystoreZLIBzHProperly measure code using a concurrency library. Valid values are: %s.z, )r   metavarchoicesr   z	--contextZLABELz2The context label to record for this coverage run.)r   r   r   z--debugZOPTSz9Debug options, separated by commas. [env: COVERAGE_DEBUG]z-dz--directoryZDIRzWrite the output files to DIR.z--fail-underZMINfloatz?Exit with a status of 2 if the total coverage is less than MIN.)r   r   typer   z-hz--helpzGet help on this command.z-iz--ignore-errorsz)Ignore errors while reading source files.z	--includezPAT1,PAT2,...zpInclude only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.z-Lz--pylibzWMeasure coverage even inside the Python installed library, which isn't done by default.z--sortZCOLUMNzbSort the report by the named column: name, stmts, miss, branch, brpart, or cover. Default is name.z-mz--show-missingzEShow line numbers of statements in each module that weren't executed.z--skip-coveredzSkip files with 100% coverage.z--no-skip-coveredstore_falseskip_coveredzDisable --skip-covered.)r   destr   z--skip-emptyzSkip files with no code.z--show-contextsz Show contexts for covered lines.z--omitzhOmit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.z
--contextszREGEX1,REGEX2,...ziOnly display data from lines covered in the given contexts. Accepts Python regexes, which must be quoted.z-ooutfileZOUTFILEz=Write the XML report to this file. Defaults to 'coverage.xml')r   r   r   r   z?Write the JSON report to this file. Defaults to 'coverage.json'z--pretty-printz"Format the JSON for human readers.z-pz--parallel-modezAppend the machine name, process id and random number to the .coverage data file name to simplify collecting data from many processes.z--modulezb<pyfile> is an importable Python module, not a script path, to be run as 'python -m' would run it.z--precisionNzVNumber of digits after the decimal point to display for reported coverage percentages.z--rcfilezSpecify configuration file. By default '.coveragerc', 'setup.cfg', 'tox.ini', and 'pyproject.toml' are tried. [env: COVERAGE_RCFILE]z--sourcezSRC1,SRC2,...z9A list of packages or directories of code to be measured.z--timidzXUse a simpler but slower trace method. Try this if you get seemingly impossible results!z--titleZTITLEz.A text string to use as the title on the HTML.z	--versionz%Display version information and exit.N)(__name__
__module____qualname____doc__optparsemake_optionappendkeepbranchZCONCURRENCY_CHOICESjoinconcurrencycontextdebug	directory
fail_underr   ignore_errorsincludepylibsortshow_missingr   no_skip_covered
skip_emptyshow_contextsomitcontexts
output_xmloutput_jsonjson_pretty_printparallel_modemoduleint	precisionrcfilesourcetimidtitleversion rF   rF   X/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/coverage/cmdline.pyr      s   

r   c                   sF   e Zd ZdZ fddZG dd deZd fdd	Zd	d
 Z  Z	S )CoverageOptionParserz|Base OptionParser for coverage.py.

    Problems don't exit the program.
    Defaults are initialized for all options.

    c                sh   t t| j|ddi| | jd d d d d d d d d d d d d d d d d d dd d d d d d d d d d |   d S )Nadd_help_optionFT)r   r'   r)   r+   r,   r-   r.   r/   r   r0   r1   r(   r>   r8   r9   r=   r@   r2   rA   r4   r   r6   r7   r3   rB   rC   rD   rE   )superrH   __init__set_defaultsdisable_interspersed_args)selfargskwargs)	__class__rF   rG   rK      s@    
zCoverageOptionParser.__init__c               @   s   e Zd ZdZdS )z&CoverageOptionParser.OptionParserErrorz;Used to stop the optparse error handler ending the process.N)r!   r"   r#   r$   rF   rF   rF   rG   OptionParserError   s   rR   Nc                s<   yt t| ||\}}W n | jk
r0   dS X d||fS )zUCall optparse.parse_args, but return a triple:

        (ok, options, args)

        )FNNT)rJ   rH   
parse_argsrR   )rN   rO   options)rQ   rF   rG   parse_args_ok   s
    z"CoverageOptionParser.parse_args_okc             C   s   t | | jdS )z7Override optparse.error so sys.exit doesn't get called.N)	show_helprR   )rN   msgrF   rF   rG   error  s    zCoverageOptionParser.error)NN)
r!   r"   r#   r$   rK   	ExceptionrR   rU   rX   __classcell__rF   rF   )rQ   rG   rH      s
   %rH   c                   s    e Zd ZdZ fddZ  ZS )GlobalOptionParserz<Command-line parser for coverage.py global option arguments.c                s$   t t|   | tjtjg d S )N)rJ   r[   rK   add_optionsr   r   rE   )rN   )rQ   rF   rG   rK     s    zGlobalOptionParser.__init__)r!   r"   r#   r$   rK   rZ   rF   rF   )rQ   rG   r[   	  s   r[   c                   s:   e Zd ZdZd	 fdd	Zdd ZdZ fddZ  ZS )
CmdOptionParserz4Parse one of the new-style commands for coverage.py.Nc                sL   |rd| }t t| j||d | jf d|i|p2i  | | || _dS )ao  Create an OptionParser for a coverage.py command.

        `action` is the slug to put into `options.action`.
        `options` is a list of Option's for the command.
        `defaults` is a dict of default value for options.
        `usage` is the usage string to display in help.
        `description` is the description of the command, for the help text.

        z%prog )usagedescriptionr   N)rJ   r]   rK   rL   r\   cmd)rN   r   rT   defaultsr^   r_   )rQ   rF   rG   rK     s    


zCmdOptionParser.__init__c             C   s   |d| j  kS )Nz<CmdOptionParser:%s>)r`   )rN   otherrF   rF   rG   __eq__,  s    zCmdOptionParser.__eq__c                s   t t|  }dj|| jdS )z>Override of an undocumented function in optparse.OptionParser.z{command} {subcommand})command
subcommand)rJ   r]   get_prog_nameformatr`   )rN   program_name)rQ   rF   rG   rf   3  s    zCmdOptionParser.get_prog_name)NNN)	r!   r"   r#   r$   rK   rc   __hash__rf   rZ   rF   rF   )rQ   rG   r]     s
   r]   annotatez[options] [modules]z|Make annotated copies of the given files, marking statements that are executed with > and statements that are missed with !.)r^   r_   combinez%[options] <path1> <path2> ... <pathN>a?  Combine data from multiple coverage files collected with 'run -p'.  The combined results are written to a single file representing the union of the data. The positional arguments are data files or directories containing data files. If no paths are provided, data files in the default data file's directory are combined.r-   z<topic>a  Display information about the internals of coverage.py, for diagnosing problems. Topics are: 'data' to show a summary of the collected data; 'sys' to show installation information; 'config' to show the configuration; 'premain' to show what is calling coverage.erasez)Erase previously collected coverage data.)r_   r   z	[command]zDescribe how to use coverage.pyhtmlzCreate an HTML report of the coverage of the files.  Each file gets its own page, with the source decorated to show executed, excluded, and missed lines.jsonz+Generate a JSON report of coverage results.reportz&Report coverage statistics on modules.runz$[options] <pyfile> [program options]z/Run a Python program, measuring code execution.xmlz+Generate an XML report of coverage results.)
rj   rk   r-   rl   r   rm   rn   ro   rp   rq   c             C   s(  | s|s|st tjd }|tjjd r8tj|}tj|}t	j
rjd}||rj|dt|  }ttj}||d< tdk	rd|d< nd|d< | rt| tjd	 td
|f tjd	 nV|rt|   t  n:tt|d }|rt|jf | ntd|  tdjf | dS )z-Display an error message, or the named topic.r   z__main__.pyz
-script.pyNrh   zwith C extensionZextension_modifierzwithout C extension)filezUse '%s help' for help.r   zDon't know topic %rz"Full documentation is at {__url__})AssertionErrorsysargvendswithospathsepdirnamebasenamer   WINDOWSlendictcoverage__dict__r   printstderrformat_helpstriptextwrapdedentHELP_TOPICSgetrg   )rX   topicparserZprogram_pathrh   Zauto_suffixZhelp_paramsZhelp_msgrF   rF   rG   rV     s2    



rV   )r         c               @   s8   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d ZdS )CoverageScriptz*The command-line interface to coverage.py.c             C   s   d| _ d | _d S )NF)global_optionr   )rN   rF   rF   rG   rK     s    zCoverageScript.__init__c             C   s  |st dd tS |d d| _| jr0t }n2t|d }|sVt d|d   tS |dd }||\}}}|sztS | 	|||rtS t
|j}t
|j}t
|j}t
|j}	t
|j}
t|j|j|j|j|j||||	|jd|jd	| _|jd
kr| |S |jdkr| j  tS |jdkr6| ||S |jdkr|jrT| j  |p\d}| jj|dt |j!d | j"  tS t#t$||j%|||
d}t&j'(dd | j  d}|jdkr| jj)f |j*|j+|j,|j-|j.d|}n|jdkr| jj/f d|j0i| n|jdkrN| jj1f |j0|j2|j+|j,|j3|j-d|}n^|jdkr||j4}| jj5f ||j,d|}n0|jdkr|j4}| jj6f ||j7|j3d|}|dk	r|j8dk	r| j9d|j8 | j:d}| j:d}t;|||rdj<|||d}t=d| t>S tS ) zThe bulk of the command line interface to coverage.py.

        `argv` is the argument list to process.

        Returns 0 if all is well, 1 if something went wrong.

        minimum_help)r   r   -zUnknown command: '%s'r   NT)Zdata_suffixZcover_pylibrC   r)   config_filerB   r8   r1   r-   r+   Zcheck_preimportedr,   r-   rl   rp   rk   )strictr(   )Zmorfsr0   r8   r1   r9   r   ro   )r4   r   r6   r@   r3   rj   r.   rm   )r.   rD   r   r6   r7   r@   rq   )r   r6   rn   )r   pretty_printr7   zreport:fail_underzreport:precisionzAtotal of {total:.{p}f} is less than fail-under={fail_under:.{p}f})totalr/   pzCoverage failure:)?rV   OK
startswithr   r[   CMDSr   ERRrU   do_helpunshell_listrB   r8   r1   r-   r9   r   r=   r2   rC   r)   rA   r+   r,   r   r   do_debugrl   do_runr'   loadrk   boolr(   saver~   unglob_argsr0   rt   rx   insertro   r4   r   r6   r@   r3   rj   r.   Zhtml_reportrD   r7   r   Z
xml_reportZjson_reportr   r/   Z
set_option
get_optionr   rg   r   
FAIL_UNDER)rN   ru   r   okrT   rO   rB   r8   r1   r-   r9   Z	data_dirsZreport_argsr   r   r/   r@   rW   rF   rF   rG   command_line  s    	

















zCoverageScript.command_linec             C   s   |j r&| jrtdd n
t|d dS |jdkrv|rhx<|D ](}t|}|rXt|d q:t|d q:W n
tdd dS |jrtdd dS dS )z`Deal with help requests.

        Return True if it handled the request, False if not.

        r   )r   )r   TrE   F)r   r   rV   r   r   r   rE   )rN   rT   rO   r   arF   rF   rG   r     s$    





zCoverageScript.do_helpc             C   sD  |sV|j rtd tS | jd}|dk	rVt|}|rV|d dkrVd|_ |dd }|sftd tS |jr| jd	rtd
 tS |jdkrx,dD ]$}t	||dk	rtd
| tS qW t|t|j d}|  |jr| j  | j  d}z.y|  W n tk
r   d} Y nX W d| j  |r>| j  X tS )z!Implementation of 'coverage run'.zNo module specified for -mzrun:command_lineNr   z-mTr   zNothing to do.zrun:parallelz,Can't append to data files in parallel mode.r   )r)   r1   r8   r2   rB   rC   ztOptions affecting multiprocessing must only be specified in a configuration file.
Remove --{} from the command line.)Z	as_moduleF)r>   rV   r   r   r   shlexsplitr'   r+   getattrrg   r
   r   preparer   startrp   r   stopr   r   )rN   rT   rO   r   opt_namerunnerZcode_ranrF   rF   rG   r     sL    





zCoverageScript.do_runc             C   s  |st d tS x|D ]}|dkr\| j }ttd xt|D ]}td|  qFW q|dkr"| j  | j }ttd td|	   |rtd|
   t|dd}t| }td	t|  xJ|D ]8}d
||| f }||}	|	r
|d|	 7 }t| qW ntd q|dkrhttd | jjj }
xRt|
D ]}td|  qPW q|dkrttd tt  qt d|  tS qW tS )z#Implementation of 'coverage debug'.z<What information would you like: config, data, sys, premain?rt   z %sdatazpath: %szhas_arcs: %rT)fullpathz

%d files:z%s: %d linesz [%s]zNo data collectedconfigZpremainzDon't know what you mean by %r)rV   r   r   sys_infor   r   r   r   get_dataZdata_filenameZhas_arcsr   sortedkeysr}   Zfile_tracerr   r   itemsr	   r   )rN   rO   infor   liner   summary	filenamesfZpluginZconfig_inforF   rF   rG   r     sJ    








zCoverageScript.do_debugN)	r!   r"   r#   r$   rK   r   r   r   r   rF   rF   rF   rG   r     s    !9r   c             C   s"   | sdS t jr| d} | dS )z)Turn a command-line argument into a list.N',)r   r|   r   r   )srF   rF   rG   r   #  s
    
r   c             C   sL   t jrHg }x8| D ]0}d|ks$d|kr6|t| q|| qW |} | S )z5Interpret shell wildcards for platforms that need it.?*)r   r|   extendglobr'   )rO   ZglobbedargrF   rF   rG   r   1  s    
r   a          Coverage.py, version {__version__} {extension_modifier}
        Measure, collect, and report on code coverage in Python programs.

        usage: {program_name} <command> [options] [args]

        Commands:
            annotate    Annotate source files with execution information.
            combine     Combine a number of data files.
            debug       Display information about the internals of coverage.py
            erase       Erase previously collected coverage data.
            help        Get help on using coverage.py.
            html        Create an HTML report.
            json        Create a JSON report of coverage results.
            report      Report coverage stats on modules.
            run         Run a Python program and measure code execution.
            xml         Create an XML report of coverage results.

        Use "{program_name} help <command>" for detailed help on any command.
    zw        Code coverage for Python, version {__version__} {extension_modifier}.  Use '{program_name} help' for help.
    zD        Coverage.py, version {__version__} {extension_modifier}
    )r   r   rE   c          
   C   s   | dkrt jdd } yt | }W n tk
rX } ztj|j  t}W dd}~X Y n t	k
r } z,|jd }t
jr|t }t| t}W dd}~X Y n8 tk
r } z|jr|jd }nd}W dd}~X Y nX |S )z\The main entry point to coverage.py.

    This is installed as the script entry point.

    Nr   r   )rt   ru   r   r   r   	tracebackprint_exceptionrO   r   r   r   PY2encoder   r   
SystemExit)ru   statuserrrW   rF   rF   rG   main^  s$    
r   ZCOVERAGE_PROFILEr   )SimpleLauncherc             C   sH   t  }zt| S |jddd\}}t|j|dddd |  X dS )z$A wrapper around main that profiles.Nr   d   )Z	re_filterZmax_recordsr   )querylimitry   col)r   Zlaunchoriginal_mainr   r   showcancel)ru   Zprofilerr   _rF   rF   rG   r     s    )NNN)N)N)Tr$   
__future__r   r   r%   os.pathrw   r   rt   r   r   r   r   r   Zcoverage.collectorr   Zcoverage.datar   Zcoverage.debugr   r   r	   Zcoverage.execfiler
   Zcoverage.miscr   r   r   r   Zcoverage.resultsr   objectr   OptionParserrH   r[   r]   r-   r   rA   ZGLOBAL_ARGSr.   r0   r1   r8   r'   r(   r9   r/   r@   r7   r   r5   r6   rD   r;   r<   r3   r4   r)   r+   r,   r>   r2   r=   rB   rC   r:   r   rV   r   r   r   r   r   r   r   r   environr   Z_profileZox_profile.core.launchersr   r   rF   rF   rF   rG   <module>   s   ,C'	

)
   !
#