
    i*                       d Z ddlmZ ddl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	rddlmZ e                    d ej        D                       ZddZ  G 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)TMorfs)Coveragec                "    i | ]}|d v|d| S )z.,/-\ ).0chars     N/root/projects/qq-shell/venv/lib64/python3.11/site-packages/coverage/report.py
<dictcomp>r      s*    LLL4V9K9KT;;;9K9K9K    textstrreturnc                6    |                      t                    S )zEPrefix all characters meaningful in markdown tables with backslashes.)	translateMARKDOWN_ESCAPES)r   s    r   escape_markdownr       s    >>*+++r   c                  T    e Zd ZdZd#dZd$d	Zd%dZd&dZd&dZd'd(dZ	d)dZ
d*d"ZdS )+SummaryReporterz*A reporter for writing the summary report.coverager   r   Nonec                h   || _         | j         j        | _        |                                                                | _        d | _        | j        j        pd| _        | j        dvrt          d| j                  g | _	        d| _
        d| _        t          | j        j                  | _        d S )Nr   >   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#   s     r   __init__zSummaryReporter.__init__$   s     m* ))++4466'+![/96%BBBUt?QUUVVV@Bt{'<===


r   liner   c                    | j         J | j                             |                                           | j                             d           dS )z-Write a line to the output, adding a newline.N
)r-   writerstrip)r3   r5   s     r   r8   zSummaryReporter.write1   sJ    |'''4;;==)))4     r   itemsIterable[str]c                V    |                      d                    |                     dS )z)Write a list of strings, joined together. N)r8   join)r3   r:   s     r   write_itemszSummaryReporter.write_items7   s$    

2775>>"""""r   header	list[str]lines_valueslist[list[Any]]
total_line	list[Any]	end_linesc           	       
 t          d |D             dgz             dz   t          t          |                    d                             dz   t          d                    dz   t          gfd|D             z             t          dd	d	d	d	d
d          

fdD             }d                    |          }dt          |          z  }|                     |           |                     |           
                    t          dd                     |D ]3}|                     
fdt          |          D                        4|r|                     |           |                     
fdt          |          D                        |D ]}	|                     |	           d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                8    g | ]}t          |d                    S )r   )lenr   r5   s     r   
<listcomp>z/SummaryReporter.report_text.<locals>.<listcomp>K   s"    >>>DG>>>r         Cover   z Coverc                f    g | ]-}t          |                    d                              dz   .S )rN   rO   )rI   index)r   r5   r@   s     r   rK   z/SummaryReporter.report_text.<locals>.<listcomp>M   s7    ]]]s4W(=(=#>??!C]]]r   z{:{name_len}}z{:>7}z{:>{n}}z{:>10}NameStmtsMissBranchBrPartrN   Missingc                L    g | ] }|                              |           !S name_lennr.   r   itemformatsmax_nmax_names     r   rK   z/SummaryReporter.report_text.<locals>.<listcomp>W   3    bbbSW,,TH,NNbbbr   r=   -z{:>{n}}%z   {:9})rN   rX   c              3  z   K   | ]5\  }}|                              t          |          d z
            V  6dS rM   r[   Nr.   r   r   r`   valuera   rb   rc   s      r   	<genexpr>z.SummaryReporter.report_text.<locals>.<genexpr>h   s_        #e DM((Uh%RS)(TT     r   c              3  z   K   | ]5\  }}|                              t          |          d z
            V  6dS rg   rh   ri   s      r   rk   z.SummaryReporter.report_text.<locals>.<genexpr>s   s^        D% $$SZZ(eai$PP     r   N)	maxrI   rQ   dictr>   r8   updater?   zip)r3   r@   rB   rD   rF   header_items
header_strrulevaluesend_linera   rb   rc   s    `        @@@r   report_textzSummaryReporter.report_text;   s\     >>>>>!DEEIC
6<<#8#89::Q>HNNQRRUG]]]]P\]]]]^^ 
 
 
 cbbbbb[abbbWW\**
S__$ 	

:

4 	 !  	
 	
 	
 # 	 	F     '*66':':       	JJt     #&vz#:#:  	
 	
 	
 " 	! 	!HJJx    	! 	!r   c           	        t          d |D             d          t          t          d                    dz   t          ddddddd	
          t          t          ||                    d                             dz   t          d                    fd|D             }d                    |          }dd                    d                    t          |d                   dz
  d          gd |dd         D             z             z   }|                     |           |                     |           |D ]V}                    t          d                     |                     fdt          ||          D                        W                    t          dd                     g }	t          ||          D ]B\  }
}|dk    r|}n|
dk    rd| d}nd| d}|	|
         
                    |          z  }	C|                     |	           |D ]}|                     |           d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              3  Z   K   | ]&}t          t          |d                              V  'dS )r   N)rI   r    rJ   s     r   rk   z2SummaryReporter.report_markdown.<locals>.<genexpr>   s6      OO$ODG4455OOOOOOr   r   )defaultz	**TOTAL**rM   z| {:{name_len}}|z{:>9} |z	{:>{n}} |z{:>10} |rR   rN      z Cover c                L    g | ] }|                              |           !S rZ   r^   r_   s     r   rK   z3SummaryReporter.report_markdown.<locals>.<listcomp>   rd   r   r=   | z- |re   c                Z    g | ](}d                      t          |          dz
  d          )S )z-: |rM   re   )rjustrI   )r   r`   s     r   rK   z3SummaryReporter.report_markdown.<locals>.<listcomp>   s0    MMMDv||CIIM3//MMMr   Nz
{:>{n}}% |)rN   c              3     K   | ]B\  }}|                              t          t          |                    d z
            V  CdS rg   )r.   r    r   ri   s      r   rk   z2SummaryReporter.report_markdown.<locals>.<genexpr>   sp         $e DM(('E

33h%RS) )       r   z|{:{name_len}} |)rS   rN   z **z%**z**r[   )rm   rI   rn   rQ   r>   r   r8   ro   r?   rp   r.   )r3   r@   rB   rD   rF   rq   rr   rule_strrt   total_line_itemsr`   rj   insertru   ra   rb   rc   s                 @@@r   report_markdownzSummaryReporter.report_markdown|   s   " OO,OOOYZ[[[x[!1!122Q6#
 
 
 C
6<<#8#89::Q>IOObbbbbb[abbbWW\**
[[\!_--13778MML<LMMMN
 
 
 	

:

8 # 	 	FNN&    
       (+66':':	      	'!  	
 	
 	
 ')vz22 	Y 	YKD%{{)u)))(u 4 4VhRW 4 X XX)***! 	! 	!HJJx    	! 	!r   Nmorfsr   r-   IO[str] | Nonefloatc                   |pt           j        | _        | j                                                            | j        j                   t          | j        |          D ]\  }}| 	                    ||           | j
        j        s| j        st          d          | j        dk    r |                     | 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*   set_query_contextsr)   report_contextsr   report_one_filer&   n_filesr1   r	   r/   r8   pc_covered_strtabular_report
pc_covered)r3   r   r-   franalysiss        r   reportzSummaryReporter.report   s     ,#*  33DK4OPPP24=%HH 	/ 	/LB  X....z! 	4$*< 	42333((JJtz01111!!!z$$r   c                   g d}| j         r|ddgz  }|dgz  }| j        j        r|dgz  }t          dddd	
          }| j         r$|                    t          dd                     g }| j        D ]\  }}|j        }|                                |j        |j	        g}| j         r||j
        |j        gz  }||j        gz  }| j        j        r||                    d          gz  }||j        gz  }|                    |           | j        j        pd                                }d}	|d         dk    rd}	|dd         }n|d         dk    r
|dd         }|                    |          t'          d| j        j                  |dk    rt)          ||	          }n|                    fd|	           d| j        j        | j        j	        g}
| j         r|
| j        j
        | j        j        gz  }
|
| j        j        gz  }
| j        j        r|
dgz  }
g }| j        j        r3| j        r,|                    dt1          | j        d           d           | j        j        r3| j        r,|                    dt1          | j        d           d           | j        d k    r| j        }n| j        } ||||
|           dS )!zWrites tabular report formats.)rS   rT   rU   rV   rW   rN   rX   r   rM   rO   )namestmtsmisscover      )branchbrpartT)r,   r   Fre   N+zInvalid sorting option: )reversec                $    |          | d         fS )Nr   r   )r5   sort_idxs    r   <lambda>z0SummaryReporter.tabular_report.<locals>.<lambda>
  s    $x.$q'!: r   )keyr   TOTALr=   r7   filez" skipped due to complete coverage.z
empty filez	 skipped.r'   )r,   r)   show_missingrn   ro   r0   numbersrelative_filenamen_statements	n_missing
n_branchesn_partial_branchesr   missing_formattedr   appendsortlowergetr   r
   r&   skip_coveredr1   r   
skip_emptyr2   r/   r   rv   )r3   r@   column_orderrB   r   r   numsargssort_optionr   rD   rF   	formatterr   s                @r   r   zSummaryReporter.tabular_report   so    +**= 	+x**F7);# 	"yk!F!!2>>>= 	:Aa 8 8 8999  , 		& 		&LB#D((**D,=t~ND} C$*ABBT())D{' D33T3BBCCT_%%D%%%% {'1688::q>S  G%abb/KK^s""%abb/K##K00M9IMMNNN&  -lGLLLLL::::     tz6
8LM
= 	Q4:0$*2OPPJtz011
;# 	2$J 	;# 	(: 	[VD.77[[[   ;! 	Ud&6 	US&)9<"H"HSSSTTT++,II(I	&,
I>>>>>r   r   r   r   r   c                .   |j         }| xj        |z  c_        |j        dk    }|j        dk    }| j        j        r|r|r| xj        dz  c_        dS | j        j        r|j        dk    r| xj	        dz  c_	        dS | j
                            ||f           dS )z4Report on just one file, the callback from report().r   rM   N)r   r&   r   r   r)   r   r1   r   r   r2   r0   r   )r3   r   r   r   no_missing_linesno_missing_branchess         r   r   zSummaryReporter.report_one_file%  s    

d

 Na/#6!;;# 	4(8 	4=P 	4!#[# 	4(9Q(>(>!##RN33333r   )r#   r   r   r$   )r5   r   r   r$   )r:   r;   r   r$   )
r@   rA   rB   rC   rD   rE   rF   rA   r   r$   )N)r   r   r-   r   r   r   )r   r$   )r   r   r   r   r   r$   )__name__
__module____qualname____doc__r4   r8   r?   rv   r   r   r   r   r   r   r   r"   r"   !   s        44> > > >! ! ! !# # # #?! ?! ?! ?!BK! K! K! K!Z% % % % %,D? D? D? D?L4 4 4 4 4 4r   r"   )r   r   r   r   )"r   
__future__r   stringr   collections.abcr   typingr   r   r   coverage.exceptionsr   r	   coverage.miscr
   r   coverage.pluginr   coverage.report_corer   coverage.resultsr   r   coverage.typesr   r#   r   r   	maketranspunctuationr   r    r"   r   r   r   <module>r      sq     " " " " " "  



 $ $ $ $ $ $ ) ) ) ) ) ) ) ) ) ) 8 8 8 8 8 8 8 8 4 4 4 4 4 4 4 4 ( ( ( ( ( ( 7 7 7 7 7 7 . . . . . . . . ! ! ! ! ! ! "!!!!!!==LL6#5LLL  
, , , ,
R4 R4 R4 R4 R4 R4 R4 R4 R4 R4r   