
    q"hl                         S SK r S SKJrJrJrJrJrJrJr  S SK	J
r
JrJr  S SKJr  \(       a  S SK Jr  Sr/ SQr " S S	5      r " S
 S\5      rg)    N)TYPE_CHECKINGBinaryIODictIterableListNoReturnOptional)HashMismatchHashMissingInstallationError)read_chunks)_Hashsha256)r   sha384sha512c                      \ rS rSrSrSS\\\\\   4      SS4S jjr	SS jr
\S\4S	 j5       rS
\S\S\4S jrS\\   SS4S jrS\\S4   SS4S jrS\SS4S jrS\SS4S jrS\\\4   S\4S jrS\4S jrS\S\4S jrS\4S jrSrg)Hashes   zYA wrapper that builds multiple hashes at once and checks them against
known-good values

Nhashesreturnc                     0 nUbD  UR                  5        H0  u  p4[        U5       Vs/ s H  oUR                  5       PM     snX#'   M2     X l        gs  snf )zW
:param hashes: A dict of algorithm names pointing to lists of allowed
    hex digests
N)itemssortedlower_allowed)selfr   allowedalgkeysks         L/var/www/html/env/lib/python3.13/site-packages/pip/_internal/utils/hashes.py__init__Hashes.__init__   sL    
 #\\^	39$<@<a	<@ ,    As   Aotherc                 :   [        U[        5      (       d  [        $ U(       d  U $ U (       d  U$ 0 nUR                  R	                  5        H?  u  p4X0R                  ;  a  M  U Vs/ s H  oUU R                  U   ;   d  M  UPM     snX#'   MA     [        U5      $ s  snf N)
isinstancer   NotImplementedr   r   )r   r$   newr   valuesvs         r!   __and__Hashes.__and__'   s    %((!! KL  >>//1KC--'#)E6a$--2D-D6ECH 2 c{ Fs   $B>Bc                 V    [        S U R                  R                  5        5       5      $ )Nc              3   8   #    U  H  n[        U5      v   M     g 7fr&   )len).0digestss     r!   	<genexpr>&Hashes.digest_count.<locals>.<genexpr><   s     F/EG3w<</Es   )sumr   r*   r   s    r!   digest_countHashes.digest_count:   s     Ft}}/C/C/EFFF    	hash_name
hex_digestc                 >    X R                   R                  U/ 5      ;   $ )z/Return whether the given hex digest is allowed.)r   get)r   r:   r;   s      r!   is_hash_allowedHashes.is_hash_allowed>   s    ]]..y"===r9   chunksc                    0 nU R                   R                  5        H  n [        R                  " U5      X#'   M     U H+  nUR                  5        H  nUR                  U5        M     M-     UR                  5        H(  u  p6UR                  5       U R                   U   ;   d  M(    g   U R                  U5        g! [        [
        4 a    [        SU 35      ef = f)zjCheck 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   r@   gotsr:   chunkhashgots          r!   check_against_chunksHashes.check_against_chunksB   s     ++-IK")++i"8 . EE" &  #jjlNI}}$--	":: + 	D 	* K'*=i[(IJJKs   B<<CrH   r   r   c                 .    [        U R                  U5      er&   )r
   r   r   rH   s     r!   rG   Hashes._raiseY   s    4==$//r9   filec                 6    U R                  [        U5      5      $ )zQCheck good hashes against a file-like object

Raise HashMismatch if none match.

)rL   r   )r   rQ   s     r!   check_against_fileHashes.check_against_file\   s     ((T):;;r9   pathc                 r    [        US5       nU R                  U5      sS S S 5        $ ! , (       d  f       g = f)Nrb)openrS   )r   rU   rQ   s      r!   check_against_pathHashes.check_against_pathd   s(    $**40 s   (
6c                 f    UR                  5        H  u  p#U R                  X#5      (       d  M    g   g)z3Return whether any of the given hashes are allowed.TF)r   r>   )r   r   r:   r;   s       r!   
has_one_ofHashes.has_one_ofh   s.    %+\\^!I##I:: &4 r9   c                 ,    [        U R                  5      $ )z,Return whether I know any known-good hashes.)boolr   r6   s    r!   __bool__Hashes.__bool__o   s    DMM""r9   c                 j    [        U[        5      (       d  [        $ U R                  UR                  :H  $ r&   )r'   r   r(   r   )r   r$   s     r!   __eq__Hashes.__eq__s   s(    %((!!}}..r9   c           	          [        SR                  [        S U R                  R	                  5        5       5      5      5      $ )N,c              3   ^   #    U  H#  u  pU  H  nS R                  X45      v   M     M%     g7f):N)join)r1   r   digest_listdigests       r!   r3   "Hashes.__hash__.<locals>.<genexpr>{   s5      ,A("- HHc]++"- ,,As   +-)rJ   ri   r   r   r   r6   s    r!   __hash__Hashes.__hash__x   s=    HH ,0MM,?,?,A 
 	
r9   )r   r&   )r$   r   r   r   )__name__
__module____qualname____firstlineno____doc__r	   r   strr   r"   r,   propertyintr7   r_   r>   r   bytesrL   rG   r   rS   rY   r\   r`   objectrc   rm   __static_attributes__ r9   r!   r   r      s   

 xS$s)^(<= 
  
 & Gc G G> ># >$ >8E? t .04W- 0* 0<x <D <1s 1t 1c3h D #$ #/F /t /
	
# 	
r9   r   c                   L   ^  \ rS rSrSrS
U 4S jjrS\\S4   SS4S jrS	r	U =r
$ )MissingHashes   zA 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.

r   c                 ,   > [         TU ]  [        / 0S9  g)z!Don't offer the ``hashes`` kwarg.)r   N)superr"   FAVORITE_HASH)r   	__class__s    r!   r"   MissingHashes.__init__   s     	 34r9   rH   r   r   c                 B    [        U[           R                  5       5      er&   )r   r   rF   rO   s     r!   rG   MissingHashes._raise   s    $}-779::r9   rz   )r   N)ro   rp   rq   rr   rs   r"   r   rt   rG   ry   __classcell__)r   s   @r!   r|   r|      s.    5;4W- ;* ; ;r9   r|   )rB   typingr   r   r   r   r   r   r	   pip._internal.exceptionsr
   r   r   pip._internal.utils.miscr   r   r   STRONG_HASHESr   r|   rz   r9   r!   <module>r      sG     T T T Q Q 0
 
 /l
 l
^;F ;r9   