Ë
    oPê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mZ dd	lmZ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Úneutralize_controlÚ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    úR/home/oem/CyberBrain26-unified/.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$      sl   € ð €Dáá!‰ä—g‘g×&Ñ&ˆØ×'Ñ'Ó)ò 1ˆØ—
‘
˜8Ó$ˆØÐ Ð Ð Ü&)¨%£jˆ‰[˜Ó"Ò#ð1ð €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-   7   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_filesrB   F   s  € ô —g‘g—m‘m¤B§G¡G§O¡O°IÓ$>Ó?�O€HˆeàÒ) ˜z€JØÐØò PˆÜ�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ðPð (8ÖX ¸s¿|¹|ÈJÕ?WšÐXÐÐ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_filerP   e   s   € ä�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__t   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)rP   Ú	ExceptionrU   Úadd)rV   r   Úshas      r   ÚclassifyzDataFileClassifier.classifyw   sQ   € ð	Ü$ QÓ'ˆCð
 �$×"Ñ"Ñ"Øà×Ñ× Ñ  Ô%Øøô ò 	ñ ð	ús   ‚8 ¸	AÁAN)ÚreturnÚNone)r   Ústrr_   zLiteral['combine', 'skip'])Ú__name__Ú
__module__Ú__qualname__Ú__doc__rW   r^   r   r   r   rR   rR   q   s   „ Ù8ó+ôr   rR   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                  d	¬
«      }|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: rY   zCombining data file T)ÚdebugÚ	read_only)Úmap_pathé   z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)rB   Úbase_filenamer   Ú	functoolsÚcacheÚmaprR   Údata_filenameÚ_debugÚshouldÚwriter   r   ÚrelpathÚ
ValueErrorr^   r   rK   r'   r   Ú_warnra   r   r   )r   Úaliasesr;   ÚstrictÚkeepÚmessager>   rj   Ú
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˜Øó 0ˆØ�×"Ñ"Ó$Ò$ð �{‰{×!Ñ! (Ô+Ø—‘×!Ñ!Ð$@ÀÀÐ"FÔGØð	ÜŸG™GŸO™O¨AÓ.ˆMð !×)Ñ)¨!Ó,ˆà"˜(ˆØ˜)Ò#Ø�{‰{×!Ñ! (Ô+Ø—‘×!Ñ!Ð$8¸¸Ð">Ô?ðMÜ'¨°·±ÈÔM�Ø—‘”ð —‘˜H¨x�Ô8Ø˜A‘�Ø#�Ø—;‘;×%Ñ% iÔ0Ø—K‘K×%Ñ%Ð(;¸M¸?Ð&KÕLà�q‰LˆGØ�{‰{×!Ñ! )Ô,Ø—‘×!Ñ!Ð$<¸]¸OÐ"LÔMãØ�{‰{×!Ñ! (Ô+Ø—‘×!Ñ!Ð$7¸°uÐ"=Ô>Ü˜ŽOða0ñ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J Ä&(JÊ JÊJÊ	LÊA)L
Ì
Lc                óB  — t        | d¬«      }|j                  «       } t        d| › �«       t        j                  j                  | «      st        d«       y|j                  «        t        d|j                  «       ›�«       t        |d¬«      }t        |j                  «       «      }t        |«      }t        t        |d«      › d	�«       |D ]O  }t        |«      › d
t        ||   d«      › �}|j                  |«      }|r|dt        |«      › d�z  }t        |«       ŒQ y)z(Implementation of 'coverage debug data'.T)ri   zpath: z%No data collected: file doesn't existNz
has_arcs: )r    rm   ú:rl   Úlinez [ú])r   rr   Úprintr   r   ÚexistsrK   r&   r$   r   Úkeysr   r   r   r+   )r#   r   ÚsummaryÚ	filenamesÚnfilesr   r‹   Úplugins           r   Údebug_data_filer”   õ   s  € ä˜¨DÔ1€DØ×!Ñ!Ó#€HÜ	ˆF�8�*Ð
ÔÜ�7‰7�>‰>˜(Ô#ÜÐ5Ô6ØØ‡I�I„KÜ	ˆJ�t—}‘}“Ð)Ð
*Ô+Ü˜$¨Ô.€GÜ˜WŸ\™\›^Ó,€IÜ�‹^€FÜ	ŒV�F˜FÓ#Ð$ AÐ
&Ô'Øò ˆÜ$ QÓ'Ð(¨¬6°'¸!±*¸fÓ+EÐ*FÐGˆØ×!Ñ! !Ó$ˆÙØ�bÔ+¨FÓ3Ð4°AÐ6Ñ6ˆ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#   ra   r,   r
   r_   r`   r   )r:   ra   r;   úIterable[str] | Noner_   z	list[str])rM   ra   r_   ra   )NNFFN)r   r   ry   zPathAliases | Noner;   r—   rz   r–   r{   r–   r|   zCallable[[str], None] | Noner_   r`   )r#   ra   r_   r`   )r   r   r#   ra   r_   z	list[int])#re   Ú
__future__r   ro   r5   rI   Úos.pathr   Úcollections.abcr   r   Útypingr   Úcoverage.exceptionsr   r   Úcoverage.filesr	   Úcoverage.miscr
   r   r   r   r   Úcoverage.sqldatar   r   r$   r-   rB   rP   rR   rˆ   r”   r*   r   r   r   ú<module>r       s»   ðñõ #ã Û Û Û ß .Ý ç >Ý &ß XÕ X÷ôó0.ô$ó>	"÷ñ ð. #'Ø'+ØØØ,0ðlØ
ðlàðlð %ðlð ð	lð
 ðlð *ðlð 
óló^ô,r   