Viewing File: /opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/__pycache__/hashes.cpython-35.pyc



t_F@s ddlmZddlZddlmZmZmZddlmZm	Z	m
Z
ddlmZddl
mZerddlmZmZmZmZmZddlmZerdd	lmZndd
lmZdZddd
gZGdddeZGdddeZdS))absolute_importN)	iteritemsiterkeys
itervalues)HashMismatchHashMissingInstallationError)read_chunks)MYPY_CHECK_RUNNING)DictListBinaryIONoReturnIterator)PY3)_Hash)_hashsha256sha384sha512c@seZdZdZdddZddZeddZd	d
ZddZ	d
dZ
ddZddZddZ
ddZdS)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)selfhashesr/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-1.el7.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/utils/hashes.py__init__)szHashes.__init__cst|tstS|sSs'|Si}xOt|jD]>\}jkr[q=fdd|D|<q=Wt|S)Ncs)g|]}|jkr|qSr)r).0v)algrrr
<listcomp>Bs	z"Hashes.__and__.<locals>.<listcomp>)
isinstancerNotImplementedrr)rothernewvaluesr)rrr__and__1s$zHashes.__and__cCs tdd|jjDS)Ncss|]}t|VqdS)N)len)rdigestsrrr	<genexpr>Hsz&Hashes.digest_count.<locals>.<genexpr>)sumrr%)rrrrdigest_countEszHashes.digest_countcCs||jj|gkS)z/Return whether the given hex digest is allowed.)rget)r	hash_name
hex_digestrrris_hash_allowedJszHashes.is_hash_allowedc
Csi}x^t|jD]M}ytj|||<Wqttfk
rbtdj|YqXqWx2|D]*}x!t|D]}|j	|qWqnWx7t
|D])\}}|j|j|krdSqW|j|dS)zCheck good hashes against ones built from iterable of chunks of
        data.

        Raise HashMismatch if none match.

        zUnknown hash name: {}N)
rrhashlibr$
ValueError	TypeErrorrformatrupdater	hexdigest_raise)rchunksgotsr-chunkhashgotrrrcheck_against_chunksSs
zHashes.check_against_chunkscCst|j|dS)N)rr)rr8rrrr6msz
Hashes._raisecCs|jt|S)zaCheck good hashes against a file-like object

        Raise HashMismatch if none match.

        )r<r	)rfilerrrcheck_against_fileqszHashes.check_against_filec	Cs*t|d}|j|SWdQRXdS)Nrb)openr>)rpathr=rrrcheck_against_pathzszHashes.check_against_pathcCs
t|jS)z,Return whether I know any known-good hashes.)boolr)rrrr__nonzero__szHashes.__nonzero__cCs
|jS)N)rD)rrrr__bool__szHashes.__bool__)__name__
__module____qualname____doc__rr&propertyr+r/r<r6r>rBrDrErrrrr$s		rcs4eZdZdZfddZddZS)
MissingHasheszA 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.

    cs#tt|jdtgidS)z!Don't offer the ``hashes`` kwarg.rN)superrKr
FAVORITE_HASH)r)	__class__rrrszMissingHashes.__init__cCst|tjdS)N)rrMr5)rr8rrrr6szMissingHashes._raise)rFrGrHrIrr6rr)rNrrKsrK)
__future__rr0Zpip._vendor.sixrrrpip._internal.exceptionsrrrpip._internal.utils.miscr	pip._internal.utils.typingr
typingrrr
rrrrrrM
STRONG_HASHESobjectrrKrrrr<module>s(e
Back to Directory File Manager