B
    `                 @   sX   d Z ddlZddlmZ ddlmZmZ ddlmZm	Z	m
Z
mZmZ dd Zdd	 ZdS )
z$Reporter foundation for coverage.py.    N)env)prep_patternsFnmatchMatcher)CoverageExceptionNoSource	NotPythonensure_dir_for_filefile_be_gonec             C   s   d}d}| rH| dkrt j}n,t|  i }tjr6d|d< t| df|}|}z.y|j||dS  tk
rr   d} Y nX W d|r|  |rt	|  X dS )	a  Run the provided reporter ensuring any required setup and cleanup is done

    At a high level this method ensures the output file is ready to be written to. Then writes the
    report to it. Then closes the file and deletes any garbage created if necessary.
    NF-utf8encodingw)outfileT)
sysstdoutr   r   PY3openreportr   closer	   )Zoutput_pathreportermorfsZfile_to_closeZdelete_filer   Zopen_kwargs r   W/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/coverage/report.pyrender_report   s(    r   c          	   #   s   |  |}| j}|jr6tt|j  fdd|D }|jr\tt|j  fdd|D }|shtdxt|D ]x}y| |}W nZ t	k
r   |j
s Y qr tk
r   | r|j
rd|j}| j|dd n Y qrX ||fV  qrW dS )	zGet the files to report on.

    For each morf in `morfs`, if it should be reported on (based on the omit
    and include configuration options), yield a pair, the `FileReporter` and
    `Analysis` for the morf.

    c                s   g | ]}  |jr|qS r   )matchfilename).0fr)matcherr   r   
<listcomp>;   s    z*get_analysis_to_report.<locals>.<listcomp>c                s   g | ]}  |js|qS r   )r   r   )r   r   )r   r   r   r   ?   s    zNo data to report.zCouldn't parse Python file '{}'zcouldnt-parse)ZslugN)Z_get_file_reportersconfigZreport_includer   r   Zreport_omitr   sortedZ_analyzer   ignore_errorsr   Zshould_be_pythonformatr   _warn)coverager   Zfile_reportersr    r   Zanalysismsgr   )r   r   get_analysis_to_report.   s.    
r'   )__doc__r   r%   r   Zcoverage.filesr   r   Zcoverage.miscr   r   r   r   r	   r   r'   r   r   r   r   <module>   s   "