AlkantarClanX12

Your IP : 18.220.200.33


Current Path : /lib/python3.6/site-packages/pip/utils/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/pip/utils/__pycache__/hashes.cpython-36.pyc

3

�Pf2�@szddlmZddlZddlmZmZmZddlmZddl	m
Z
mZmZdZ
dddgZGd	d
�d
e�ZGdd�de�ZdS)
�)�absolute_importN)�HashMismatch�HashMissing�InstallationError)�read_chunks)�	iteritems�iterkeys�
itervaluesZsha256Zsha384Zsha512c@sJeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�HasheszaA wrapper that builds multiple hashes at once and checks them against
    known-good values

    NcCs|dkrin||_dS)zo
        :param hashes: A dict of algorithm names pointing to lists of allowed
            hex digests
        N)�_allowed)�self�hashes�r�/usr/lib/python3.6/hashes.py�__init__szHashes.__init__c
Cs�i}xJt|j�D]<}ytj|�||<Wqttfk
rJtd|��YqXqWx(|D] }xt|�D]}|j|�qdWqVWx*t	|�D]\}}|j
�|j|kr�dSq�W|j|�dS)z�Check good hashes against ones built from iterable of chunks of
        data.

        Raise HashMismatch if none match.

        zUnknown hash name: %sN)rr�hashlib�new�
ValueError�	TypeErrorrr	�updater�	hexdigest�_raise)rZchunks�gotsZ	hash_name�chunk�hashZgotrrr�check_against_chunks s
zHashes.check_against_chunkscCst|j|��dS)N)rr)rrrrrr7sz
Hashes._raisecCs|jt|��S)zaCheck good hashes against a file-like object

        Raise HashMismatch if none match.

        )rr)r�filerrr�check_against_file:szHashes.check_against_filec	Cs t|d��}|j|�SQRXdS)N�rb)�openr)r�pathrrrr�check_against_pathBszHashes.check_against_pathcCs
t|j�S)z,Return whether I know any known-good hashes.)�boolr)rrrr�__nonzero__FszHashes.__nonzero__cCs|j�S)N)r#)rrrr�__bool__JszHashes.__bool__)N)�__name__�
__module__�__qualname__�__doc__rrrrr!r#r$rrrrr
s
r
cs(eZdZdZ�fdd�Zdd�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.

    cstt|�jtgid�dS)z!Don't offer the ``hashes`` kwarg.)r
N)�superr)r�
FAVORITE_HASH)r)�	__class__rrrUszMissingHashes.__init__cCst|tj���dS)N)rr+r)rrrrrr[szMissingHashes._raise)r%r&r'r(rr�
__classcell__rr)r,rr)Nsr))Z
__future__rrZpip.exceptionsrrrZ	pip.utilsrZpip._vendor.sixrrr	r+Z
STRONG_HASHES�objectr
r)rrrr�<module>s
: