Ë
    ìÏj4%  ã                  ó  — 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    úJ/var/www/html/gaurav-v2/venv/lib/python3.12/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áá!‰ä—g‘g×&Ñ&ˆØ×'Ñ'Ö)ˆØ—
‘
˜8Ó$ˆØÐ Ð Ð Ü&)¨%£jˆ‰[˜Ó"Ò#ð *ð €Kr   c                óö   — | j                  «       r.|j                  t        | j                  |«      xs g «      «       n|j                  t	        | |«      «       |j                  | j                  |«      «       y)zÊContribute `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   € ð ‡}�}„Ø�‰”f˜TŸY™Y xÓ0Ò6°BÓ7Õ8à�‰”l 4¨Ó2Ô3Ø
‡M�M�$×"Ñ" 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 )zÃMake 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  € ô —g‘g—m‘m¤B§G¡G§O¡O°IÓ$>Ó?�O€HˆeàÒ) ˜z€JØÐÛˆÜ�7‰7�>‰>˜!ÔØ×#Ñ#¤B§G¡G§O¡O°AÓ$6Õ7Ü�W‰W�]‰]˜1ÔÜ—k‘k¤"§'¡'§,¡,¬r¯w©w¯©¸qÓ/AÀ5Ó"IÓJÈTÑQˆGØ×#Ñ#¤D§I¡I¨gÓ$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ÙˆQˆvŠYØ�‰yÐä�*˜dÔ# tÜ—[‘[ ¸UÔCˆFØ�M‰M˜$Ÿ)™)›+Ô&÷ $ð ×ÑÓ!Ð!÷ $ð ×ÑÓ!Ð!ú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Øð	ÜŸG™GŸO™O¨AÓ.ˆMð !×)Ñ)¨!Ó,ˆà"˜(ˆØ˜)Ò#Ø�{‰{×!Ñ! (Ô+Ø—‘×!Ñ!Ð$8¸¸Ð">Ô?ðMÜ'¨°·±Ô=�Ø—‘”ð —‘˜H¨x�Ô8Ø˜A‘�Ø#�Ø—;‘;×%Ñ% iÔ0Ø—K‘K×%Ñ%Ð(;¸M¸?Ð&KÕLà�q‰LˆGØ�{‰{×!Ñ! )Ô,Ø—‘×!Ñ!Ð$<¸]¸OÐ"LÔMãØ�{‰{×!Ñ! (Ô+Ø—‘×!Ñ!Ð$7¸°uÐ"=Ô>Ü˜ŽOða ñd ‘lÜÐ0Ó1Ð1á�H˜wÑ&¨Ñ0°1Ò4Øœ& ¨6Ó2Ð3Ð4ˆÙØ�Z ˜yÐ)Ñ)ˆCÙØ�Rœ˜w¨Ó/Ð0°Ð9Ñ9ˆCÙ��ð 5€wøôW ò 	ð ‹Mð		ûô %ò (Ø˜1‘�Ø—:’:ð —J‘Jœs 3›xÔ(Ø—;‘;×%Ñ% iÔ0Ø—K‘K×%Ñ%Ð(CÀMÀ?ÐRTÐUXÐTYÐ&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Ü	ˆF�8�*Ð
ÔÜ�7‰7�>‰>˜(Ô#ÜÐ5Ô6ØØ‡I�I„KÜ	ˆJ�t—}‘}“Ð)Ð
*Ô+Ü˜$¨Ô.€GÜ˜WŸ\™\›^Ó,€IÜ�‹^€FÜ	ŒV�F˜FÓ#Ð$ AÐ
&Ô'ÛˆØ��B”v˜g a™j¨&Ó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   € à�J‰J�xÓ €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   