B
    ê¹`Æ  ã               @   sP   d Z ddlZddlZddlmZmZ ddlmZ ddd„Z	dd	„ Z
dd
d„ZdS )a  Coverage data for coverage.py.

This file had the 4.x JSON data support, which is now gone.  This file still
has storage-agnostic helpers, and is kept to avoid changing too many imports.
CoverageData is now defined in sqldata.py, and imported here to keep the
imports working.

é    N)ÚCoverageExceptionÚfile_be_gone)ÚCoverageDataFc             C   sF   i }|rdd„ }nt jj}x&|  ¡ D ]}t|  |¡ƒ|||ƒ< q$W |S )aH  Return a dict summarizing the line coverage data.

    Keys are based on the file names, and values are the number of executed
    lines.  If `fullpath` is true, then the keys are the full pathnames of
    the files, otherwise they are the basenames of the files.

    Returns a dict mapping file names to counts of lines.

    c             S   s   | S )N© )Úfr   r   úU/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/coverage/data.pyÚ<lambda>    ó    zline_counts.<locals>.<lambda>)ÚosÚpathÚbasenameZmeasured_filesÚlenÚlines)ÚdataÚfullpathZsummZfilename_fnÚfilenamer   r   r   Úline_counts   s    

r   c             C   sN   |   ¡ r"| t|  |¡pg ƒ¡ n| t|  |¡p4g ƒ¡ | |  |¡¡ dS )zÊContribute `filename`'s data to the `hasher`.

    `hasher` is a `coverage.misc.Hasher` instance to be updated with
    the file's data.  It should only get the results data, not the run
    data.

    N)Zhas_arcsÚupdateÚsortedZarcsr   Zfile_tracer)r   r   Zhasherr   r   r   Úadd_data_to_hash(   s    r   c             C   s¸  t j |  ¡ ¡\}}|d }|p$|g}g }xn|D ]f}	t j |	¡rT| t j |	¡¡ q0t j |	¡rˆt j t j |	¡|¡}
| 	t
 
|
¡¡ q0td|	f ƒ‚q0W |rª|sªtdƒ‚d}xð|D ]è}||  ¡ krä| j d¡r´| j d|f ¡ q´| j d¡r| j d|f ¡ yt|| jd}| ¡  W n: tk
rX } z| jrH|  t|ƒ¡ W d	d	}~X Y q´X | j||d
 |d7 }|s´| j d¡r”| j d|f ¡ t|ƒ q´W |r´|s´tdƒ‚d	S )a™  Combine a number of data files together.

    Treat `data.filename` as a file prefix, and combine the data from all
    of the data files starting with that prefix plus a dot.

    If `aliases` is provided, it's a `PathAliases` object that is used to
    re-map paths to match the local machine's.

    If `data_paths` is provided, it is a list of directories or files to
    combine.  Directories are searched for files that start with
    `data.filename` plus dot as a prefix, and those files are combined.

    If `data_paths` is not provided, then the directory portion of
    `data.filename` is used as the directory to search for data files.

    Unless `keep` is True every data file found and combined is then deleted from disk. If a file
    cannot be read, a warning will be issued, and the file will not be
    deleted.

    If `strict` is true, and no files are found to combine, an error is
    raised.

    z.*z,Couldn't combine from non-existent path '%s'zNo data to combiner   ZdataiozSkipping combining ourself: %rzCombining data file %r)ÚdebugN)Úaliasesé   zDeleting combined data file %rzNo usable data files)r
   r   ÚsplitÚbase_filenameÚisfileÚappendÚabspathÚisdirÚjoinÚextendÚglobr   Zdata_filenameÚ_debugZshouldÚwriter   ÚreadÚ_warnÚstrr   r   )r   r   Z
data_pathsÚstrictZkeepÚdata_dirÚlocalZlocaldotZfiles_to_combineÚpÚpatternZfiles_combinedr   Znew_dataÚexcr   r   r   Úcombine_parallel_data7   sF    


 r-   )F)NNFF)Ú__doc__r!   Úos.pathr
   Zcoverage.miscr   r   Zcoverage.sqldatar   r   r   r-   r   r   r   r   Ú<module>   s   
