o
    ge)                     @  s   d Z ddlmZ ddlZddlmZmZmZmZm	Z	m
Z
m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rNddlmZ G dd dZdS )zSummary reporting    )annotationsN)AnyIOIterableListOptionalTupleTYPE_CHECKING)ConfigErrorNoDataError)human_sorted_items)FileReporter)get_analysis_to_report)AnalysisNumbers)TMorf)Coveragec                   @  sb   e Zd ZdZd+ddZd,d
dZd-ddZd.ddZd.ddZd/d0d!d"Z	d1d#d$Z
d2d)d*ZdS )3SummaryReporterz*A reporter for writing the summary report.coverager   returnNonec                 C  sr   || _ | j j| _|  | _d | _| jjpd| _| jdvr&td| jg | _	d| _
d| _t| jjd| _d S )Ntext>   r   totalmarkdownzUnknown report format choice: r   )	precision)r   configget_datahas_arcsbranchesoutfileformatoutput_formatr
   fr_analysisskipped_countempty_countr   r   r   )selfr    r&   O/var/www/html/bloggers_ems/venv/lib/python3.10/site-packages/coverage/report.py__init__   s   

zSummaryReporter.__init__linestrc                 C  s.   | j dusJ | j |  | j d dS )z-Write a line to the output, adding a newline.N
)r   writerstrip)r%   r)   r&   r&   r'   r,   '   s   zSummaryReporter.writeitemsIterable[str]c                 C  s   |  d| dS )z)Write a list of strings, joined together. N)r,   join)r%   r.   r&   r&   r'   write_items-   s   zSummaryReporter.write_itemsheader	List[str]lines_valuesList[List[Any]]
total_line	List[Any]	end_linesc              	     sB  t dd |D dg d t t|d d tdd t gfdd|D  td	d
d
d
d
ddd  fddD }d|}dt| }| | | |  jtdddd |D ]} fddt|D }	| |	 qe|r| |  fddt|D }	| |	 |D ]}
| |
 qdS )a:  Internal method that prints report data in text format.

        `header` is a list with captions.
        `lines_values` is list of lists of sortable values.
        `total_line` is a list with values of the total line.
        `end_lines` is a list of ending lines with information about skipped files.

        c                 S  s   g | ]}t |d  qS )r   )len.0r)   r&   r&   r'   
<listcomp>A   s    z0SummaryReporter._report_text.<locals>.<listcomp>      Cover   z Coverc                   s"   g | ]}t | d  d qS )r@   rA   )r:   indexr;   )r3   r&   r'   r=   C   s   " z{:{name_len}}z{:>7}z{:>{n}}z{:>10}NameStmtsMissBranchBrPartr@   Missingc                       g | ]} | j |d qS name_lennr    r<   itemformatsmax_nmax_namer&   r'   r=   M   s    r0   -z{:>{n}}%r@   z   {:9})rI   c                   ,   g | ]\}} | j t|d  dqS r?   rL   r    r*   r<   rQ   valuerR   r&   r'   r=   [       c                   rX   rY   rZ   r[   rR   r&   r'   r=   e   r]   N)	maxr:   rB   dictr1   r,   updatezipr2   )r%   r3   r5   r7   r9   header_items
header_strrulevalues
line_itemsend_liner&   )rS   r3   rT   rU   r'   _report_text1   sD   $	




zSummaryReporter._report_textc              	     s  t dd |D ddt tdd tdddddd	d
d t t||d d td fdd|D }d|}dddt|d d dgdd |dd D   }| | | | |D ]} tdd  fddt||D }	| 	|	 qh tdd	d g }
t||D ](\}}|dkr|}n|dkrd| d}nd| d}|
 | j
