
    L-Ph                        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Zd)dZd*d+dZ	 	 	 	 	 d,d-d#Zd.d$Zd/d&ZdS )0a  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)Iterable)CoverageExceptionNoDataError)PathAliases)Hasherfile_be_gonehuman_sortedplural)CoverageDataFdatar   fullpathboolreturndict[str, int]c                    i }|rd }nt           j        j        }|                                 D ]6}|                     |          }|J t          |          | ||          <   7|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 N )fs    M/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/coverage/data.py<lambda>zline_counts.<locals>.<lambda>+   s         )ospathbasenamemeasured_fileslineslen)r   r   summfilename_fnfilenamer   s         r   line_countsr$      s~     D '!kg&'')) 1 1

8$$   &)%jj[[""##Kr   r#   strhasherr	   Nonec                4   |                                  r8|                    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&   s      r   add_data_to_hashr/   5   s     }} 4fTYYx006B778888l422333
MM$""8,,-----r   	data_file
data_pathsIterable[str] | None	list[str]c                   t           j                            t           j                            |                     \  }}|p|g}g }|D ]}t           j                            |          r3|                    t           j                            |                     Tt           j                            |          rzt          j        t           j        	                    t           j                            |          |                    dz   }|
                    t          j        |                     t          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                <    g | ]}|                     d           |S )z-journal)endswith).0fnms     r   
<listcomp>z$combinable_files.<locals>.<listcomp>[   s)    XXXs||J?W?WXXXXr   )r   r   splitabspathisfileappendisdirglobescapejoinextendr   r+   )r0   r1   data_dirlocalfiles_to_combineppatterns          r   combinable_filesrI   D   s5    gmmBGOOI$>$>??OHe)zJ P P7>>! 	P##BGOOA$6$67777W]]1 	Pk"',,rwq/A/A5"I"IJJDPG##DIg$6$67777N!NNNOOO YX'7XXX
 "###r   aliasesPathAliases | NonestrictkeepmessageCallable[[str], None] | Nonec                   t          |                                 |          }|r|st          d          |d}nt          j        |j                  }t                      }d}	|D ]V}
|
|                                 k    r8| j        	                    d          r| j        
                    d|
           S	 t          j                            |
          }n# t          $ r |
}Y nw xY wt          |
d          5 }t!          j        dd          }|                    |                                           |                                }||v}ddd           n# 1 swxY w Y   | }|r| j        	                    d          r| j        
                    d	|
           |                    |           	 t-          |
| j        
          }|                                 |                     ||           d}	|r |d|            ne# t.          $ rH}| j        r"|                     t3          |                     |r |d| d|            d}Y d}~nd}~ww xY w|r |d|            |rF| j        	                    d          r| j        
                    d|
           t5          |
           X|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 )debug)map_pathTzCombined data file zCouldn't combine data file : zSkipping duplicate data zDeleting data file zNo usable data files)rI   base_filenamer   	functoolscachemapsetdata_filename_debugshouldwriter   r   relpath
ValueErroropenhashlibnewr*   readdigestaddr   r   _warnr%   r
   )r   rJ   r1   rL   rM   rN   rF   rV   file_hashescombined_anyr   rel_file_namefobjr&   shacombine_this_onedelete_this_onenew_dataexcs                      r   combine_parallel_datars   c   s   F ((:(:(<(<jII 0& 0.///?7;//%%KL 2 2""$$$$ {!!(++ H!!"F"F"FGGG	GOOA..MM 	 	 	 MMM		 !T]] 	6d[UCCCFMM$))++&&&--//C"+5		6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 #( 	D{!!(++ @!!">">">???OOC   C'=== Hx888# CGA-AABBB % ( ( (: ) JJs3xx((( RGP-PP3PPQQQ"'(  DB=BBCCC 	{!!(++ ?!!"="="=>>>OOO 2l 201112 2 2 2s=   :CC)(C)<AEE"	%E"	;*H
I!>II!c           	        t          |           }|                                } t          d|             t          j                            |           st          d           dS |                                 t          d|                                           t          |d          }t          |
                                          }t          |          }t          | dt          |           d           |D ]T}| d	||          d
t          ||                    }|                    |          }|r	|d| dz  }t          |           UdS )z(Implementation of 'coverage debug data'.zpath: z%No data collected: file doesn't existNz
has_arcs: T)r   z file:rW   z linez [])r   r]   printr   r   existsrf   r)   r$   r   keysr    r   r.   )r#   r   summary	filenamesnfilesr   lineplugins           r   debug_data_filer      sb   !!D!!##H	
8

7>>(## 5666IIKKK	
*t}}
*
*+++$...GW\\^^,,I^^F	V
+
+&..
+
+
+,,,  <<wqz<<wqz(:(:<<!!!$$ 	#NNNN"Dd r   	list[int]c                N    |                      |          }t          |pg           S )z+Get the sorted lines for a file, for tests.)r   r+   )r   r#   r   s      r   r-   r-      s%    JJx  E%+2r   )F)r   r   r   r   r   r   )r   r   r#   r%   r&   r	   r   r'   r   )r0   r%   r1   r2   r   r3   )NNFFN)r   r   rJ   rK   r1   r2   rL   r   rM   r   rN   rO   r   r'   )r#   r%   r   r'   )r   r   r#   r%   r   r   )__doc__
__future__r   rY   r@   rd   os.pathr   typingr   collections.abcr   coverage.exceptionsr   r   coverage.filesr   coverage.miscr	   r
   r   r   coverage.sqldatar   r$   r/   rI   rs   r   r-   r   r   r   <module>r      sw    # " " " " "              $ $ $ $ $ $ > > > > > > > > & & & & & & D D D D D D D D D D D D 9 9 9 9 9 9    0. . . .$ $ $ $ $B #''+,0e2 e2 e2 e2 e2P   ,     r   