
9Vc           @@  s9  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z y d  d l Z e Z Wn e k
 r e Z n Xd  d l m Z d  d l m Z d  d l Z d  d l m Z m Z d  d l m Z d  d l  m! Z! m" Z" m# Z# m$ Z$ m% Z% m& Z& m' Z' m( Z( m) Z) d  d l* m+ Z+ d  d	 l, m- Z- d  d
 l. m/ Z/ m0 Z0 d  d l1 m2 Z2 d  d l3 m4 Z4 d  d l5 m6 Z6 m7 Z7 d  d l8 m9 Z9 m: Z: d  d l; m< Z< m= Z= d  d l> m? Z? d  d l@ mA ZA d  d lB mC ZC d  d lD mE ZE d  d lF mG ZG d  d lH mI ZI d  d lJ mK ZK d d d d d d d d d d  d! g ZL e jM eN  ZO d"   ZP d# e< f d$     YZQ d% e9 f d&     YZR d' eG f d(     YZS d) e: f d*     YZT d+ e6 jU f d,     YZV d d d-  ZX e jY d. e jZ  Z[ e jY d/ e jZ  Z\ d0   Z] d1   Z^ d2   Z_ d3   Z` d4   Za d5   Zb d6   Zc d7   Zd d8   Ze d9   Zf d:   Zg d;   Zh d<   Zi d d d=  Zj d d>  Zk d?   Zl d@ eK jm f dA     YZn d e d dB  Zo dC   Zp dD   Zq d S(E   i    (   t   absolute_importN(   t   parse(   t   request(   t   InstallationErrort   HashMismatch(   t   PyPI(	   t   splitextt   rmtreet   format_sizet   display_patht
   backup_dirt   ask_path_existst   unpack_filet   call_subprocesst   ARCHIVE_EXTENSIONS(   t   check_path_owner(   t
   indent_log(   t   DownloadProgressBart   DownloadProgressSpinner(   t   write_delete_marker_file(   t   vcs(   t   requestst   six(   t   BaseAdaptert   HTTPAdapter(   t   AuthBaset   HTTPBasicAuth(   t   Response(   t   CaseInsensitiveDict(   t   urllib3(   t   CacheControlAdapter(   t	   FileCache(   t	   LockError(   t   xmlrpc_clientt   get_file_contentt   is_urlt   url_to_patht   path_to_urlt   is_archive_filet   unpack_vcs_linkt   unpack_file_urlt
   is_vcs_urlt   is_file_urlt   unpack_http_urlt
   unpack_urlc          C@  s  i i d d 6t  j d 6d 6t j   d 6i t j   d 6d 6}  |  d d d k rj t j   |  d d <n |  d d d k r t j j d	 k r t j d
  } n	 t j } d j g  | D] } t	 |  ^ q  |  d d <nV |  d d d k rt j   |  d d <n+ |  d d d k r2t j   |  d d <n  t j j
 d  rt t d   t d d d g t j      } t t d   t d d g t j      } | r| | d <n  | r| |  d <qn  t j j
 d  rt j   d ri d d 6t j   d d 6|  d <n  t j   r<t j   |  j d i   d <n  t j   rgt j   |  j d i   d <n  t j   rt j   |  d <n  d j d |  d t j |  d d" d! t  S(#   s6   
    Return a string representing the user agent.
    t   pipt   namet   versiont	   installert   pythont   implementationt   CPythont   PyPyt   finali   t   .t   Jythont
   IronPythont   linuxc         S@  s   |  d S(   Ni   (    (   t   x(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   <lambda>[   s    t   idc         S@  s   |  d S(   Ni   (    (   R:   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR;   _   s    t   libt   libct   distrot   darwini    s   OS Xt   systemt   releaset   cpus9   {data[installer][name]}/{data[installer][version]} {json}t   datat   jsont
   separatorst   ,t   :t	   sort_keys(   RG   RH   (   R-   t   __version__t   platformt   python_versiont   python_implementationt   syst   pypy_version_infot   releaselevelt   joint   strt
   startswitht   dictt   filtert   zipt   linux_distributiont   libc_vert   mac_verRA   t
   setdefaultRB   t   machinet   formatRE   t   dumpst   True(   RD   RO   R:   R?   R>   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt
   user_agent<   sN    	-$!"%	t   MultiDomainBasicAuthc           B@  s/   e  Z e d   Z d   Z d   Z d   Z RS(   c         C@  s   | |  _  i  |  _ d  S(   N(   t	   promptingt	   passwords(   t   selfRa   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   __init__{   s    	c         C@  s   t  j | j  } | j j d d  d } t  j | d  | f | d  | _ |  j j | d  \ } } | d  k r |  j	 | j  \ } } n  | s | r | | f |  j | <t
 | p d | p d  |  } n  | j d |  j  | S(   Nt   @i   ii   t    t   response(   NN(   t   urllib_parset   urlparset   urlt   netloct   rsplitt
   urlunparseRb   t   gett   Nonet   parse_credentialsR   t   register_hookt
   handle_401(   Rc   t   reqt   parsedRk   t   usernamet   password(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   __call__   s    %$c         K@  s   | j  d k r | S|  j s  | St j | j  } t j j d | j  } t	 j	 d  } | sf | r | | f |  j
 | j <n  | j | j j   t | p d | p d  | j  } | j j | |  } | j j |  | S(   Ni  s   User for %s: s
   Password: Rf   (   t   status_codeRa   Rh   Ri   Rj   R   t   movest   inputRk   t   getpassRb   t   contentt   rawt   release_connR   R   t
   connectiont   sendt   historyt   append(   Rc   t   respt   kwargsRt   Ru   Rv   Rs   t   new_resp(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyRr      s    	$c         C@  sL   d | k rH | j  d d  d } d | k r> | j d d  S| d  f Sd S(   NRe   i   i    RH   (   NN(   Rl   t   splitRo   (   Rc   Rk   t   userinfo(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyRp      s    
(   t   __name__t
   __module__R^   Rd   Rw   Rr   Rp   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR`   y   s   		"t   LocalFSAdapterc           B@  s)   e  Z d d d d d d   Z d   Z RS(   c         C@  s   t  | j  } t   } d | _ | j | _ y t j |  }	 Wn% t k
 rg }
 d | _ |
 | _ n} Xt j	 j
 |	 j d t } t j |  d p d } t i | d 6|	 j d 6| d 6 | _ t | d	  | _ | j j | _ | S(
   Ni   i  t   usegmti    s
   text/plains   Content-Types   Content-Lengths   Last-Modifiedt   rb(   R$   Rj   R   Rx   t   ost   statt   OSErrorR}   t   emailt   utilst
   formatdatet   st_mtimeR^   t	   mimetypest
   guess_typeR   t   st_sizet   headerst   opent   close(   Rc   R   t   streamt   timeoutt   verifyt   certt   proxiest   pathnameR   t   statst   exct   modifiedt   content_type(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR      s$    			
c         C@  s   d  S(   N(    (   Rc   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR      s    N(   R   R   Ro   R   R   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR      s   t   SafeFileCachec           B@  s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   sw   
    A file based cache which is safe to use even when the target directory may
    not be accessible or writable.
    c         O@  sK   t  t |   j | |   t |  j  sG t j d |  j  d  |  _ n  d  S(   Ns   The directory '%s' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.(   t   superR   Rd   R   t	   directoryt   loggert   warningRo   (   Rc   t   argsR   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyRd      s    
c         O@  sQ   |  j  d  k r d  Sy t t |   j | |   SWn t t t f k
 rL n Xd  S(   N(   R   Ro   R   R   Rn   R    R   t   IOError(   Rc   R   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyRn     s    c         O@  sQ   |  j  d  k r d  Sy t t |   j | |   SWn t t t f k
 rL n Xd  S(   N(   R   Ro   R   R   t   setR    R   R   (   Rc   R   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR     s    c         O@  sQ   |  j  d  k r d  Sy t t |   j | |   SWn t t t f k
 rL n Xd  S(   N(   R   Ro   R   R   t   deleteR    R   R   (   Rc   R   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR     s    (   R   R   t   __doc__Rd   Rn   R   R   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR      s
   			t   InsecureHTTPAdapterc           B@  s   e  Z d    Z RS(   c         C@  s   d | _  d  | _ d  S(   Nt	   CERT_NONE(   t	   cert_reqsRo   t   ca_certs(   Rc   t   connRj   R   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   cert_verify+  s    	(   R   R   R   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR   )  s   t
   PipSessionc           B@  s    e  Z d Z d    Z d   Z RS(   c   	      O@  s5  | j  d d  } | j  d d   } | j  d g   } t t |   j | |   t   |  j d <t   |  _ t	 j
 d | d d g d	 d
  } | r t d t | d t d |  } n t d |  } t d |  } |  j d |  |  j d |  |  j d t    x' | D] } |  j d j |  |  qWd  S(   Nt   retriesi    t   cachet   insecure_hostss
   User-Agentt   totalt   status_forcelisti  t   backoff_factorg      ?t   use_dir_lockt   max_retriess   https://s   http://s   file://s   https://{0}/(   t   popRo   R   R   Rd   R_   R   R`   t   authR   t   RetryR   R   R^   R   R   t   mountR   R\   (	   Rc   R   R   R   R   R   t   secure_adaptert   insecure_adaptert   host(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyRd   4  s*    			c         O@  s2   | j  d |  j  t t |   j | | | |  S(   NR   (   RZ   R   R   R   R   (   Rc   t   methodRj   R   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR   p  s    N(   R   R   Ro   R   Rd   R   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR   0  s   	<c   
      C@  s  | d
 k r t d   n  t j |   } | rt| j d  j   } | d k r | r | j d  r t d | |  f   n  | d k r/|  j d d  d } | j	 d d  } t
 j |  } | r | j d  d | j d	 d  d } n  t j |  } | j d  r&d | j d  } n  | }  qt| j |   } | j   t j ra| j | j f S| j | j f Sn  y% t |    } | j   } Wd
 QXWn) t k
 r}	 t d t |	    n X|  | f S(   s   Gets the content of a file; it may be a filename, file: URL, or
    http: URL.  Returns (location, content).  Content is unicode.sA   get_file_content() missing 1 required keyword argument: 'session'i   t   filet   https6   Requirements file %s references URL %s, which is localRH   s   \t   /t   |Ns$   Could not open requirements file: %s(   Ro   t	   TypeErrort
   _scheme_ret   searcht   groupt   lowerRS   R   R   t   replacet   _url_slash_drive_ret   matchRh   t   unquotet   lstripRn   t   raise_for_statusR   t   PY3Rj   t   textR|   R   t   readR   RR   (
   Rj   t
   comes_fromt   sessionR   t   schemet   pathR   t   fR|   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR"   x  sB    *	
	s   ^(http|https|file):s   /*([a-z])\|c         C@  sI   d |  k r t  S|  j d d  d j   } | d d d d g t j k S(   s)   Returns true if the name looks like a URLRH   i   i    R   t   httpsR   t   ftp(   t   FalseR   R   R   t   all_schemes(   R.   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR#     s    c         C@  sg   |  j  d  s t d |    t j |   \ } } } } } | rP d | } n  t j | |  } | S(   s(   
    Convert a file: URL to a path.
    s   file:s4   You can only turn file: urls into filenames (not %r)s   \\(   RS   t   AssertionErrorRh   t   urlsplitt   urllib_requestt   url2pathname(   Rj   t   _Rk   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR$     s    c         C@  s=   t  j j t  j j |    }  t j d t j |    } | S(   sh   
    Convert a path to a file: URL.  The path will be made absolute and have
    quoted path parts.
    s   file:(   R   R   t   normpatht   abspathRh   t   urljoinR   t   pathname2url(   R   Rj   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR%     s    c         C@  s*   t  |   d j   } | t k r& t St S(   s9   Return True if `name` is a considered as an archive file.i   (   R   R   R   R^   R   (   R.   t   ext(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR&     s    c         C@  s   t  |   } | j |  d  S(   N(   t   _get_used_vcs_backendt   unpack(   t   linkt   locationt   vcs_backend(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR'     s    c         C@  s=   x6 t  j D]+ } |  j | j k r
 | |  j  } | Sq
 Wd  S(   N(   R   t   backendsR   t   schemesRj   (   R   t   backendR   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR     s    c         C@  s   t  t |    S(   N(   t   boolR   (   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR)     s    c         C@  s   |  j  j   j d  S(   Ns   file:(   Rj   R   RS   (   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR*     s    c         C@  s   |  j  t j | j  j  k rM t j d |  j  | | j  t d |   n  |  j   | j k r t j d | |  j   | j  t d | j | f   n  d  S(   NsP   Hash digest size of the package %d (%s) doesn't match the expected hash name %s!s!   Hash name mismatch for package %ss?   Hash of the package %s (%s) doesn't match the expected hash %s!s   Bad %s hash for package %s(	   t   digest_sizet   hashlibt   newt	   hash_nameR   t   criticalR   t	   hexdigestt   hash(   t   download_hashR   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   _check_hash  s    c         C@  s   y t  j | j  } Wn. t t f k
 rF t j d | j |  d  SXt |  d  : } x0 t	 r | j
 d  } | s{ Pn  | j |  q\ WWd  QX| S(   Ns'   Unsupported hash name %s for package %sR   i   (   R   R   R   t
   ValueErrorR   R   R   Ro   R   R^   R   t   update(   t   target_fileR   R   t   fpt   chunk(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   _get_hash_from_file  s    	c         O@  s   |  S(   N(    (   t   iterableR   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   _progress_indicator  s    c         @  sA  d  } | j r[ | j r[ y t j | j  } Wq[ t k
 rW t j d | j |  q[ Xn  y t   j	 d  } Wn  t t
 t f k
 r d } n Xt   d t  } t j   t j k r t } n9 | r t } n* | d k r t } n | s t } n t } | j }   f d   } t }	 | j t j k r7| }
 n	 | j }
 | r| rzt j d |
 t |   t d	 |  j }	 qt j d
 |
  t   j }	 n) | rt j d |
  n t j d
 |
  t j d |  xF |	 | d  d  D]/ } | d  k	 r
| j |  n  | j |  qW| j r=| j r=t | |  n  | S(   Ns'   Unsupported hash name %s for package %ss   content-lengthi    t
   from_cachei(   i  c         3@  sr   y, x%   j  j |  d t D] } | Vq WWn? t k
 rm x/ t ri   j  j |   } | sa Pn  | Vq? Wn Xd  S(   Nt   decode_content(   R}   R   R   t   AttributeErrorR^   R   (   t
   chunk_sizeR   (   R   (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt	   resp_read/  s    	s   Downloading %s (%s)t   maxs   Downloading %ss   Using cached %ss   Downloading from URL %si   i@  (    Ro   R   R   R   R   R   R   R   t   intR   t   KeyErrorR   t   getattrR   t   getEffectiveLevelt   loggingt   INFOR^   t   show_urlR  Rk   R   t   url_without_fragmentt   infoR   R   t   iterR   t   debugR   t   writeR   (   R   R   t   content_fileR   t   total_lengtht   cached_respt   show_progressR  R  t   progress_indicatorRj   R   (    (   R   s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   _download_url  s^    
					%		c         C@  s  t  } t j j | | j  } t j j |  r t d t |  d  } | d k r^ t } q | d k r t	 j
 d t |   t j |  q | d k r t |  } t	 j
 d t |  t |   t j | |  q n  | rt j |  |  t	 j d t |   n  d  S(	   Ns/   The file %s exists. (i)gnore, (w)ipe, (b)ackup t   it   wt   bs   Deleting %ss   Backing up %s to %ss   Saved %s(   R  R  R  (   R^   R   R   RQ   t   filenamet   existsR   R	   R   R   R   t   removeR
   t   shutilt   movet   copyR  (   R  R   R   R   R$  t   download_locationRg   t	   dest_file(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt
   _copy_filev  s*    		c         C@  s   | d  k r t d   n  t j d d  } d  } | rK t |  |  } n  | rm | } t j |  d } n t |  | |  \ } } t | | | |   | r | r t	 | | | |   n  | s t
 j |  n  t |  d  S(   Ns@   unpack_http_url() missing 1 required keyword argument: 'session's   -unpacks   pip-i    (   Ro   R   t   tempfilet   mkdtempt   _check_download_dirR   R   t   _download_http_urlR   R'  R   t   unlinkR   (   R   R   t   download_dirR   t   temp_dirt   already_downloaded_patht	   from_pathR   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR+     s"    c         C@  s  t  |  j  } t j j |  rp t j j |  r@ t |  n  t j | | d t | rl t	 j
 d  n  d S|  j r t | |   } t | |   n  d } | r t |  |  } n  | r | } n | } t j |  d } t | | | |   | r| rt | | | |   n  d S(   s   Unpack link into location.
    If download_dir is provided and link points to a file, make a copy
    of the link file inside download_dir.t   symlinkss*   Link is a directory, ignoring download_dirNi    (   R$   R  R   R   t   isdirR   R"  t   copytreeR^   R   R  R   R  R   Ro   R*  R   R   R   R'  (   R   R   R-  t	   link_patht   link_path_hashR/  R0  R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR(     s*    		c      
   C@  s   t  j j |  r t |  n  d } t j g } | j d  | j d |  | j d  | d | g 7} t j d |   t	    t
 | d |  d t Wd	 QXt  j j | t  j |  d
  } t j d | |  t | | d d	 d d	 d	 S(   s   Copy distribution files in `link_path` to `location`.

    Invoked when user requests to install a local directory. E.g.:

        pip install .
        pip install ~/dev/git-repos/python-prompt-toolkit

    s   setup.pys   -cs   import setuptools, tokenize;__file__=%r;exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))t   sdists
   --dist-dirs   Running setup.py sdist for %st   cwdt   show_stdoutNi    s   Unpacking sdist %s into %sR   R   (   R   R   R2  R   RN   t
   executableR   R   R  R   R   R   RQ   t   listdirR   Ro   (   R4  R   t   setup_pyt
   sdist_argsR6  (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   _copy_dist_from_dir  s     
"t   PipXmlrpcTransportc           B@  s&   e  Z d  Z e d  Z e d  Z RS(   sR   Provide a `xmlrpclib.Transport` implementation via a `PipSession`
    object.
    c         C@  s;   t  j j |  |  t j |  } | j |  _ | |  _ d  S(   N(   R!   t	   TransportRd   Rh   Ri   R   t   _schemet   _session(   Rc   t	   index_urlR   t   use_datetimet   index_parts(    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyRd     s    c   
      C@  s   |  j  | | d  d  d  f } t j |  } yX i d d 6} |  j j | d | d | d t } | j   | |  _ |  j	 | j
  SWn2 t j k
 r }	 t j d |	 j j |    n Xd  S(   Ns   text/xmls   Content-TypeRD   R   R   s   HTTP error %s while getting %s(   R@  Ro   Rh   Rm   RA  t   postR^   R   t   verboset   parse_responseR}   R   t	   HTTPErrorR   R   Rg   Rx   (
   Rc   R   t   handlert   request_bodyRF  t   partsRj   R   Rg   R   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR     s    
	(   R   R   R   R   Rd   R   (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR>    s   c         C@  s}   t  |   r t |  |  nJ t |   r; t |  | |  n+ | d k rS t   } n  t |  | | |  | ry t |  n  d S(   sO  Unpack link.
       If link is a VCS link:
         if only_download, export into download_dir and ignore location
          else unpack into location
       for other types of link:
         - unpack into location
         - if download_dir, copy the file into download_dir
         - if only_download, mark location for deletion
    N(   R)   R'   R*   R(   Ro   R   R+   R   (   R   R   R-  t   only_downloadR   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR,     s    c      
   C@  s  |  j  j d d  d } y0 | j | d i d d 6d t } | j   Wn2 t j k
 r} } t j d | j	 j
 |     n X| j j d	 d
  } |  j } | j j d  } | r t j |  \ }	 }
 |
 j d  p | } n  t |  d } | st j |  } | r| | 7} qn  | rd|  j  | j  k rdt j j | j   d } | rd| | 7} qdn  t j j | |  } t | d   } t | |  |  Wd QX| | f S(   s6   Download link url into temp_dir using provided sessiont   #i   i    R   t   identitys   Accept-EncodingR   s   HTTP error %s while getting %ss   content-typeRf   s   content-dispositionR  t   wbN(   Rj   R   Rn   R^   R   R   RH  R   R   Rg   Rx   R   R  t   cgit   parse_headerR   R   t   guess_extensionR   R   RQ   R   R  (   R   R   R.  t
   target_urlR   R   R   R  t   content_dispositiont   typet   paramsR   t	   file_pathR  (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR+  ?  s<    		c         C@  s   t  j j | |  j  } t  j j |  r t j d |  |  j r t | |   } y t	 | |   Wq t
 k
 r t j d |  t  j |  d SXn  | Sd S(   s    Check download_dir for previously downloaded file with correct hash
        If a correct file is found return its path else None
    s   File was already downloaded %ss;   Previously-downloaded file %s has bad hash, re-downloading.N(   R   R   RQ   R  R   R   R  R   R  R   R   R   R,  Ro   (   R   R-  t   download_pathR   (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyR*  z  s    	(r   t
   __future__R    RP  t   email.utilsR   R   R{   RE   R  R   R   RK   t   reR"  RN   R(  t   sslR^   t   HAS_TLSt   ImportErrorR   t   pip._vendor.six.moves.urllibR   Rh   R   R   R-   t   pip.exceptionsR   R   t
   pip.modelsR   t	   pip.utilsR   R   R   R	   R
   R   R   R   R   t   pip.utils.filesystemR   t   pip.utils.loggingR   t   pip.utils.uiR   R   t   pip.locationsR   t   pip.vcsR   t   pip._vendorR   R   t   pip._vendor.requests.adaptersR   R   t   pip._vendor.requests.authR   R   t   pip._vendor.requests.modelsR   t   pip._vendor.requests.structuresR   t   pip._vendor.requests.packagesR   t   pip._vendor.cachecontrolR   t   pip._vendor.cachecontrol.cachesR   t   pip._vendor.lockfileR    t   pip._vendor.six.movesR!   t   __all__t	   getLoggerR   R   R_   R`   R   R   R   t   SessionR   Ro   R"   t   compilet   IR   R   R#   R$   R%   R&   R'   R   R)   R*   R   R  R  R  R'  R+   R(   R=  R?  R>  R,   R+  R*  (    (    (    s)   /tmp/pip-build-5Z5nTX/pip/pip/download.pyt   <module>   s   

@			=M!BH-			
									f	!*	'!	;