o
    v&iӏ                     @  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ZddlZddlmZmZmZ ddlZddlmZ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m Z m!Z! ddl"m#Z#m$Z$m%Z% ddl&m'Z' ddl(m)Z)m*Z* ddl+m,Z, dXddZ-G dd dZ.G dd dej/Z0G dd de0Z1G dd de0Z2e.j3e.j4e.j5gZ6e2de.j7e.j8e.j9e.j:e.j;ge6 de-dde2d e.j<e.j=e.j>e.j?ge6 d!e-d"de2d#e6d$e-d%de2d&e.j=ge6 d'd(e2d)e6d*d+de2d,e.j@e.j7e.j8e.jAe.j9e.j:e.j;e.jBe.j?e.jCe.jDe.jEe.jFe.jGge6 de-d-de2d.e.j@e.j8e.jAe.j9e.j:e.j;e.jHe.jIe.j?e.jCg
e6 dd/de2d0e.j8e.jAe.j9e.j:e.jJe.j;e.j?ge6 dd1de2d2e.j@e.j8e.jAe.jKe.j9e.j:e.j;e.jBe.jLe.jMe.jDe.jEe.jFge6 dd3de2d4e.j<e.jNe.jOe.jPe.jQe.j:e.jRe.j;e.jSe.jTe.jUe.jVe.jWge6 d5d6de2d7e.j8e.jAe.j9e.j:e.j;e.jXe.j?e.jFge6 dd8dd9ZY			dYdZd@dAZZdB\Z[Z\Z]G dCdD dDZ^d[dGdHZ_d\dKdLZ`dMe-dNdOdPZad]d^dSdTZbecdUZdedrddVlemfZf ebZg	d]d^dWdTZbdS dS )_z%Command-line support for coverage.py.    )annotationsN)AnyNoReturncast)Coverageenv)CoverageConfig)DEFAULT_DATAFILE)CTRACER_FILE)CoverageDatacombinable_filesdebug_data_file)info_headershort_stackwrite_formatted_info)NoSourceCoverageException_ExceptionDuringRun)PyRunner)display_coveredshould_fail_under)__url__textstrreturnc                 C  s   d |  S )zCTurn a multi-line string into one line for help to reformat nicely. )joinsplit)r    r   V/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/coverage/cmdline.pyoneline$   s   r    c                   @  s6  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ed	d
eejdZejddddddZejddddeddZejddddeddZejddddeddZejdddde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+dZ	ejd,d-dd.dZejd/d0dd1dZejdd2dd3ed4dZejdd5dd6dZejd7d8ded9dZejd:d;dd<dZejd:d=ded>dZejdd?dd3ed@dZejdAdddBddCdDZejdAdddBddEdDZ ejdAdddBddFdDZ!ejddGddHdZ"ejdIdJdedKdZ#ejddLddMe$edNd(Z%ejdOdPddQdZ&ejddRdedSdZ'ejddTddUdVdWgedXdYZ(ejdZdd[dZ)ejd\dd]dZ*ejd^d_d`dadbZ+ejdcddddZ,ejdeddfedgdZ-ejddhddidjdZ.ejddkddldZ/ejddmddndodZ0ejddpddqdZ1drS )sOptszBA namespace class for individual options we'll build parsers from.z-az--append
store_truezBAppend data to the data file. Otherwise it starts clean each time.)actionhelp z--branchz:Measure branch coverage in addition to statement coverage.z--concurrencystoreLIBSz
            Properly measure code using a concurrency library.
            Valid values are: {}, or a comma-list of them.
            z, )r#   metavarr$   z	--contextLABELz2The context label to record for this coverage run.z
