
    /~h                        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y)zLCOV reporting for coverage.py.    )annotationsN)IOTYPE_CHECKING)Iterable)FileReporter)get_analysis_to_report)AnalysisNumbers)TMorf)Coveragec                    t        j                  | j                  d      d      j                         }t	        j
                  |      j                  d      j                  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)linehasheds     \/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/coverage/lcovreport.py	line_hashr      sM     [[W-uELLNFF#**73::3??    c           	     |   d}|D ]I  }|rdt        ||dz
           z   }t        || j                  v      }|j                  d| d| | d       K | j                  j
                  dkD  rS|j                  d| j                  j
                   d       |j                  d| j                  j                   d       y	y	)
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)analysislinessource_linesoutfilehash_suffixr   hits          r   
lcov_linesr/   $   s     K 9	,tAv*> ??K $h.../D63%}B789 $$q(H,,99:"=>H,,778;< )r   c           
        | j                         D cg c]p  }|j                  dk(  r_|j                  rSt        |j                  t        |j                              t        |j                  t        |j                              |fr }}|sy|j                          d}|D ]  \  }}}|j                  |j                        }t        |j                  j                  dkD        }	||	z  }|j                  d| d| d|j                   d       |j                  d|	 d|j                   d        |j                  dt        |       d       |j                  d	| d       yc c}w )
z4Emit function coverage records for an analyzed file.functionNr   zFN:r    r"   zFNDA:zFNF:zFNH:)code_regionskindr*   minstartmaxsortnarrowr#   r&   r(   r%   namelen)
frfile_analysisr,   region	functionsfunctions_hit
first_line	last_liner)   r.   s
             r   lcov_functionsrB   9   sQ   ( oo'	 ;;*$	 
V\\3v||,	-	V\\3v||,	-		I  NNM)2 5%
Iv !''5(""--12J<q1V[[MDEcU!FKK=345 MMDY(+,MMDr*+/s   A5E'c                   |j                         }|j                         }|j                         }|D ]  }||vr||   \  }}	|	dk(  r(t        ||         dk(  sJ ||   D 
cg c]  }
|
df }}
n/||   D 
cg c]  }
|
df }}
|j	                  d ||   D               |j                  d        |D ]2  \  }
}| j                  ||
      }|j                  d| d| d	| d
       4  t        d |j                         D              }|t        d |j                         D              z
  }|dkD  r+|j                  d| d
       |j                  d| d
       yyc c}
w c c}
w )z2Emit branch coverage records for an analyzed file.r   -1c              3  $   K   | ]  }|d f 
 yw)0N ).0dsts     r   	<genexpr>zlcov_arcs.<locals>.<genexpr>   s       "c
 s   c                    | d   dk  | fS )Nr   rH   )ds    r   <lambda>zlcov_arcs.<locals>.<lambda>   s    11 r   )keyzBRDA:z,0,r    r"   c              3  &   K   | ]	  \  }}|  y wNrH   rI   tks      r   rK   zlcov_arcs.<locals>.<genexpr>   s     2DAqa2s   c              3  ,   K   | ]  \  }}||z
    y wrQ   rH   rR   s      r   rK   zlcov_arcs.<locals>.<genexpr>   s     <daAE<s   zBRF:zBRH:N)
branch_statsexecuted_branch_arcsmissing_branch_arcsr:   extendr7   arc_descriptionr%   sumvalues)r;   r)   r*   r,   rV   executed_arcsmissing_arcsr   _takenrJ   destinationsr.   branchbrfbrhs                   r   	lcov_arcsre   c   s    ((*L113M//1L %=|#
  %5A: }T*+q000&24&8"c
L  '4D&9"c
L    &24&8   	56$ 	=HC''c2FMME$s6(!C5;<	=G%=P 2L//12
2C
<l&9&9&;<<
<C
QwSEn%SEn% ;s   "E7E$c                  @    e Zd ZdZdZddZddZ	 	 	 	 	 	 	 	 	 	 d	dZy)
LcovReporterz-A reporter for writing LCOV coverage reports.zLCOV reportc                    || _         |j                  | _        t        | j                   j                  j                        | _        y rQ   )coverageconfigr
   	precisiontotal)selfri   s     r   __init__zLcovReporter.__init__   s0     ooT]]11;;<
r   c                   | j                   j                          |xs t        j                  }t	        | j                   |      D cg c]  \  }}|j                         ||f }}}|j                          |D ]9  \  }}}| xj                  |j                  z  c_        | j                  ||||       ; | j                  j                  xr | j                  j                  S c c}}w )zRenders the full lcov report.

        `morfs` is a list of modules or filenames

        outfile is the file object to write the file into.
        )ri   get_datasysstdoutr   relative_filenamer7   rl   r&   	lcov_filer'   
pc_covered)rm   morfsr,   r;   r)   	to_reportfnames          r   reportzLcovReporter.report   s     	 'SZZ
 !7t}}e L
H !!#R2
	 
 	#, 	9E2xJJ(***JNN5"h8	9 zz&&@4::+@+@@
s   C$c                   |j                   j                  dk(  r| j                  j                  ry|j	                  d| d       t        |j                        }| j                  j                  r|j                         j                         }ng }t        ||||       t        |||       |j                  rt        ||||       |j	                  d       y)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
)r&   r'   rj   
skip_emptyr%   sorted
statementslcov_line_checksumssource
splitlinesr/   rB   has_arcsre   )rm   	rel_fnamer;   r)   r,   r*   r+   s          r   rt   zLcovReporter.lcov_file   s     ((A-{{%%I;b)*x**+;;**99;113LL8UL':r8W-b(E73'(r   N)ri   r   returnNone)rv   zIterable[TMorf] | Noner,   IO[str]r   float)
r   strr;   r   r)   r	   r,   r   r   r   )__name__
__module____qualname____doc__report_typern   ry   rt   rH   r   r   rg   rg      sJ    7K=
A0)) ) 	)
 ) 
)r   rg   )r   r   r   r   )
r)   r	   r*   	list[int]r+   z	list[str]r,   r   r   r   )r;   r   r<   r	   r,   r   r   r   )
r;   r   r)   r	   r*   r   r,   r   r   r   )r   
__future__r   r   r   rq   typingr   r   collections.abcr   coverage.pluginr   coverage.report_corer   coverage.resultsr	   r
   coverage.typesr   ri   r   r   r/   rB   re   rg   rH   r   r   <module>r      s    & "   
 $ $ ( 7 .  !	@=== = 	=
 
=*',',', ', 
	',T7&7&7& 7& 	7&
 
7&t@) @)r   