|d 7 }
q| 	|
 |D ]}| | qdS )!aT  Internal method that prints report data in markdown format.

        `header` is a list with captions.
        `lines_values` is a sorted list of lists containing coverage information.
        `total_line` is a list with values of the total line.
        `end_lines` is a list of ending lines with information about skipped files.

        c                 s  s$    | ]}t |d  ddV  qdS )r   _\_N)r:   replacer;   r&   r&   r'   	<genexpr>~   s   " z3SummaryReporter._report_markdown.<locals>.<genexpr>r   )defaultz	**TOTAL**r?   z| {:{name_len}}|z{:>9} |z	{:>{n}} |z{:>10} |rC   r@      z Cover c                   rJ   rK   rO   rP   rR   r&   r'   r=           z4SummaryReporter._report_markdown.<locals>.<listcomp>r0   | z- |rV   c                 S  s    g | ]}d  t|d dqS )z-: |r?   rV   )rjustr:   rP   r&   r&   r'   r=      ro   Nz
{:>{n}}% |rW   c                   s4   g | ]\}} | j t|d dd dqS )ri   rj   r?   rL   )r    r*   rk   r[   rR   r&   r'   r=      s    "z|{:>{name_len}} |)rD   r@   z **z%**z**rL   )r^   r:   r_   rB   r1   rr   r,   r`   ra   r2   r    )r%   r3   r5   r7   r9   rb   rc   rule_strre   rf   total_line_itemsrQ   r\   insertrg   r&   rR   r'   _report_markdownn   sL    	



z SummaryReporter._report_markdownNmorfsOptional[Iterable[TMorf]]r   Optional[IO[str]]floatc                 C  s   |pt j| _| j | jj t| j|D ]
\}}| 	|| q| j
js,| js,td| jdkr<| | j
j | j
jS |   | j
jS )zWrites a report summarizing coverage statistics per module.

        `outfile` is a text-mode file object to write the summary to.

        zNo data to report.r   )sysstdoutr   r   r   set_query_contextsr   report_contextsr   report_one_filer   n_filesr#   r   r!   r,   pc_covered_strtabular_report
pc_covered)r%   rw   r   franalysisr&   r&   r'   report   s   
zSummaryReporter.reportc                   sp  g d}| j r|ddg7 }|dg7 }| jjr|dg7 }tdddd	d
}| j r/|tddd g }| jD ]9\}}|j}| |j|j	g}| j rO||j
|jg7 }||jg7 }| jjrb||jddg7 }||jg7 }|| q4| jjpsd }d}	|d dkrd}	|dd }n|d dkr|dd }||  du rtd| jj|dkrt||	d}n|j fdd|	d d| jj| jj	g}
| j r|
| jj
| jjg7 }
|
| jjg7 }
| jjr|
dg7 }
g }| jjr| jr| jdkrdnd}|d| j d| d | jjr"| jr"| jdkrdnd}|d| j d | d! | jd"kr,| j}n| j}||||
| dS )#zWrites tabular report formats.)rD   rE   rF   rG   rH   r@   rI   r   r?   rA   )namestmtsmisscover      )branchbrpartT)r   r   FrV   N+zInvalid sorting option: )reversec                   s   |   | d fS )Nr   r&   )r)   sort_idxr&   r'   <lambda>   s    z0SummaryReporter.tabular_report.<locals>.<lambda>)keyr   TOTALr0   sr+   z filez" skipped due to complete coverage.z empty filez	 skipped.r   )r   r   show_missingr_   r`   r"   numbersrelative_filenamen_statements	n_missing
n_branchesn_partial_branchesr   missing_formattedr   appendsortlowergetr
   r   r   skip_coveredr#   
skip_emptyr$   r!   rv   rh   )r%   r3   column_orderr5   r   r   numsargssort_optionr   r7   r9   file_suffix	formatterr&   r   r'   r      sn   




zSummaryReporter.tabular_reportr   r   r   r   c                 C  s   |j }|  j|7  _|jdk}|jdk}| jjr%|r%|r%|  jd7  _dS | jjr7|jdkr7|  j	d7  _	dS | j
||f dS )z4Report on just one file, the callback from report().r   r?   N)r   r   r   r   r   r   r#   r   r   r$   r"   r   )r%   r   r   r   no_missing_linesno_missing_branchesr&   r&   r'   r     s   

zSummaryReporter.report_one_file)r   r   r   r   )r)   r*   r   r   )r.   r/   r   r   )
r3   r4   r5   r6   r7   r8   r9   r4   r   r   )N)rw   rx   r   ry   r   rz   )r   r   )r   r   r   r   r   r   )__name__
__module____qualname____doc__r(   r,   r2   rh   rv   r   r   r   r&   r&   r&   r'   r      s    




=>
Ir   )r   
__future__r   r{   typingr   r   r   r   r   r   r	   coverage.exceptionsr
   r   coverage.miscr   coverage.pluginr   coverage.report_corer   coverage.resultsr   r   coverage.typesr   r   r   r   r&   r&   r&   r'   <module>   s   $