
    L-Ph                        d Z ddlmZ ddlZddl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 dd	lmZ erdd
lmZ d dZd!dZd"dZd#dZ G d d          ZdS )$zLCOV reporting for coverage.py.    )annotationsN)IOTYPE_CHECKING)Iterable)FileReporter)get_analysis_to_report)AnalysisNumbers)TMorf)Coveragelinestrreturnc                    t          j        |                     d          d                                          }t	          j        |                              d                              d          S )z9Produce a hash of a source line for use in the LCOV file.zutf-8F)usedforsecurityascii=)hashlibmd5encodedigestbase64	b64encodedecoderstrip)r   hasheds     S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/coverage/lcovreport.py	line_hashr      s]     [W--uEEELLNNFF##**733::3???    analysisr	   lines	list[int]source_lines	list[str]outfileIO[str]Nonec           	     f   d}|D ]S}|rdt          ||dz
                     z   }t          || j        v          }|                    d| d| | d           T| j        j        dk    rH|                    d| j        j         d           |                    d| j        j         d           d	S d	S )
z0Emit line coverage records for an analyzed file. ,   zDA:
r   zLF:zLH:N)r   intmissingwritenumbersn_statements
n_executed)r    r!   r#   r%   hash_suffixr   hits          r   
lcov_linesr5   $   s     K 9 9 	@	,tAv*> ? ??K $h..//7D77377778888$q((=H,9===>>>;H,7;;;<<<<< )(r   frr   file_analysisc           
        d |                                  D             }|sdS |                                 d}|D ]\  }}}|                    |j                  }t	          |j        j        dk              }	||	z  }|                    d| d| d|j         d           |                    d|	 d|j         d           |                    dt          |           d           |                    d	| d           dS )
z4Emit function coverage records for an analyzed file.c           	         g | ]c}|j         d k    |j        t          |j        t          |j                            t	          |j        t	          |j                            |fdS )function)kindr!   minstartmax).0regions     r   
<listcomp>z"lcov_functions.<locals>.<listcomp>I   sq        ;*$$$	 
V\3v|,,	-	-	V\3v|,,	-	-		 %$$r   Nr   zFN:r*   r,   zFNDA:zFNF:zFNH:)
code_regionssortnarrowr!   r-   r0   r2   r/   namelen)
r6   r7   r%   	functionsfunctions_hit
first_line	last_liner@   r    r4   s
             r   lcov_functionsrK   9   sB      oo''	  I  NNM)2 5 5%
Iv !''55("-122DJDDDDV[DDDEEE3c33FK3334444MM+Y+++,,,MM****+++++r   c                L   |                                 }|                                }|                                }|D ]}||vr||         \  }}	|	dk    r.t          ||                   dk    sJ d ||         D             }
n7d ||         D             }
|
                    d ||         D                        |
                    d            |
D ]:\  }}|                     ||          }|                    d| d| d	| d
           ;t          d |	                                D                       }|t          d |	                                D                       z
  }|dk    r4|                    d| d
           |                    d| d
           dS dS )z2Emit branch coverage records for an analyzed file.r   c                    g | ]}|d fS )- r?   dsts     r   rA   zlcov_arcs.<locals>.<listcomp>{   )       "c
  r   c                    g | ]}|d fS )1rO   rP   s     r   rA   zlcov_arcs.<locals>.<listcomp>   rR   r   c              3     K   | ]}|d fV  	dS )0NrO   rP   s     r   	<genexpr>zlcov_arcs.<locals>.<genexpr>   s7          "c
           r   c                    | d         dk     | fS )Nr   rO   )ds    r   <lambda>zlcov_arcs.<locals>.<lambda>   s    11 r   )keyzBRDA:z,0,r*   r,   c              3      K   | ]	\  }}|V  
d S NrO   r?   tks      r   rW   zlcov_arcs.<locals>.<genexpr>   s&      22DAqa222222r   c              3  &   K   | ]\  }}||z
  V  d S r]   rO   r^   s      r   rW   zlcov_arcs.<locals>.<genexpr>   s*      <<daAE<<<<<<r   zBRF:zBRH:N)