--contextszREGEX1,REGEX2,...z
            Only display data from lines covered in the given contexts.
            Accepts Python regexes, which must be quoted.
            z--data-fileDATAFILEz~
            Base name of the data files to operate on.
            Defaults to '.coverage'. [env: COVERAGE_FILE]
            INFILEz
            Read coverage data for report generation from this file.
            Defaults to '.coverage'. [env: COVERAGE_FILE]
            OUTFILEz
            Write the recorded coverage data to this file.
            Defaults to '.coverage'. [env: COVERAGE_FILE]
            z--debugOPTSz9Debug options, separated by commas. [env: COVERAGE_DEBUG]z-dz--directoryDIRzWrite the output files to DIR.z--fail-underMINfloatz?Exit with a status of 2 if the total coverage is less than MIN.)r#   r(   typer$   z--formatFORMATz9Output format, either text (default), markdown, or total.z-hz--helpzGet help on this command.z-iz--ignore-errorsz)Ignore errors while reading source files.z	--includezPAT1,PAT2,...z
            Include only files whose paths match one of these patterns.
            Accepts shell-style wildcards, which must be quoted.
            z--keepz9Keep original coverage files, otherwise they are deleted.z-Lz--pylibz}
            Measure coverage even inside the Python installed library,
            which isn't done by default.
            -mz--show-missingzEShow line numbers of statements in each module that weren't executed.--modulez
            <pyfile> is an importable Python module, not a script path,
            to be run as 'python -m' would run it.
            z--omitz
            Omit files whose paths match one of these patterns.
            Accepts shell-style wildcards, which must be quoted.
            z-ooutfilez=Write the XML report to this file. Defaults to 'coverage.xml')r#   destr(   r$   z?Write the JSON report to this file. Defaults to 'coverage.json'z?Write the LCOV report to this file. Defaults to 'coverage.lcov'z--pretty-printz"Format the JSON for human readers.z-pz--parallel-modez
            Append a unique suffix to the data file name to collect separate
            data from multiple processes.
            z--precisionNz|
            Number of digits after the decimal point to display for
            reported coverage percentages.
            z-qz--quietz-Don't print messages about what is happening.z--rcfilez
            Specify configuration file.
            By default '.coveragerc', 'setup.cfg', 'tox.ini', and
            'pyproject.toml' are tried. [env: COVERAGE_RCFILE]
            z--save-signalSIGNALUSR1USR2z
            Specify a signal that will trigger coverage to write its collected data.
            Supported values are: USR1, USR2. Not available on Windows.
            )r#   r(   choicesr$   z--show-contextsz Show contexts for covered lines.z--skip-coveredzSkip files with 100% coverage.z--no-skip-coveredstore_falseskip_coveredzDisable --skip-covered.)r#   r6   r$   z--skip-emptyzSkip files with no code.z--sortCOLUMNz
            Sort the report by the named column: name, stmts, miss, branch, brpart, or cover.
            Default is name.
            z--sourcezSRC1,SRC2,...z=A list of directories or importable names of code to measure.z--timidz*Use the slower Python trace function core.z--titleTITLEz.A text string to use as the title on the HTML.z	--versionz%Display version information and exit.N)2__name__
__module____qualname____doc__optparsemake_optionappendbranchr    formatr   sortedr   CONCURRENCY_CHOICESconcurrencycontextcontextsdatafiledatafle_inputdatafile_outputdebug	directory
fail_underr$   ignore_errorsincludekeeppylibshow_missingmoduleomit
output_xmloutput_jsonoutput_lcovjson_pretty_printparallel_modeint	precisionquietrcfilesave_signalshow_contextsr=   no_skip_covered
skip_emptysortsourcetimidtitleversionr   r   r   r   r!   )   s2   
r!   c                      sJ   e Zd ZdZd fddZG d	d
 d
eZd fddZdddZ  Z	S )CoverageOptionParserz|Base OptionParser for coverage.py.

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

    argsr   kwargsr   Nonec                   s   d|d< t  j|i | | jd$i 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 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 d"d d#d  |   d S )%NFadd_help_optionr#   rF   rG   rK   rL   rM   	data_filerQ   rR   rS   rH   r$   rT   rU   rV   rY   rZ   r_   ra   rW   rb   rc   Trd   re   rX   r=   rg   rh   ri   rj   rk   rl   r   )super__init__set_defaultsdisable_interspersed_args)selfrn   ro   	__class__r   r   rt   z  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@   rA   rB   rC   r   r   r   r   OptionParserError  s    rz   	list[str].tuple[bool, optparse.Values | None, list[str]]c                   s>   z
