
    V.jh                        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y)zLCOV reporting for coverage.py.    )annotationsN)IOTYPE_CHECKING)FileReporter)get_analysis_to_report)AnalysisAnalysisNarrowerNumbers)TMorfs)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     UC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\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	,tax*@ AAK $h.../D63%}B78  $$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t        |      }|j                  d |D               |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.functionNc              3  <   K   | ]  \  }}}|j                     y wN)r*   ).0_rs      r   	<genexpr>z!lcov_functions.<locals>.<genexpr>T   s     :	WQ1	s   r   zFN:r    r"   zFNDA:zFNF:zFNH:)code_regionskindr*   minstartmaxr	   add_regionssortnarrowr#   r&   r(   r%   namelen)frfile_analysisr,   region	functionsnarrowerfunctions_hit
first_line	last_liner)   r.   s              r   lcov_functionsrJ   7   sm   , oo' (F;;*$ c&,,/0c&,,/0	

 (   .H:	::NNM)2%
Iv ??6<<0(""--12J<q1V[[MDEcU!FKK=34 *3 MMDY(+,MMDr*+9s   A5F
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 )r4   dsts     r   r7   zlcov_arcs.<locals>.<genexpr>   s     I6Hsc
6Hs   c                    | d   dk  | fS )Nr   rP   )ds    r   <lambda>zlcov_arcs.<locals>.<lambda>   s    11r   )keyzBRDA:z,0,r    r"   c              3  &   K   | ]	  \  }}|  y wr3   rP   r4   tks      r   r7   zlcov_arcs.<locals>.<genexpr>   s     21DAqa1s   c              3  ,   K   | ]  \  }}||z
    y wr3   rP   rW   s      r   r7   zlcov_arcs.<locals>.<genexpr>   s     <&;daAE&;s   zBRF:zBRH:N)
branch_statsexecuted_branch_arcsmissing_branch_arcsrA   extendr>   arc_descriptionr%   sumvalues)rB   r)   r*   r,   r[   executed_arcsmissing_arcsr   r5   takenrQ   destinationsr.   branchbrfbrhs                   r   	lcov_arcsri   f   s    ((*L113M//1L|#
  %5A: }T*+q0002>t2DE2D3S#J2DLE
 3@2EF2E3S#J2ELFIl46HII 	56$HC''c2FMME$s6(!C5;< %; D 2L//12
2C
<l&9&9&;<<
<C
QwSEn%SEn% / F
 G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 r3   )coverageconfigr
   	precisiontotal)selfrm   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.
        )rm   get_datasysstdoutr   relative_filenamer>   rp   r&   	lcov_filer'   
pc_covered)rq   morfsr,   rB   r)   	to_reportfnames          r   reportzLcovReporter.report   s     	 'SZZ
 !7t}}e L
 LH !!#R2 L 	 
 	#,E2xJJ(***JNN5"h8 $- 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'   rn   
skip_emptyr%   sorted
statementslcov_line_checksumssource
splitlinesr/   rJ   has_arcsri   )rq   	rel_fnamerB   r)   r,   r*   r+   s          r   rx   zLcovReporter.lcov_file   s     ((A-{{%%I;b)*x**+;;**99;113LL8UL':r8W-b(E73'(r   N)rm   r   returnNone)rz   r   r,   IO[str]r   float)
r   strrB   r   r)   r   r,   r   r   r   )__name__
__module____qualname____doc__report_typerr   r}   rx   rP   r   r   rk   rk      sJ    7K=
A0)) ) 	)
 ) 
)r   rk   )r   r   r   r   )
r)   r   r*   	list[int]r+   z	list[str]r,   r   r   r   )rB   r   rC   r   r,   r   r   r   )
rB   r   r)   r   r*   r   r,   r   r   r   )r   
__future__r   r   r   ru   typingr   r   coverage.pluginr   coverage.report_corer   coverage.resultsr   r	   r
   coverage.typesr   rm   r   r   r/   rJ   ri   rk   rP   r   r   <module>r      s    & "   
 $ ( 7 @ @ !!	@=== = 	=
 
=*,,,,,, ,, 
	,,^1&1&1& 1& 	1&
 
1&h@) @)r   