o
    g9                     @  s   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	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
rBdd	lmZ dddZG dd dZdS )zLCOV reporting for coverage.py.    )annotationsN)IOIterableOptionalTYPE_CHECKING)FileReporter)get_analysis_to_report)AnalysisNumbers)TMorf)Coveragelinestrreturnc                 C  s*   t | d }t|d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)r   hashed r   S/var/www/html/bloggers_ems/venv/lib/python3.10/site-packages/coverage/lcovreport.py	line_hash   s   r   c                   @  s2   e Zd ZdZdZdddZdddZdddZdS )LcovReporterz-A reporter for writing LCOV coverage reports.zLCOV reportcoverager   r   Nonec                 C  s   || _ t| j jj| _d S N)r   r
   config	precisiontotal)selfr   r   r   r   __init__"   s   zLcovReporter.__init__morfsOptional[Iterable[TMorf]]outfileIO[str]floatc                 C  sH   | j   |p	tj}t| j |D ]\}}| ||| q| 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.
        )	r   get_datasysstdoutr   get_lcovr$   n_statements
pc_covered)r%   r'   r)   franalysisr   r   r   report&   s
   

zLcovReporter.reportr2   r   r3   r	   c                 C  s<  |  j |j7  _ |d |d|  d |  }t|jD ]+}||jv r+q#|r>|d t	|kr7 n||d  }nd}|d| dt
| d q#t|jD ]}|sZJ ||d  }|d| dt
| d qT|d	|jj d |d
|jj d | }| }	tt|  D ]L\}
}tt|| D ]\}}t|d}|d| d|
 d| d qtt|	| t	|| dD ]\}}t|d}|d| d|
 d| d qq| r| }tdd | D }|tdd | D  }|d| d |d| d |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.
        zTN:
zSF:
    zDA:z,1,z,0,zLF:zLH:r   zBRDA:,z,-
)startz,1
c                 s  s    | ]\}}|V  qd S r!   r   .0tkr   r   r   	<genexpr>}   s    z(LcovReporter.get_lcov.<locals>.<genexpr>c                 s  s    | ]	\}}|| V  qd S r!   r   r:   r   r   r   r>   ~   s    zBRF:zBRH:zend_of_record
N)r$   numberswriterelative_filenamesource
splitlinessortedexecutedexcludedlenr   missingr0   
n_executedmissing_branch_arcsexecuted_branch_arcs	enumeratebranch_statskeysmaxhas_arcssumvalues)r%   r2   r3   r)   source_linescoveredr   missedmissing_arcsexecuted_arcsblock_numberblock_line_numberbranch_numberline_numberrM   brfbrhr   r   r   r/   6   sV   




 


 
zLcovReporter.get_lcovN)r   r   r   r    )r'   r(   r)   r*   r   r+   )r2   r   r3   r	   r)   r*   r   r    )__name__
__module____qualname____doc__report_typer&   r4   r/   r   r   r   r   r      s    

r   )r   r   r   r   )ra   
__future__r   r   r   r-   typingr   r   r   r   coverage.pluginr   coverage.report_corer   coverage.resultsr	   r
   coverage.typesr   r   r   r   r   r   r   r   r   <module>   s   
