
    V.j@&                       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	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
lmZ dddZddZdddZddZ G d d      Z	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 ddZddZ ddZ!y)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.

    )annotationsN)CallableIterable)Literal)CoverageExceptionNoDataError)PathAliases)Hasherfile_be_gonehuman_sortedplural)CoverageData)filename_matchc                    i }|rd }nt         j                  j                  }| j                         D ]+  }| j	                  |      }|J t        |      | ||      <   - |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    OC:\xampp\htdocs\tradingbinance\backend\.venv\Lib\site-packages\coverage/data.py<lambda>zline_counts.<locals>.<lambda>+   s        )ospathbasenamemeasured_fileslineslen)datafullpathsummfilename_fnfilenamer   s         r   line_countsr#      sg     D!gg&&'')

8$   &)%j["# * Kr   c                    | j                         r.|j                  t        | j                  |      xs g              n|j                  t	        | |             |j                  | j                  |             y)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"   hashers      r   add_data_to_hashr,   5   sV     }}fTYYx06B78l423
MM$""8,-r   c                   t         j                  j                  t         j                  j                  |             \  }}|xs |g}g }|D ]  }t         j                  j	                  |      r/|j                  t         j                  j                  |             Qt         j                  j                  |      rxt        j                  t         j                  j                  t         j                  j                  |      |            dz   }|j                  t        j                  |             t        d| d       |D cg c]  }|j                  d      r| }}t        |      S c c}w )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 ''z-journal)r   r   splitabspathisfileappendisdirglobescapejoinextendr   endswithr'   )	data_file
data_pathsdata_dirlocalfiles_to_combineppatternfnms           r   combinable_filesrA   D   s    ggmmBGGOOI$>?OHe)zJ77>>!##BGGOOA$67WW]]1kk"'',,rwwq/A5"IJTQG##DIIg$67 I!ANOO  (8X'7s||J?W'7X
 "## Ys   E/E/c                   t        |       }|r
|d   r|d   S t        | d      5 }t        j                  dd      }|j	                  |j                                ddd       |j                         S # 1 sw Y   j                         S xY w)z%Get the hash of the data in the file.hashrbsha3_256F)usedforsecurityN)r   openhashlibnewr&   read	hexdigest)
dbfilenamemfobjr+   s       r   hash_for_data_filerO   c   sz    z"AQvYy*d#t[[UCFMM$))+& $ !! $ !!s   7A33Bc                       e Zd ZdZddZddZy)DataFileClassifierz.Track what files to combine and which to skip.c                "    t               | _        y r   )setfile_hashes)selfs    r   __init__zDataFileClassifier.__init__r   s    %(Ur   c                    	 t        |      }|| j                  v ry| j                  j                  |       y# t        $ r Y yw xY w)z/Determine whether to combine or skip this file.combineskip)rO   	ExceptionrT   add)rU   r   shas      r   classifyzDataFileClassifier.classifyu   sQ    	$Q'C
 $"""  %  	 	s   8 	AAN)returnNone)r   strr^   zLiteral['combine', 'skip'])__name__
__module____qualname____doc__rV   r]   r   r   r   rQ   rQ   o   s    8+r   rQ   c                "   t        | j                         |      }|r|st        d      |d}nt        j                  |j
                        }t               }d}	dx}
x}}|D ]  }|| j                         k(  r:| j                  j                  d      r| j                  j                  d|       Q	 t        j                  j                  |      }|j                  |      }| }|dk(  r| j                  j                  d      r| j                  j                  d|       	 t!        || j                  	      }|j#                          | j%                  ||
       |
dz  }
d}	| j                  j                  d      r]| j                  j                  d|        n>|dz  }| j                  j                  d      r| j                  j                  d|        |s| j                  j                  d      r| j                  j                  d|       t-        |        |r|	st        d      |rC|
|z   |z   dkD  r7dt/        |
d       }|r|d| z  }|r|dt/        |d       dz  } ||       yyy# t        $ r |}Y w xY w# t&        $ rt}|dz  }| j(                  r| j)                  t+        |             | j                  j                  d      r!| j                  j                  d| d|        d}Y d}~*d}~ww xY w)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 combineNFr   dataiozSkipping combining ourself: rX   zCombining data file )debug)map_path   TzCombined data file zCouldn't combine data file : zSkipping duplicate data zDeleting data file zNo usable data filesz	Combined filez
, skipped z, z errored)rA   base_filenamer   	functoolscachemaprQ   data_filename_debugshouldwriter   r   relpath
ValueErrorr]   r   rJ   r&   r   _warnr`   r   r   )r   aliasesr:   strictkeepmessager=   rh   
classifiercombined_anycombinedskippederroredr   rel_file_namefile_actiondelete_this_onenew_dataexcmsgs                       r   combine_parallel_datar      s   F ((:(:(<jI&.//??7;;/#%JL#$$H$w""$$ {{!!(+!!$@"FG	GGOOA.M !))!,"()#{{!!(+!!$8">?M'= Hx8A#;;%%i0KK%%(;M?&KLqLG{{!!),!!$<]O"LM{{!!(+!!$7u"=>Oa d l011Hw&014&6234Zy))CRw/099C 5wW  	 M		 % (1:: JJs3x(;;%%i0KK%%(CM?RTUXTY&Z["'(s+   4I?&'J?JJ	LA)L		Lc                   t        |       }|j                         } t        d|         t        j                  j                  |       st        d       y|j                          t        d|j                                t        |d      }t        |j                               }t        |      }t        t        |d       d       |D ]=  }| d	t        ||   d
       }|j                  |      }|r	|d| dz  }t        |       ? y)z(Implementation of 'coverage debug data'.zpath: z%No data collected: file doesn't existNz
has_arcs: T)r   rk   :rj   linez [])r   rp   printr   r   existsrJ   r%   r#   r   keysr   r   r*   )r"   r   summary	filenamesnfilesr   r   plugins           r   debug_data_filer      s    !D!!#H	F8*
77>>(#56IIK	Jt}})
*+$.GW\\^,I^F	VFF#$A
&'Bvgaj&123!!!$bN"Dd r   c                B    | j                  |      }t        |xs 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   boolr^   zdict[str, int])r   r   r"   r`   r+   r
   r^   r_   r   )r9   r`   r:   Iterable[str] | Noner^   z	list[str])rL   r`   r^   r`   )NNFFN)r   r   rw   zPathAliases | Noner:   r   rx   r   ry   r   rz   zCallable[[str], None] | Noner^   r_   )r"   r`   r^   r_   )r   r   r"   r`   r^   z	list[int])"rd   
__future__r   rm   r4   rH   os.pathr   collections.abcr   r   typingr   coverage.exceptionsr   r   coverage.filesr	   coverage.miscr
   r   r   r   coverage.sqldatar   r   r#   r,   rA   rO   rQ   r   r   r)   r   r   r   <module>r      s    #     .  > & D D 9 +0.$>	" . #''+,0l
ll %l 	l
 l *l 
l^,r   