o
    gH                     @   sZ   d Z ddlZddlZddlmZ ddl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   sB   i }|r	dd }nt jj}|  D ]}t| ||||< q|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   K/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/coverage/data.py<lambda>!   s    zline_counts.<locals>.<lambda>)ospathbasenamemeasured_fileslenlines)datafullpathsummfilename_fnfilenamer   r   r   line_counts   s   

r   c                 C   sN   |   r|t| |pg  n|t| |pg  || | dS )zContribute `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)has_arcsupdatesortedarcsr   file_tracer)r   r   hasherr   r   r   add_data_to_hash)   s   r   c                 C   s  t j|  \}}|d }|p|g}g }	|D ]3}
t j|
r)|	t j|
 qt j|
rCt jt j|
|}|		t

| qtd|
 d|rS|	sStdd}|	D ]~}||  kro| jdrn| jd| qW| jdr~| jd| zt|| jd	}|  W n ty } z| jr| t| W Y d
}~qWd
}~ww | j||d |d7 }|r|dt j|  |s| jdr| jd| t| qW|r|stdd
S 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 ''zNo data to combiner   dataiozSkipping combining ourself: zCombining data file )debugN)aliases   zCombined data file zDeleting combined data file zNo usable data files)r	   r
   splitbase_filenameisfileappendabspathisdirjoinextendglobr   data_filename_debugshouldwriter   read_warnstrr   relpathr   )r   r   
data_pathsstrictkeepmessagedata_dirlocallocaldotfiles_to_combineppatternfiles_combinedr   new_dataexcr   r   r   combine_parallel_data8   sR   
r?   )F)NNFFN)__doc__r)   os.pathr	   coverage.exceptionsr   coverage.miscr   coverage.sqldatar   r   r   r?   r   r   r   r   <module>   s   	
