Ë
    »ÿæi†  ã                  óž   — d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	m
Z
mZmZ d dlmZ erd dlmZ dZg d	¢Z G d
„ d«      Z G d„ de«      Zy)é    )ÚannotationsN)ÚIterable)ÚTYPE_CHECKINGÚBinaryIOÚNoReturn)ÚHashMismatchÚHashMissingÚInstallationError)Úread_chunks)Ú_HashÚsha256)r   Úsha384Úsha512c                  ó|   — e Zd ZdZddd„Zdd„Zedd„«       Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zdd„Zdd„Zdd„Zdd„Zy)ÚHasheszaA wrapper that builds multiple hashes at once and checks them against
    known-good values

    Nc                ó¨   — i }|�B|j                  «       D ]/  \  }}t        |«      D �cg c]  }|j                  «       ‘Œ c}||<   Œ1 || _        yc c}w )zo
        :param hashes: A dict of algorithm names pointing to lists of allowed
            hex digests
        N)ÚitemsÚsortedÚlowerÚ_allowed)ÚselfÚhashesÚallowedÚalgÚkeysÚks         úo/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/pip/_internal/utils/hashes.pyÚ__init__zHashes.__init__   sT   € ð
 ˆØÐØ#Ÿ\™\ž^‘	��Tä39¸$´<Ó@±<¨a §¡¥	°<Ñ@�˜’ð ,ð  ˆ�ùò  As   ¨Ac                ó  — t        |t        «      st        S |s| S | s|S i }|j                  j	                  «       D ]9  \  }}|| j                  vrŒ|D �cg c]  }|| j                  |   v sŒ|‘Œ c}||<   Œ; t        |«      S c c}w ©N)Ú
isinstancer   ÚNotImplementedr   r   )r   ÚotherÚnewr   ÚvaluesÚvs         r   Ú__and__zHashes.__and__*   s�   € Ü˜%¤Ô(Ü!Ð!ñ ØˆKÙØˆLð ˆØ Ÿ>™>×/Ñ/Ö1‰KˆC�Ø˜$Ÿ-™-Ñ'ØÙ#)ÓE¡6˜a¨Q°$·-±-ÀÑ2DÒ-Dš 6ÑEˆC�ŠHð 2ô �c‹{Ðùò Fs   ÁBÁ+Bc                óV   — t        d„ | j                  j                  «       D «       «      S )Nc              3  ó2   K  — | ]  }t        |«      –— Œ y ­wr    )Úlen)Ú.0Údigestss     r   Ú	<genexpr>z&Hashes.digest_count.<locals>.<genexpr>?   s   è ø€ ÐFÑ/E G”3�w—<Ñ/Eùs   ‚)Úsumr   r%   ©r   s    r   Údigest_countzHashes.digest_count=   s    € äÑF¨t¯}©}×/CÑ/CÔ/EÓFÓFÐFó    c                ó>   — || j                   j                  |g «      v S )z/Return whether the given hex digest is allowed.)r   Úget)r   Ú	hash_nameÚ
hex_digests      r   Úis_hash_allowedzHashes.is_hash_allowedA   s   € à˜TŸ]™]×.Ñ.¨y¸"Ó=Ð=Ð=r1   c                ó¨  — i }| j                   j                  «       D ]  }	 t        j                  |«      ||<   Œ |D ](  }|j                  «       D ]  }|j                  |«       Œ Œ* |j                  «       D ]&  \  }}|j                  «       | j                   |   v sŒ& y | j                  |«       y# t        t
        f$ r t        d|› �«      ‚w xY w)z‚Check good hashes against ones built from iterable of chunks of
        data.

        Raise HashMismatch if none match.

        zUnknown hash name: N)r   r   Úhashlibr$   Ú
