L idZddlmZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZddlmZddlmZmZmZmZdd lmZddd Zdd Zddd Z d dd ZddZddZy)aCoverage 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_sortedplural) CoverageDataci}|rd}ntjj}|jD]+}|j |}|Jt ||||<-|S)aHReturn 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|SN)fs S/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/coverage/data.pyzline_counts..*s)ospathbasenamemeasured_fileslineslen)datafullpathsumm filename_fnfilenamers r line_countsr!sl D! gg&& '')1 8$   &)%j[ "#1 Krc|jr.|jt|j|xsgn|jt |||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_arcsupdatesortedarcs sorted_lines file_tracer)rr hashers radd_data_to_hashr*4sV }} fTYYx06B78 l423 MM$""8,-rctjjtjj|\}}|xs|g}g}|D]}tjj |r/|j tjj|Qtjj |rxtjtjjtjj||dz}|jtj|td|d|Dcgc]}|jdr|}}t|Scc}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)rrsplitabspathisfileappendisdirglobescapejoinextendrendswithr%) data_file data_pathsdata_dirlocalfiles_to_combineppatternfnms rcombinable_filesr?CsggmmBGGOOI$>?OHe)zJ P 77>>!   # #BGGOOA$6 7 WW]]1 kk"'',,rwwq/A5"IJTQG  # #DIIg$6 7 I!ANO OP(8Xs||J?WXX " ## Ys E/E/c8t|j|}|r |s td|d}ntj|j }t }d} |D]} | |jk(r:|jjdr|jjd| Q tjj| } t| d5} t!j"dd} | j%| j'| j)}||v}ddd| }r|jjdr|jjd | |j+ t-| |j }|j'|j%|| d } |r|d | n |r |d| |s{|jjdr|jjd| t5| |r| s tdyy#t$r| } YpwxYw#1swYxYw#t.$rB}|j0r|j1t3||r|d| d|d}Yd}~d}~wwxYw)aCombine 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. zNo data to combineNFdataiozSkipping combining ourself: rbsha3_256)usedforsecurityzCombining data file )debug)map_pathTzCombined data file zCouldn't combine data file : zSkipping duplicate data zDeleting data file zNo usable data files)r? base_filenamer functoolscachemapset data_filename_debugshouldwriterrrelpath ValueErroropenhashlibnewr$readdigestaddr r_warnstrr )raliasesr8strictkeepmessager;rF file_hashes combined_anyr rel_file_namefobjr)shacombine_this_onedelete_this_onenew_dataexcs rcombine_parallel_datarhbsjF((:(:(? OOC  C'=  Hx 8# 1-AB2=/BC {{!!(+ !!$7u"=> Oe2hl011#vU M    6 6% (::JJs3x(9-3%PQ"' (s7.H/A I<'I/ H>=H>I  J8JJc (t|}|j}td|tjj |s tdy|j td|jt|d}t|j}t|}t|dt|d|D]B}|d ||d t||}|j|}|r |d |d z }t|Dy) z(Implementation of 'coverage debug data'.zpath: z%No data collected: file doesn't existNz has_arcs: T)rz file:rGz linez [])r rMprintrrexistsrVr#r!r keysrr r()r rsummary filenamesnfilesrlineplugins rdebug_data_filerts  !D!!#H F8*  77>>( # 56IIK Jt}}) *+$.GW\\^,I ^F VHE&.) +, Bwqzl%wqz(:';<!!!$  bN "D d rcB|j|}t|xsgS)z+Get the sorted lines for a file, for tests.)rr%)rr rs rr'r's JJx E %+2 r)F)rr rboolreturnzdict[str, int])rr r rZr)r rwNoner)r7rZr8Iterable[str] | Nonerwz list[str])NNFFN)rr r[zPathAliases | Noner8ryr\rvr]rvr^zCallable[[str], None] | Nonerwrx)r rZrwrx)rr r rZrwz list[int])__doc__ __future__rrIr2rTos.pathrcollections.abcrtypingrcoverage.exceptionsrrcoverage.filesr coverage.miscr r r r coverage.sqldatar r!r*r?rhrtr'rrrrs# $>&DD90 .$B#''+,0 e2 e2 e2%e2  e2  e2 * e2 e2P,r