
    He.                        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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 G d d      Zy)zLCOV reporting for coverage.py.    )annotationsN)IOIterableTYPE_CHECKING)FileReporter)get_analysis_to_report)AnalysisNumbers)TMorf)Coveragec                    t        j                  | j                  d            j                         }t	        j
                  |      j                  d      j                  d      S )z9Produce a hash of a source line for use in the LCOV file.zutf-8ascii=)hashlibmd5encodedigestbase64	b64encodedecoderstrip)linehasheds     5/usr/lib/python3/dist-packages/coverage/lcovreport.py	line_hashr      sI    [[W-.557FF#**73::3??    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                n    || _         t        | j                   j                  j                        | _        y N)coverager
   config	precisiontotal)selfr!   s     r   __init__zLcovReporter.__init__"   s%     T]]11;;<
r   c                   | j                   j                          |xs t        j                  }t	        | j                   |      D ]  \  }}| j                  |||        | j                  j                  xr | 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.
        )	r!   get_datasysstdoutr   get_lcovr$   n_statements
pc_covered)r%   morfsoutfilefranalysiss        r   reportzLcovReporter.report&   sq     	 'SZZ24==%H 	1LBMM"h0	1 zz&&@4::+@+@@r   c                   | xj                   |j                  z  c_         |j                  d       |j                  d|j                          d       |j	                         j                         }t        |j                        D ]R  }||j                  v r|r|dz
  t        |      k\  r n.||dz
     }nd}|j                  d| dt        |       d       T t        |j                        D ]/  }|sJ ||dz
     }|j                  d| dt        |       d       1 |j                  d	|j                  j                   d       |j                  d
|j                  j                   d       |j                         }|j                         }	t!        t        |j#                         j%                                     D ]  \  }
}t!        t        ||               D ],  \  }}t'        |d      }|j                  d| d|
 d| d       . t!        t        |	|         t        ||               D ],  \  }}t'        |d      }|j                  d| d|
 d| d       .  |j)                         r}|j#                         }t+        d |j-                         D              }|t+        d |j-                         D              z
  }|j                  d| d       |j                  d| d       |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.
        zTN:
zSF:
    zDA:z,1,z,0,zLF:zLH:r   zBRDA:,z,-
)startz,1
c              3  &   K   | ]	  \  }}|  y wr     .0tks      r   	<genexpr>z(LcovReporter.get_lcov.<locals>.<genexpr>}   s     :DAqa:s   c              3  ,   K   | ]  \  }}||z
    y wr    r:   r;   s      r   r?   z(LcovReporter.get_lcov.<locals>.<genexpr>~   s     DdaAEDs   zBRF:zBRH:zend_of_record
N)r$   numberswriterelative_filenamesource
splitlinessortedexecutedexcludedlenr   missingr,   
n_executedmissing_branch_arcsexecuted_branch_arcs	enumeratebranch_statskeysmaxhas_arcssumvalues)r%   r0   r1   r/   source_linescoveredr   missedmissing_arcsexecuted_arcsblock_numberblock_line_numberbranch_numberline_numberrO   brfbrhs                    r   r+   zLcovReporter.get_lcov6   s    	

h&&&
gB0023267yy{--/h//0 	AG(+++ 19L 11#GAI.MMCyIdO+<B?@'	A* X--. 	@F  <q)DMMCxs9T?*;2>?	@ 	H,,99:"=>H,,778;<  335 557/88((*//120
 	X+L+ /8|$567/ X*{ "+q1k]!L>=/QUVWX /8}%678,'89:/ X*{ "+q1k]!L>=/QUVWX!	X0 #002L:L$7$7$9::CDl.A.A.CDDDCMMDR.)MMDR.)'(r   N)r!   r   returnNone)r.   zIterable[TMorf] | Noner/   IO[str]r`   float)r0   r   r1   r	   r/   rb   r`   ra   )__name__
__module____qualname____doc__report_typer&   r2   r+   r:   r   r   r   r      s    7K=A L)r   r   )r   strr`   ri   )rg   
__future__r   r   r   r)   typingr   r   r   coverage.pluginr   coverage.report_corer   coverage.resultsr	   r
   coverage.typesr   r!   r   r   r   r:   r   r   <module>rp      s@    & "   
 . . ( 7 .  !@e) e)r   