o
    g                     @  s   d Z ddlmZ ddlZddlZddlZddlmZm	Z	m
Z
mZ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d/d0ddZ							d1d2d%d&Zd3d'd(Zd4d*d+ZdS )5a  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)CallableDictIterableListOptional)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   M/var/www/html/bloggers_ems/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_hash3   s   r-   	data_file
data_pathsOptional[Iterable[str]]	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 }|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>Y   s    z$combinable_files.<locals>.<listcomp>)r   r   splitabspathisfileappendisdirglobescapejoinextendr	   )r.   r/   data_dirlocalfiles_to_combineppatternr   r   r   combinable_filesB   s   
 rE   aliasesOptional[PathAliases]strictkeepmessageOptional[Callable[[str], None]]c                 C  s  t |  |}|r|stdt }d}|D ]}	|	|  kr.| jdr-| jd|	 qztj	
|	}
W n tyA   |	}
Y nw t|	d}td}||  | }||v}W d   n1 sfw   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|st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 combineFdataiozSkipping combining ourself: rbsha3_256NzCombining data file )debugzCouldn't combine data file : )rF   TzCombined data file zSkipping duplicate data zDeleting data file zNo usable data files)rE   base_filenamer	   setdata_filename_debugshouldwriter   r   relpath
ValueErroropenhashlibnewr(   readdigestaddr   r   _warnr$   r   )r   rF   r/   rH   rI   rJ   rB   file_hashescombined_anyr   rel_file_namefobjr%   shacombine_this_onedelete_this_onenew_dataexcr   r   r   combine_parallel_data^   sh   #


	ri   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:rP   z linez [])r   rS   printr   r   existsr\   r'   r#   r   keysr   r   r,   )r"   r   summary	filenamesnfilesr   linepluginr   r   r   debug_data_file   s&    

rt   	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/   r0   r   r1   )NNFFN)r   r   rF   rG   r/   r0   rH   r   rI   r   rJ   rK   r   r&   )r"   r$   r   r&   )r   r   r"   r$   r   ru   )__doc__
__future__r   r<   rZ   os.pathr   typingr   r   r   r   r   coverage.exceptionsr   r	   coverage.filesr
   coverage.miscr   r   r   r   coverage.sqldatar   r#   r-   rE   ri   rt   r+   r   r   r   r   <module>   s*   	

c