a
    
3e)                     @  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rd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                   @  s   e Zd ZdZdddddZdddd	d
ZdddddZddddddddZddddddddZd&ddddddZ	dddd Z
d!d"dd#d$d%ZdS )'SummaryReporterz*A reporter for writing the summary report.r   None)coveragereturnc                 C  sr   || _ | j j| _|  | _d | _| jjp.d| _| jdvrLt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_dataZhas_arcsbranchesoutfileformatoutput_formatr
   fr_analysisskipped_countempty_countr   r   r   )selfr    r%   Q/var/www/test.vcks.de/backend/venv/lib/python3.9/site-packages/coverage/report.py__init__   s    

zSummaryReporter.__init__str)liner   c                 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.writezIterable[str])itemsr   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_itemsz	List[str]zList[List[Any]]z	List[Any])headerlines_values
total_line	end_linesr   c              	     sF  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 }	| |	 q|r| |  fddt|D }	| |	 |D ]}
| |
 q0d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       z0SummaryReporter._report_text.<locals>.<listcomp>      Cover   z Coverc                   s"   g | ]}t | d  d qS )r<   r=   )r5   indexr6   )r1   r%   r&   r8   C   r9   z{:{name_len}}z{:>7}z{:>{n}}z{:>10}NameStmtsMissBranchBrPartr<   Missingc                   s    g | ]} | j |d qS Zname_lennr   r7   itemformatsmax_nmax_namer%   r&   r8   M   s   r.   -z{:>{n}}%r<   z   {:9})rE   c                   s,   g | ]$\}} | j t|d  dqS r;   rG   r   r(   r7   rK   valuerL   r%   r&   r8   [   s   c                   s,   g | ]$\}} | j t|d  dqS rR   rS   rT   rL   r%   r&   r8   e   s   N)	maxr5   r>   dictr/   r+   updatezipr0   )r$   r1   r2   r3   r4   header_items
header_strZrulevalues
line_itemsend_liner%   )rM   r1   rN   rO   r&   _report_text1   sB    $	




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 }	| 	|	 qЈ tdd	d g }
t||D ]V\}}|dkrD|}n$|dkr\d| 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)r5   replacer6   r%   r%   r&   	<genexpr>~   r9   z3SummaryReporter._report_markdown.<locals>.<genexpr>r   )defaultz	**TOTAL**r;   z| {:{name_len}}|z{:>9} |z	{:>{n}} |z{:>10} |r?   r<      z Cover c                   s    g | ]} | j |d qS rF   rI   rJ   rL   r%   r&   r8      r9   z4SummaryReporter._report_markdown.<locals>.<listcomp>r.   | z- |rP   c                 S  s    g | ]}d  t|d dqS )z-: |r;   rP   )rjustr5   rJ   r%   r%   r&   r8      r9   Nz
{:>{n}}% |rQ   c                   s4   g | ],\}} | j t|d dd dqS )r`   ra   r;   rG   )r   r(   rb   rT   rL   r%   r&   r8      s   z|{:>{name_len}} |)r@   r<   z **z%**z**rG   )rV   r5   rW   r>   r/   rh   r+   rX   rY   r0   r   )r$   r1   r2   r3   r4   rZ   r[   Zrule_strr\   r]   Ztotal_line_itemsrK   rU   insertr^   r%   rL   r&   _report_markdownn   sJ    	 





z SummaryReporter._report_markdownNzOptional[Iterable[TMorf]]zOptional[IO[str]]float)morfsr   r   c                 C  s   |pt j| _| j | jj t| j|D ]\}}| 	|| q,| j
jsX| jsXtd| jdkrr| | j
j n|   | 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   Zset_query_contextsr   Zreport_contextsr   report_one_filer   Zn_filesr"   r   r    r+   pc_covered_strtabular_report
pc_covered)r$   rl   r   franalysisr%   r%   r&   report   s    
zSummaryReporter.report)r   c                   s~  g d}| j r|ddg7 }|dg7 }| jjr6|dg7 }tdddd	d
}| j r^|tddd g }| jD ]r\}}|j}| |j|j	g}| j r||j
|jg7 }||jg7 }| jjr||jddg7 }||jg7 }|| qh| jjpd }d}	|d dkrd}	|dd }n|d dkr*|dd }||  du rPtd| jj|dkrht||	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rR| jrR| jdkr4dnd}|d| j d | d! | jd"krf| j}n| j}||||
| dS )#zWrites tabular report formats.)r@   rA   rB   rC   rD   r<   rE   r   r;   r=   )nameZstmtsZmissZcover      )branchZbrpartT)r   rw   FrP   N+zInvalid sorting option: )reversec                   s   |   | d fS )Nr   r%   )r)   Zsort_idxr%   r&   <lambda>   r9   z0SummaryReporter.tabular_report.<locals>.<lambda>)keyr|   ZTOTALr.   sr*   z filez" skipped due to complete coverage.z empty filez	 skipped.r   )r   r   Zshow_missingrW   rX   r!   numbersZrelative_filenamen_statements	n_missingZ
n_branchesn_partial_branchesrp   Zmissing_formattedrr   appendsortlowergetr
   r   r   skip_coveredr"   
skip_emptyr#   r    rj   r_   )r$   r1   Zcolumn_orderr2   rs   rt   numsargsZsort_optionr|   r3   r4   Zfile_suffix	formatterr%   r}   r&   rq      sn    







zSummaryReporter.tabular_reportr   r   )rs   rt   r   c                 C  s~   |j }|  j|7  _|jdk}|jdk}| jjrH|rH|rH|  jd7  _n2| jjrj|jdkrj|  j	d7  _	n| 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$   rs   rt   r   Zno_missing_linesZno_missing_branchesr%   r%   r&   ro     s    

zSummaryReporter.report_one_file)N)__name__
__module____qualname____doc__r'   r+   r0   r_   rj   ru   rq   ro   r%   r%   r%   r&   r      s   =>Ir   )r   
__future__r   rm   typingr   r   r   r   r   r   r	   Zcoverage.exceptionsr
   r   Zcoverage.miscr   Zcoverage.pluginr   Zcoverage.report_corer   Zcoverage.resultsr   r   Zcoverage.typesr   r   r   r   r%   r%   r%   r&   <module>   s   $