branch_statsexecuted_branch_arcsmissing_branch_arcsrF   extendrC   arc_descriptionr/   sumvalues)r6   r    r!   r%   rb   executed_arcsmissing_arcsr   _takendestinationsrQ   r4   branchbrfbrhs                   r   	lcov_arcsrq   c   s,    ((**L1133M//11L %= %=|##
  %5A:: }T*++q0000 &24&8  LL &3D&9  L     &24&8         	55666$ 	= 	=HC''c22FMM;$;;6;;C;;;<<<<	=
 22L//11222
2
2C
<<l&9&9&;&;<<<<<
<C
QwwnSnnn%%%nSnnn%%%%% wr   c                  .    e Zd ZdZdZddZddZddZdS )LcovReporterz-A reporter for writing LCOV coverage reports.zLCOV reportcoverager   r   r'   c                r    || _         |j        | _        t          | j         j        j                  | _        d S r]   )rt   configr
   	precisiontotal)selfrt   s     r   __init__zLcovReporter.__init__   s-     oT]1;<<


r   morfsIterable[TMorf] | Noner%   r&   floatc                R   | j                                          |pt          j        }d t	          | j         |          D             }|                                 |D ]3\  }}}| xj        |j        z  c_        |                     ||||           4| j        j	        o| j        j
        S )zRenders the full lcov report.

        `morfs` is a list of modules or filenames

        outfile is the file object to write the file into.
        c                B    g | ]\  }}|                                 ||fS rO   )relative_filename)r?   r6   r    s      r   rA   z'LcovReporter.report.<locals>.<listcomp>   s?     
 
 
H !!##R2
 
 
r   )rt   get_datasysstdoutr   rC   rx   r0   	lcov_filer1   
pc_covered)ry   r{   r%   	to_reportfnamer6   r    s          r   reportzLcovReporter.report   s     	   'SZ
 
 6t}e L L
 
 
	 	#, 	9 	9E2xJJ(**JJNN5"h8888z&@4:+@@r   	rel_fnamer   r6   r   r    r	   c                   |j         j        dk    r| j        j        rdS |                    d| d           t          |j                  }| j        j        r'|                                	                                }ng }t          ||||           t          |||           |j        rt          ||||           |                    d           dS )zProduces the lcov data for a single file.

        This currently supports both line and branch coverage,
        however function coverage is not supported.
        r   NzSF:r,   zend_of_record
)r0   r1   rv   
skip_emptyr/   sorted
statementslcov_line_checksumssource
splitlinesr5   rK   has_arcsrq   )ry   r   r6   r    r%   r!   r#   s          r   r   zLcovReporter.lcov_file   s     (A--{% )I)))***x*++;* 	99;;1133LLL8UL':::r8W--- 	4b(E7333'(((((r   N)rt   r   r   r'   )r{   r|   r%   r&   r   r}   )
r   r   r6   r   r    r	   r%   r&   r   r'   )__name__
__module____qualname____doc__report_typerz   r   r   rO   r   r   rs   rs      s_        77K= = = =
A A A A0) ) ) ) ) )r   rs   )r   r   r   r   )
r    r	   r!   r"   r#   r$   r%   r&   r   r'   )r6   r   r7   r	   r%   r&   r   r'   )
r6   r   r    r	   r!   r"   r%   r&   r   r'   )r   
__future__r   r   r   r   typingr   r   collections.abcr   coverage.pluginr   coverage.report_corer   coverage.resultsr	   r
   coverage.typesr   rt   r   r   r5   rK   rq   rs   rO   r   r   <module>r      s^   & % " " " " " "   



 $ $ $ $ $ $ $ $ $ $ $ $ $ $ ( ( ( ( ( ( 7 7 7 7 7 7 . . . . . . . .             "!!!!!!	@ 	@ 	@ 	@= = = =*', ', ', ',T7& 7& 7& 7&t@) @) @) @) @) @) @) @) @) @)r   