HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/site-packages/pip/_internal/utils/__pycache__/hashes.cpython-310.pyc
o

��i��@s�ddlZddlmZmZmZmZmZmZddlm	Z	m
Z
mZddlm
Z
er2ddlmZddlmZdZgd�ZGd	d
�d
�ZGdd�de�ZdS)
�N)�
TYPE_CHECKING�BinaryIO�Dict�Iterable�List�Optional)�HashMismatch�HashMissing�InstallationError)�read_chunks)�_Hash)�NoReturn�sha256)r�sha384�sha512c@s�eZdZdZd$deeeeefddfdd�Zd%dd	�Z	e
defd
d��Zded
ede
fdd�Zdeeddfdd�Zdeedfddfdd�Zdeddfdd�Zdeddfdd�Zde
fdd�Zdede
fd d!�Zdefd"d#�ZdS)&�HasheszaA wrapper that builds multiple hashes at once and checks them against
    known-good values

    N�hashes�returncCs4i}|dur|��D]
\}}t|�||<q
||_dS)zo
        :param hashes: A dict of algorithm names pointing to lists of allowed
            hex digests
        N)�items�sorted�_allowed)�selfr�allowed�alg�keys�r�E/usr/local/lib/python3.10/site-packages/pip/_internal/utils/hashes.py�__init__s

zHashes.__init__�othercsbt|t�stS|s�S�s|Si}|j��D]\�}��jvr q��fdd�|D�|�<qt|�S)Ncsg|]}|�j�vr|�qSr)r)�.0�v�rrrr�
<listcomp>;sz"Hashes.__and__.<locals>.<listcomp>)�
isinstancer�NotImplementedrr)rr�new�valuesrr!r�__and__+s

zHashes.__and__cCstdd�|j��D��S)Ncss�|]}t|�VqdS�N)�len)r�digestsrrr�	<genexpr>@s�z&Hashes.digest_count.<locals>.<genexpr>)�sumrr&�rrrr�digest_count>szHashes.digest_count�	hash_name�
hex_digestcCs||j�|g�vS)z/Return whether the given hex digest is allowed.)r�get)rr/r0rrr�is_hash_allowedBszHashes.is_hash_allowed�chunksc
Cs�i}|j��D]}z	t�|�||<Wqttfy"td|����w|D]}|��D]}|�|�q+q%|�	�D]\}}|�
�|j|vrHdSq8|�|�dS)z�Check good hashes against ones built from iterable of chunks of
        data.

        Raise HashMismatch if none match.

        zUnknown hash name: N)rr�hashlibr%�
ValueError�	TypeErrorr
r&�updater�	hexdigest�_raise)rr3�gotsr/�chunk�hash�gotrrr�check_against_chunksFs ���zHashes.check_against_chunksr:rr
cCst|j|��r()rr�rr:rrrr9]sz
Hashes._raise�filecCs|�t|��S)zaCheck good hashes against a file-like object

        Raise HashMismatch if none match.

        )r>r)rr@rrr�check_against_file`szHashes.check_against_file�pathcCs8t|d��
}|�|�Wd�S1swYdS)N�rb)�openrA)rrBr@rrr�check_against_pathhs$�zHashes.check_against_pathcCs
t|j�S)z,Return whether I know any known-good hashes.)�boolrr-rrr�__bool__ls
zHashes.__bool__cCst|t�stS|j|jkSr()r#rr$r)rrrrr�__eq__ps
z
Hashes.__eq__cCs"td�tdd�|j��D����S)N�,css,�|]\}}|D]
}d�||f�VqqdS)�:N)�join)rr�digest_list�digestrrrr+xs����z"Hashes.__hash__.<locals>.<genexpr>)r<rKrrrr-rrr�__hash__us���zHashes.__hash__r()rrrr)�__name__�
__module__�__qualname__�__doc__rr�strrrr'�property�intr.rFr2r�bytesr>r9rrArErG�objectrHrNrrrrrs$
rcs<eZdZdZd�fdd�Zdeedfddfd	d
�Z�ZS)�
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.

    rNcst�jtgid�dS)z!Don't offer the ``hashes`` kwarg.)rN)�superr�
FAVORITE_HASHr-��	__class__rrr�szMissingHashes.__init__r:rr
cCst|t����r()r	rZr8r?rrrr9�szMissingHashes._raise)rN)	rOrPrQrRrrrSr9�
__classcell__rrr[rrX�s"rX)r4�typingrrrrrr�pip._internal.exceptionsrr	r
�pip._internal.utils.miscrrr
rZ�
STRONG_HASHESrrXrrrr�<module>s h