B
    `                 @   sT   d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
 G dd deZdS )	zSummary reporting    N)env)get_analysis_to_report)Numbers)CoverageExceptionoutput_encodingc               @   s2   e Zd ZdZdd Zdd ZdddZd	d
 ZdS )SummaryReporterz*A reporter for writing the summary report.c             C   sH   || _ | j j| _|  | _d | _g | _d| _d| _t	 | _
d| _d S )Nr   z%s   %s: %s)coverageconfigget_dataZhas_arcsbranchesoutfilefr_analysisskipped_countempty_countr   totalZfmt_err)selfr    r   X/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/coverage/summary.py__init__   s    
zSummaryReporter.__init__c             C   s2   t jr|t }| j|  | jd dS )z-Write a line to the output, adding a newline.
N)r   PY2encoder   r   writerstrip)r   liner   r   r   writeout   s    zSummaryReporter.writeoutNc                s~  |pt j| _| j | jj x$t| j|D ]\}}| 	|| q.W t
dd | jD dg }d| }d}d}|d d }	|d	 }
| jr|	d
7 }	|
d7 }
t }|	d|d df 7 }	|
d|d f 7 }
| jjr|	d7 }	|
d7 }
dt|	 }tddddd}| jr|tddd | |	 | | g }x| jD ]\}}|j}| |j|jf}| jrn||j|jf7 }||jf7 }| jjr||jddf7 }|
| }||jf7 }|||f q6W t| jddrT| jj  }d}|d dkrd}|dd }n|d dkr|dd }|!|  dkr>t"d #| jj|j fd!d"|d# x|D ]}| |d  qZW | j$j%dkr| | d$| j$j| j$jf}| jr|| j$j| j$jf7 }|| j$jf7 }| jjr|d%7 }| |
|  | j$j%s | j&s t"d&| jj'r6| j&r6| || j&| j&dkr,d'nd(f  | jj(rl| j)rl| || j)| j)dkrbd'nd(f  | j$jo|| j$jS ))zWrites a report summarizing coverage statistics per module.

        `outfile` is a file object to write the summary to. It must be opened
        for native strings (bytes on Python 2, Unicode on Python 3).

        c             S   s   g | ]\}}t | qS r   )lenrelative_filename).0franalysisr   r   r   
<listcomp>1   s    z*SummaryReporter.report.<locals>.<listcomp>   z	%%- %ds  z,
%s file%s skipped due to complete coverage.z
%s empty file%s skipped.Namez Stmts   Missz%6d %6dz Branch BrPartz %6d %6dz%*s   ZCoverz	%%%ds%%%%   z
   Missingz   %s-r         )nameZstmtsZmissZcover)branchZbrpartT)r   sortNF+zInvalid sorting option: {!r}c                s   | d   | d fS )Nr'   r   r   )l)positionr   r   <lambda>k       z(SummaryReporter.report.<locals>.<lambda>)keyreverseZTOTAL) zNo data to report.sr4   )*sysstdoutr   r   r
   Zset_query_contextsr	   Zreport_contextsr   report_one_filemaxr   r   r   Zpc_str_widthZshow_missingr   dictupdater   numbersr   n_statements	n_missingZ
n_branchesn_partial_branchesZpc_covered_strZmissing_formattedZ
pc_coveredappendgetattrr,   lowergetr   formatr   Zn_filesr   skip_covered
skip_emptyr   )r   Zmorfsr   r   r    Zmax_nameZfmt_nameZfmt_skip_coveredZfmt_skip_emptyheaderZfmt_coverageZwidth100ZruleZcolumn_orderlinesnumsargstextZsort_optionr3   r   r   )r/   r   report#   s    







  zSummaryReporter.reportc             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	   rE   r   rF   r=   r   r   r@   )r   r   r    rI   Zno_missing_linesZno_missing_branchesr   r   r   r8      s    

zSummaryReporter.report_one_file)N)__name__
__module____qualname____doc__r   r   rL   r8   r   r   r   r   r      s
   
gr   )rP   r6   r   r   Zcoverage.reportr   Zcoverage.resultsr   Zcoverage.miscr   r   objectr   r   r   r   r   <module>   s   