t  |\}}W n | jy   ddg f Y S w d||fS )zUCall optparse.parse_args, but return a triple:

        (ok, options, args)

        FNT)rs   
parse_argsrz   )rw   rn   optionsrx   r   r   parse_args_ok  s   
z"CoverageOptionParser.parse_args_okmsgr   r   c                 C  s   t | | j)z7Override optparse.error so sys.exit doesn't get called.)	show_helprz   )rw   r   r   r   r   error  s   zCoverageOptionParser.error)rn   r   ro   r   r   rp   )rn   r{   r   r|   )r   r   r   r   )
r@   rA   rB   rC   rt   	Exceptionrz   r   r   __classcell__r   r   rx   r   rm   r  s    )rm   c                      s"   e Zd ZdZd fddZ  ZS )GlobalOptionParserz<Command-line parser for coverage.py global option arguments.r   rp   c                   s    t    | tjtjg d S N)rs   rt   add_optionsr!   r$   rl   rw   rx   r   r   rt     s   
zGlobalOptionParser.__init__r   rp   )r@   rA   rB   rC   rt   r   r   r   rx   r   r     s    r   c                      sB   e Zd ZdZ	dd fd
dZdddZdZd fddZ  ZS )CmdOptionParserz4Parse one of the new-style commands for coverage.py.Nr#   r   r~   list[optparse.Option]descriptionusage
str | Nonec                   s<   |rd| }t  j||d | j|d | | || _dS )a4  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.
        `description` is the description of the command, for the help text.
        `usage` is the usage string to display in help.

        z%prog r   r   )r#   N)rs   rt   ru   r   cmd)rw   r#   r~   r   r   rx   r   r   rt     s   

zCmdOptionParser.__init__otherr   boolc                 C  s   |d| j  dkS )Nz<CmdOptionParser:>)r   )rw   r   r   r   r   __eq__  s   zCmdOptionParser.__eq__c                   s   t   }| d| j S )z>Override of an undocumented function in optparse.OptionParser.r   )rs   get_prog_namer   )rw   program_namerx   r   r   r     s   
zCmdOptionParser.get_prog_namer   )r#   r   r~   r   r   r   r   r   )r   r   r   r   )r   r   )	r@   rA   rB   rC   rt   r   __hash__r   r   r   r   rx   r   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   combinez%[options] <path1> <path2> ... <pathN>a|  
            Combine data from multiple coverage files.
            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.
            rQ   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;
                'pybehave' to show internal flags describing Python behavior;
                'sqlite' to show SQLite compilation options.
            erasez)Erase previously collected coverage data.)r   r$   z	[command]zDescribe how to use coverage.pyhtmlz
            Create 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.lcovz,Generate an LCOV 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.)r   r   rQ   r   r$   r   r   r   r   r   r   r   r   topicparseroptparse.OptionParser | Nonerp   c                 C  sB  | s|s|sJ t jd }|tjjd rtj|}tj|}tj	r5d}||r5|dt
|  }ttj}t|d< ||d< trId|d< nd	|d< | rbt| t jd
 td| dt jd
 n3|rpt|   t  n%|dusvJ tt|d }|rt|jdi | ntd| tdjdi | dS )z-Display an error message, or the named topic.r   z__main__.pyz
-script.pyNr   r   zwith C extensionextension_modifierzwithout C extension)filezUse 'z help' for help.r%   zDon't know topic z"Full documentation is at {__url__}r   )sysargvendswithospathsepdirnamebasenamer   WINDOWSlendictcoverage__dict__r   r
   printstderrformat_helpstriptextwrapdedentHELP_TOPICSgetrH   )r   r   r   program_pathr   auto_suffixhelp_paramshelp_msgr   r   r   r     s6   



