Sindbad~EG File Manager
3
�Pf2�@szddlmZddlZddlmZmZmZddlmZddl m
Z
mZmZdZ
dddgZGd d
�d
e�ZGdd�de�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|dkrin||_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)rZchunks�gotsZ hash_name�chunk�hashZgotrrr�check_against_chunks s
zHashes.check_against_chunkscCst|j|��dS)N)rr)rrrrrr7sz
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_pathBszHashes.check_against_pathcCs
t|j�S)z,Return whether I know any known-good hashes.)�boolr)rrrr�__nonzero__FszHashes.__nonzero__cCs|j�S)N)r#)rrrr�__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)rrrrrr[szMissingHashes._raise)r%r&r'r(rr�
__classcell__rr)r,rr)Nsr))Z
__future__rrZpip.exceptionsrrrZ pip.utilsrZpip._vendor.sixrrr r+Z
STRONG_HASHES�objectr
r)rrrr�<module>s
:
Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists