o
    v&i                     @  s   d Z ddlmZ ddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZmZ ddlmZ ddlmZmZmZmZ dd	lmZ d-d.ddZd/ddZd0d1ddZ			
	
	d2d3d&d'Zd4d(d)Zd5d+d,ZdS )6a  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.

    )annotationsN)Iterable)Callable)CoverageExceptionNoDataError)PathAliases)Hasherfile_be_gonehuman_sortedplural)CoverageDataFdatar   fullpathboolreturndict[str, int]c                 C  sR   i }|r	dd }nt jj}|  D ]}| |}|dusJ 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   S/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/coverage/data.py<lambda>*   s    zline_counts.<locals>.<lambda>N)ospathbasenamemeasured_fileslineslen)r   r   summfilename_fnfilenamer   r   r   r   line_counts   s   


r    r   strhasherr   Nonec                 C  sF   |   r|t| |pg  n|t| | || | 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arcssorted_linesfile_tracer)r   r   r"   r   r   r   add_data_to_hash4   s   r*   	data_file
data_pathsIterable[str] | None	list[str]c                 C  s   t jt j| \}}|p|g}g }|D ]8}t j|r'|t j| qt j|rFtt j	t j||d }|
t| qtd| ddd |D }t|S )zMake a list of data files to be combined.

    `data_file` is a path to a data file.  `data_paths` is a list of files or
    directories of files.

    Returns a list of absolute file paths.
    z.*z)Couldn't combine from non-existent path ''c                 S  s   g | ]	}| d s|qS )z-journal)endswith).0fnmr   r   r   
<listcomp>Z   s    z$combinable_files.<locals>.<listcomp>)r   r   splitabspathisfileappendisdirglobescapejoinextendr   r&   )r+   r,   data_dirlocalfiles_to_combineppatternr   r   r   combinable_filesC   s   
 rB   aliasesPathAliases | NonestrictkeepmessageCallable[[str], None] | Nonec                 C  s  t |  |}|r|std|du rd}nt|j}t }d}	|D ]}
|
|  kr;| j	dr:| j
d|
 q#ztj|
}W n tyN   |
}Y nw t|
d}tjddd}||  | }||v}W d   n1 suw   Y  | }|r| j	dr| j
d	|
 || zt|
| jd
}|  W n* ty } z| jr| t| |r|d| d|  d}W Y d}~n!d}~ww | j||d d}	|r|d|  n	|r|d|  |r| j	dr| j
d|
 t|
 q#|r|	s	tddS dS )a  Combine a number of data files together.

    `data` is a CoverageData.

    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.

    `message` is a function to use for printing messages to the user.

    zNo data to combineNFdataiozSkipping combining ourself: rbsha3_256)usedforsecurityzCombining data file )debugzCouldn't combine data file : )map_pathTzCombined data file zSkipping duplicate data zDeleting data file zNo usable data files)rB   base_filenamer   	functoolscachemapsetdata_filename_debugshouldwriter   r   relpath
ValueErroropenhashlibnewr%   readdigestaddr   r   _warnr!   r	   )r   rC   r,   rE   rF   rG   r?   rO   file_hashescombined_anyr   rel_file_namefobjr"   shacombine_this_onedelete_this_onenew_dataexcr   r   r   combine_parallel_datab   sn   #

	rk   c                 C  s   t | }| } td|   tj| std dS |  td|  t|dd}t	|
 }t|}t| dt| d |D ]%}| d	||  d
t||  }||}|rg|d| d7 }t| qFdS )z(Implementation of 'coverage debug data'.zpath: z%No data collected: file doesn't existNz
has_arcs: T)r   z file:rN   z linez [])r   rU   printr   r   existsr^   r$   r    r
   keysr   r   r)   )r   r   summary	filenamesnfilesr   linepluginr   r   r   debug_data_file   s&    

rv   	list[int]c                 C  s   |  |}t|p	g S )z+Get the sorted lines for a file, for tests.)r   r&   )r   r   r   r   r   r   r(      s   
r(   )F)r   r   r   r   r   r   )r   r   r   r!   r"   r   r   r#   r   )r+   r!   r,   r-   r   r.   )NNFFN)r   r   rC   rD   r,   r-   rE   r   rF   r   rG   rH   r   r#   )r   r!   r   r#   )r   r   r   r!   r   rw   )__doc__
__future__r   rQ   r9   r\   os.pathr   collections.abcr   typingr   coverage.exceptionsr   r   coverage.filesr   coverage.miscr   r	   r
   r   coverage.sqldatar   r    r*   rB   rk   rv   r(   r   r   r   r   <module>   s.   	
!
h