r   )r         c                   @  sL   e Zd ZdZdddZdd	d
ZdddZd ddZd!ddZd"ddZ	dS )#CoverageScriptz*The command-line interface to coverage.py.r   rp   c                 C  s   d| _ |  d S )NF)global_optionr   r   r   r   rt     s   zCoverageScript.__init__r   r{   r`   c                 C  s  |s	t dd tS |d d| _| jrt }nt|d }|s,t d|d  tS |dd }||\}}}|s>tS |dusDJ | 	|||rMtS t
|j}t
|j}t
|j}t
|j}	t
|j}
|jdurr|jd}nd}t|jpyt|j|j|j|j|j||||	|d	|j|j d
| _|jdkr| |S |jdkr| j  tS |jdkr|  ||S |jdkr|j!r| j"  |pd}| 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-d#|j.|j/|j0|j1|j2|j3d|}nq|jdkr!| jj4d#d|j5i| n^|jdkr>| jj6d#|j5|j.|j0|j1|j7|j8d|}nA|jdkrS| jj9d#|j:|j1d|}n,|jdkrj| jj;d#|j:|j<|j7d|}n|jdkr}| jj=d#d|j:i|}nt>|dur|j?dur| j@d|j? |j.dur| j@d|j. tAtB| jCd}tAtD| jCd}tE|||rd j3tF||||d!}tGd"| tHS 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: r   N,T)rr   data_suffixcover_pylibrj   rG   config_fileri   rZ   rU   rQ   rK   check_preimportedrL   messagesrQ   r   r   r   )strictrV   )morfsrT   rZ   rU   rM   r%   r   )ra   rX   r=   rg   rh   output_formatr   rR   r   )rR   ra   r=   rg   re   rk   r   )r5   rg   r   )r5   pretty_printre   r   r5   zreport:fail_underzreport:precisionz;total of {total} is less than fail-under={fail_under:.{p}f})totalrS   pzCoverage failure:r   )Ir   OK
startswithr   r   COMMANDSr   ERRr   do_helpunshell_listri   rZ   rU   rQ   rM   rK   r   r   rr   r	   r_   rW   rj   rG   rc   rL   rb   r   r#   do_debugr   do_runrF   loadr   r   rV   saver   unglob_argsrT   r   r   insertr   ra   rX   r=   rg   rh   rH   r   rR   html_reportre   rk   
xml_reportr5   json_reportr   lcov_reportAssertionErrorrS   
set_optionr   r0   
get_optionr`   r   r   r   
FAIL_UNDER)rw   r   r   okr~   rn   ri   rZ   rU   rQ   rM   rK   
data_pathsreport_argsr   rS   ra   r   r   r   r   command_line  s   	
















		


zCoverageScript.command_liner~   optparse.Valuesrn   r   optparse.OptionParserr   c                 C  s   |j r| jrtdd dS t|d dS |jdkr=|r6|D ]}t|}|dur.t|d qt|d qdS tdd dS |jrGtdd dS dS )z`Deal with help requests.

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

        r$   r   )r   TNrl   F)r$   r   r   r#   r   r   rl   )rw   r~   rn   r   aparser_mayber   r   r   r     s(   





zCoverageScript.do_help_signum_frametypes.FrameType | Nonec                 C  s   t ddd | j  dS )z&Signal handler to save coverage reportzSaving coverage data...T)flushN)r   r   r   )rw   r   r   r   r   r   do_signal_save  s   zCoverageScript.do_signal_savec                 C  s  |s.|j rtd tS tt| jd}|dur.t|}|r.|d dv r.d|_ |dd }|s6td tS |j	rE| jd	rEtd
 tS |j
dkrddD ]}t||durctdd| d  t  S qLdtjd< t|t|j d}|  |j	r~| j  |jrtjrtd tS ttd|j }t|| j | j  d}z z|  W n
 ty   d} w W | j  |r| j  tS | j  |r| j  w w )z!Implementation of 'coverage run'.zNo module specified for -mzrun:command_lineNr   >   r3   r4   Tr   zNothing to do.zrun:parallelz,Can't append to data files in parallel mode.multiprocessing)rG   rU   rZ   rW   ri   rj   zROptions affecting multiprocessing must only be specified in a configuration file.
