
    zi                        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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)FileReporter)get_analysis_to_report)AnalysisAnalysisNarrowerNumbers)TMorfs)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     ^/var/www/tmov.alphamb/tmov_inventario/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 	B	,tax*@ A AAK $h..//7D77377778888$q((=H,9===>>>;H,7;;;<<<<< )(r   frr   file_analysisc           
     d   d |                                  D             }|sdS t          |          }|                    d |D                        |                                 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>G   sq        ;*$$$ c&,//00c&,//00	
 %$$r   Nc              3  ,   K   | ]\  }}}|j         V  d S N)r!   )r?   _rs      r   	<genexpr>z!lcov_functions.<locals>.<genexpr>T   s*      ::WQ1::::::r   r   zFN:r*   r,   zFNDA:zFNF:zFNH:)code_regionsr	   add_regionssortnarrowr!   r-   r0   r2   r/   namelen)r6   r7   r%   	functionsnarrowerfunctions_hit
first_line	last_liner@   r    r4   s              r   lcov_functionsrR   7   sp      oo''  I  ..H::	::::::NNM)2 5 5%
Iv ??6<00("-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>~   s    EEE3S#JEEEr   c                    g | ]}|d fS )1rV   rW   s     r   rA   zlcov_arcs.<locals>.<listcomp>   s    FFF3S#JFFFr   c              3     K   | ]}|d fV  	dS )0NrV   rW   s     r   rF   zlcov_arcs.<locals>.<genexpr>   s&      IIsc
IIIIIIr   c                    | d         dk     | fS )Nr   rV   )ds    r   <lambda>zlcov_arcs.<locals>.<lambda>   s    11 r   )keyzBRDA:z,0,r*   r,   c              3      K   | ]	\  }}|V  
d S rC   rV   r?   tks      r   rF   zlcov_arcs.<locals>.<genexpr>   s&      22DAqa222222r   c              3  &   K   | ]\  }}||z
  V  d S rC   rV   rb   s      r   rF   zlcov_arcs.<locals>.<genexpr>   s*      <<daAE<<<<<<r   zBRF:zBRH:N)
branch_statsexecuted_branch_arcsmissing_branch_arcsrL   extendrI   arc_descriptionr/   sumvalues)r6   r    r!   r%   rf   executed_arcsmissing_arcsr   rD   takendestinationsrX   r4   branchbrfbrhs                   r   	lcov_arcsrt   f   s    ((**L1133M//11L = =|##
  %5A:: }T*++q0000EE,t2DEEELL
 GF-2EFFFLIIl46HIIIIII 	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 rC   )rw   configr
   	precisiontotal)selfrw   s     r   __init__zLcovReporter.__init__   s-     oT]1;<<


r   morfsr   r%   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 rV   )relative_filename)r?   r6   r    s      r   rA   z'LcovReporter.report.<locals>.<listcomp>   s?     
 
 
H !!##R2
 
 
r   )rw   get_datasysstdoutr   rI   r{   r0   	lcov_filer1   
pc_covered)r|   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   ry   
skip_emptyr/   sorted
statementslcov_line_checksumssource
splitlinesr5   rR   has_arcsrt   )r|   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)rw   r   r   r'   )r~   r   r%   r&   r   r   )
r   r   r6   r   r    r   r%   r&   r   r'   )__name__
__module____qualname____doc__report_typer}   r   r   rV   r   r   rv   rv      s_        77K= = = =
A A A A0) ) ) ) ) )r   rv   )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   coverage.pluginr   coverage.report_corer   coverage.resultsr   r	   r
   coverage.typesr   rw   r   r   r5   rR   rt   rv   rV   r   r   <module>r      sR   & % " " " " " "   



 $ $ $ $ $ $ $ $ ( ( ( ( ( ( 7 7 7 7 7 7 @ @ @ @ @ @ @ @ @ @ ! ! ! ! ! ! "!!!!!!	@ 	@ 	@ 	@= = = =*,, ,, ,, ,,^1& 1& 1& 1&h@) @) @) @) @) @) @) @) @) @)r   