ó
^†êWc           @@  s©   d  d l  m Z d  d l Z d  d l m Z m Z m Z d  d l m Z d  d l	 m
 Z
 m Z m Z d Z d d d g Z d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d S(   i    (   t   absolute_importN(   t   HashMismatcht   HashMissingt   InstallationError(   t   read_chunks(   t	   iteritemst   iterkeyst
   itervaluest   sha256t   sha384t   sha512t   Hashesc           B@  sP   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   sa   A wrapper that builds multiple hashes at once and checks them against
    known-good values

    c         C@  s   | d k r i  n | |  _ d S(   so   
        :param hashes: A dict of algorithm names pointing to lists of allowed
            hex digests
        N(   t   Nonet   _allowed(   t   selft   hashes(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyt   __init__   s    c         C@  sá   i  } xX t  |  j ƒ D]G } y t j | ƒ | | <Wq t t f k
 r\ t d | ƒ ‚ q Xq Wx2 | D]* } x! t | ƒ D] } | j | ƒ q{ Wqh Wx7 t	 | ƒ D]) \ } } | j
 ƒ  |  j | k r£ d Sq£ W|  j | ƒ d S(   s‚   Check good hashes against ones built from iterable of chunks of
        data.

        Raise HashMismatch if none match.

        s   Unknown hash name: %sN(   R   R   t   hashlibt   newt
   ValueErrort	   TypeErrorR   R   t   updateR   t	   hexdigestt   _raise(   R   t   chunkst   gotst	   hash_namet   chunkt   hasht   got(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyt   check_against_chunks    s    c         C@  s   t  |  j | ƒ ‚ d  S(   N(   R   R   (   R   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyR   7   s    c         C@  s   |  j  t | ƒ ƒ S(   sa   Check good hashes against a file-like object

        Raise HashMismatch if none match.

        (   R   R   (   R   t   file(    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyt   check_against_file:   s    c         C@  s)   t  | d ƒ  } |  j | ƒ SWd  QXd  S(   Nt   rb(   t   openR    (   R   t   pathR   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyt   check_against_pathB   s    c         C@  s   t  |  j ƒ S(   s,   Return whether I know any known-good hashes.(   t   boolR   (   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyt   __nonzero__F   s    c         C@  s
   |  j  ƒ  S(   N(   R&   (   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyt   __bool__J   s    N(   t   __name__t
   __module__t   __doc__R   R   R   R   R    R$   R&   R'   (    (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyR      s   					t   MissingHashesc           B@  s    e  Z d  Z d „  Z d „  Z RS(   sÀ   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.

    c         C@  s$   t  t |  ƒ j d i g  t 6ƒ d S(   s!   Don't offer the ``hashes`` kwarg.R   N(   t   superR+   R   t   FAVORITE_HASH(   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyR   U   s    c         C@  s   t  | t j ƒ  ƒ ‚ d  S(   N(   R   R-   R   (   R   R   (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyR   [   s    (   R(   R)   R*   R   R   (    (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyR+   N   s   	(   t
   __future__R    R   t   pip.exceptionsR   R   R   t	   pip.utilsR   t   pip._vendor.sixR   R   R   R-   t   STRONG_HASHESt   objectR   R+   (    (    (    sa   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/utils/hashes.pyt   <module>   s   :