z	Remove --z from the command line.trueCOVERAGE_RUN)	as_modulez*--save-signal is not supported on Windows.SIGF)rY   r   r   r   r   r   r   shlexr   rF   rK   getattrr   environr   r   preparer   rd   r   r   signalr   startr   r   stopr   r   )rw   r~   rn   r   opt_namerunnersigcode_ranr   r   r   r     sl   








zCoverageScript.do_runc                 C  s:  |st d tS |dd rt d tS |d dkr%ttd| j  tS |d dkrKttd | jjj}t	| t
|D ]
}td t	| q>tS |d d	kr]ttd	| jj  tS |d d
krrttd
 ttdd tS |d dkrttdt  tS |d dkrttdt  tS t d|d  tS )z#Implementation of 'coverage debug'.zNWhat information would you like: config, data, sys, premain, pybehave, sqlite?r   Nz Only one topic at a time, pleaser   r   dataz-----configpremainT)fullpybehavesqlitezDon't know what you mean by )r   r   r   r   r   sys_infor   r  rr   r   r   
debug_infor   r   r   r   )rw   rn   rr   filenamer   r   r   r     sD   

	zCoverageScript.do_debugNr   )r   r{   r   r`   )r~   r   rn   r{   r   r   r   r   )r   r`   r   r   r   rp   )r~   r   rn   r{   r   r`   )rn   r{   r   r`   )
r@   rA   rB   rC   rt   r   r   r   r   r   r   r   r   r   r     s    

 
%
&
Br   slist[str] | Nonec                 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   r   )r  r   r   r   r   1  s
   

r   rn   r{   c                 C  sH   t jr"g }| D ]}d|v sd|v r|t| q|| q|} | S )z5Interpret shell wildcards for platforms that need it.?*)r   r   extendglobrF   )rn   globbedargr   r   r   r   ?  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.
            lcov        Create an LCOV 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.
    z
        Code coverage for Python, version {__version__} {extension_modifier}.
        Use '{program_name} help' for help.
        z7Coverage.py, version {__version__} {extension_modifier})r$   r   rl   r   
int | Nonec              
   C  s  | du rt jdd } z	t | }W |S  ty/ } ztj|j  t}W Y d}~|S d}~w t	y] } z#|jd }|j
rL|d dt d|j
 }t| t}W Y d}~|S d}~w ty } z|jrm|jd }n	d}W Y d}~|S W Y d}~|S d}~ww )z\The main entry point to coverage.py.

    This is installed as the script entry point.

    Nr   r   .z; see z/messages.html#error-)r   r   r   r   r   	tracebackprint_exceptionrn   r   r   slugrstripr   r   
SystemExit)r   statuserrr   r   r   r   mainl  s6   

r  COVERAGE_PROFILE)SimpleLauncherc                 C  sv   t  }zt| W |jddd\}}t|j|dddd |  S |jddd\}}t|j|dddd |  w )z$A wrapper around main that profiles.r   d   )	re_filtermax_recordsr%   )querylimitr   col)r   launchoriginal_mainr$  r   showcancel)r   profilerr  _r   r   r   r    s   

)r   r   r   r   )NNN)r   r   r   r   r   r   r   rp   )r  r   r   r  )rn   r{   r   r{   r   )r   r  r   r  )hrC   
__future__r   r  rD   r   os.pathr   r   r   r   r  typestypingr   r   r   r   r   r   coverage.configr   coverage.controlr	   coverage.corer
   coverage.datar   r   r   coverage.debugr   r   r   coverage.exceptionsr   r   r   coverage.execfiler   coverage.resultsr   r   coverage.versionr   r    r!   OptionParserrm   r   r   rQ   r$   rc   GLOBAL_ARGSrR   rO   rT   rU   rZ   rF   rN   rV   rb   rM   rS   ra   re   r=   rf   rg   rk   r\   r^   r]   rH   rh   rX   rG   rK   rL   rP   rY   rW   r_   rd   ri   rj   r[   r   r   r   r   r   r   r   r   r   r  getenv_profileox_profile.core.launchersr   r(  r   r   r   r   <module>   s  
  KH2	

  D
/  
@
 
$