o
    v&iB*                     @  s   d Z ddlmZ ddlZddlmZ ddlmZmZm	Z	 ddl
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mZ ddlmZ erNddlmZ G dd dZdS )zSummary reporting    )annotationsN)Iterable)IOTYPE_CHECKINGAny)ConfigErrorNoDataError)human_sorted_itemsplural)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_analysesskipped_countempty_countr   r   r   )selfr    r$   U/var/www/html/karishye-ai-python/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           
   	     s8  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| }| | | |  tddd |D ]}|  fddt|D  qd|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    z/SummaryReporter.report_text.<locals>.<listcomp>      Cover   z Coverc                   s"   g | ]}t | d  d qS )r>   r?   )r8   indexr9   )r1   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        r.   -z{:>{n}}%z   {:9})r>   rG   c                 3  0    | ]\}} | j t|d  dV  qdS r=   rJ   Nr   r(   r:   rO   valuerP   r$   r%   	<genexpr>^   
    
z.SummaryReporter.report_text.<locals>.<genexpr>c                 3  rV   rW   rX   rY   rP   r$   r%   r[   i   r\   N)	maxr8   r@   dictr/   r*   updater0   zip)
r#   r1   r3   r5   r7   header_items
header_strrulevaluesend_liner$   )rQ   r1   rR   rS   r%   report_text1   sN   $	



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)r8   replacer9   r$   r$   r%   r[      s   " z2SummaryReporter.report_markdown.<locals>.<genexpr>r   )defaultz	**TOTAL**r=   z| {:{name_len}}|z{:>9} |z	{:>{n}} |z{:>10} |rA   r>      z Cover c                   rH   rI   rM   rN   rP   r$   r%   r;      rT   z3SummaryReporter.report_markdown.<locals>.<listcomp>r.   | z- |rU   c                 S  s    g | ]}d  t|d dqS )z-: |r=   rU   )rjustr8   rN   r$   r$   r%   r;      rT   Nz
{:>{n}}% |)r>   c                 3  s8    | ]\}} | j t|d dd dV  qdS )rg   rh   r=   rJ   N)r   r(   ri   rY   rP   r$   r%   r[      s    
z|{:>{name_len}} |)rB   r>   z **z%**z**rJ   )r]   r8   r^   r@   r/   rn   r*   r_   r0   r`   r   )r#   r1   r3   r5   r7   ra   rb   rule_strrd   total_line_itemsrO   rZ   insertre   r$   rP   r%   report_markdownr   sd    	




zSummaryReporter.report_markdownNmorfsIterable[TMorf] | Noner   IO[str] | None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#   rs   r   franalysisr$   r$   r%   report   s   
zSummaryReporter.reportc                   s^  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rt| jd}|d| j d| d | jjr| jrt| jd}|d| j d | d! | jd"kr#| j}n| j}||||
| dS )#zWrites tabular report formats.)rB   rC   rD   rE   rF   r>   rG   r   r=   r?   )namestmtsmisscover      )branchbrpartT)r   r   FrU   N+zInvalid sorting option: )reversec                   s   |   | d fS )Nr   r$   )r'   sort_idxr$   r%   <lambda>   s    z0SummaryReporter.tabular_report.<locals>.<lambda>)keyr   TOTALr.   filer)   rm   z" skipped due to complete coverage.z empty z	 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!   r
   
skip_emptyr"   r   rr   rf   )r#   r1   column_orderr3   r   r   numsargssort_optionr   r5   r7   files	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   )
r1   r2   r3   r4   r5   r6   r7   r2   r   r   )N)rs   rt   r   ru   r   rv   )r   r   )r   r   r   r   r   r   )__name__
__module____qualname____doc__r&   r*   r0   rf   rr   r   r~   r{   r$   r$   r$   r%   r      s    




AL
Hr   )r   
__future__r   rw   collections.abcr   typingr   r   r   coverage.exceptionsr   r   coverage.miscr	   r
   coverage.pluginr   coverage.report_corer   coverage.resultsr   r   coverage.typesr   r   r   r   r$   r$   r$   r%   <module>   s   