ValueErrorÚ	TypeErrorr
   r%   Úupdater   Ú	hexdigestÚ_raise)r   ÚchunksÚgotsr4   ÚchunkÚhashÚgots          r   Úcheck_against_chunkszHashes.check_against_chunksE   sÉ   € ð ˆØŸ™×+Ñ+Ö-ˆIðKÜ")§+¡+¨iÓ"8��Y’ð .ó ˆEØŸ™ž�Ø—‘˜EÕ"ñ &ð ð #Ÿj™jžl‰NˆI�sØ�}‰}‹ $§-¡-°	Ñ":Ò:Ùð +ð 	�‰�DÕøô ¤	Ð*ò KÜ'Ð*=¸i¸[Ð(IÓJÐJðKús   ¡B3Â3Cc                ó.   — t        | j                  |«      ‚r    )r   r   ©r   r?   s     r   r=   zHashes._raise\   s   € Ü˜4Ÿ=™=¨$Ó/Ð/r1   c                ó6   — | j                  t        |«      «      S )zaCheck good hashes against a file-like object

        Raise HashMismatch if none match.

        )rC   r   )r   Úfiles     r   Úcheck_against_filezHashes.check_against_file_   s   € ð ×(Ñ(¬°TÓ):Ó;Ð;r1   c                óh   — t        |d«      5 }| j                  |«      cd d d «       S # 1 sw Y   y xY w)NÚrb)ÚopenrH   )r   ÚpathrG   s      r   Úcheck_against_pathzHashes.check_against_pathg   s(   € Ü�$˜Ô Ø×*Ñ*¨4Ó0÷ ×Òús   �(¨1c                ó\   — |j                  «       D ]  \  }}| j                  ||«      sŒ y y)z3Return whether any of the given hashes are allowed.TF)r   r6   )r   r   r4   r5   s       r   Ú
has_one_ofzHashes.has_one_ofk   s/   € à%+§\¡\¦^Ñ!ˆI�zØ×#Ñ# I¨zÕ:Ùð &4ð r1   c                ó,   — t        | j                  «      S )z,Return whether I know any known-good hashes.)Úboolr   r/   s    r   Ú__bool__zHashes.__bool__r   s   € ä�D—M‘MÓ"Ð"r1   c                ó`   — t        |t        «      st        S | j                  |j                  k(  S r    )r!   r   r"   r   )r   r#   s     r   Ú__eq__zHashes.__eq__v   s%   € Ü˜%¤Ô(Ü!Ð!Ø�}‰} §¡Ñ.Ð.r1   c           	     ó†   — t        dj                  t        d„ | j                  j	                  «       D «       «      «      «      S )NÚ,c              3  óV   K  — | ]!  \  }}|D ]  }d j                  ||f«      –— Œ Œ# y­w)Ú:N)Újoin)r+   r   Údigest_listÚdigests       r   r-   z"Hashes.__hash__.<locals>.<genexpr>~   s7   è ø€ ð á,AÑ(˜˜[Û"-˜ð —H‘H˜c 6˜]×+à"-ð ,Ù,Aùs   ‚'))rA   rY   r   r   r   r/   s    r   Ú__hash__zHashes.__hash__{   s=   € ÜØ�H‰HÜñ à,0¯M©M×,?Ñ,?Ô,Aóó óó
ð 	
r1   r    )r   zdict[str, list[str]] | NoneÚreturnÚNone)r#   r   r]   r   )r]   Úint)r4   Ústrr5   r`   r]   rQ   )r>   zIterable[bytes]r]   r^   ©r?   zdict[str, _Hash]r]   r   )rG   r   r]   r^   )rL   r`   r]   r^   )r   zdict[str, str]r]   rQ   )r]   rQ   )r#   Úobjectr]   rQ   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r'   Úpropertyr0   r6   rC   r=   rH   rM   rO   rR   rT   r\   © r1   r   r   r      sT   „ ñô

 óð& òGó ðGó>óó.0ó<ó1óó#ó/ô
	
r1   r   c                  ó,   ‡ — e Zd ZdZdˆ fd„Zdd„Zˆ xZS )ÚMissingHasheszÀA workalike for Hashes used when we're missing a hash for a requirement

    It computes the actual hash of the requirement and raises a HashMissing
    exception showing it to the user.

    c                ó2   •— t         ‰| �  t        g i¬«       y)z!Don't offer the ``hashes`` kwarg.)r   N)Úsuperr   ÚFAVORITE_HASH)r   Ú	__class__s    €r   r   zMissingHashes.__init__�   s   ø€ ô 	‰Ñ¤°Ð 3ÐÕ4r1   c                óB   — t        |t           j                  «       «      ‚r    )r	   rm   r<   rE   s     r   r=   zMissingHashes._raise•   s   € Ü˜$œ}Ñ-×7Ñ7Ó9Ó:Ð:r1   )r]   r^   ra   )rc   rd   re   rf   r   r=   Ú__classcell__)rn   s   @r   rj   rj   ‡   s   ø„ ñõ5÷;r1   rj   )Ú
__future__r   r8   Úcollections.abcr   Útypingr   r   r   Úpip._internal.exceptionsr   r	   r
   Úpip._internal.utils.miscr   r   rm   ÚSTRONG_HASHESr   rj   rh   r1   r   Ú<module>rw      sJ   ðÝ "ã Ý $ß 4Ñ 4ç QÑ QÝ 0áÝð
 €ò
 /€÷l
ñ l
ô^;�Fõ ;r1   