
^Wc           @@  sY  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 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( m) Z) d  d l* m+ Z+ d  d	 l, m- Z- d  d
 l. m/ Z/ d  d l0 m1 Z1 d  d l2 m3 Z3 m4 Z4 d  d l5 m6 Z6 d  d l7 m8 Z8 d  d l9 m: Z: m; Z; d  d l< m= Z= m> Z> d  d l? m@ Z@ mA ZA d  d lB mC ZC mD ZD d  d lE mF ZF d  d lG mH ZH d  d lI mJ ZJ d  d lK mL ZL d  d lM mN ZN d  d lO mP ZP d d d d d d d d  d! d" d# g ZQ e jR eS  ZT d$   ZU d% e@ f d&     YZV d' e= f d(     YZW d) eL f d*     YZX d+ e> f d,     YZY d- e: jZ f d.     YZ[ d d d/  Z] e j^ d0 e j_  Z` e j^ d1 e j_  Za d2   Zb d3   Zc d4   Zd d5   Ze d6   Zf d7   Zg d8   Zh d9   Zi d:   Zj d;   Zk d<   Zl d=   Zm d d d d>  Zn d d d?  Zo d@   Zp dA eP jq f dB     YZr d e d d dC  Zs dD   Zt dE   Zu d S(F   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   ARCHIVE_EXTENSIONSt   consumet   call_subprocess(   t   auto_decode(   t   check_path_owner(   t
   indent_log(   t   SETUPTOOLS_SHIM(   t   DownloadProgressBart   DownloadProgressSpinner(   t   write_delete_marker_file(   t   vcs(   t   requestst   six(   t   BaseAdaptert   HTTPAdapter(   t   AuthBaset   HTTPBasicAuth(   t   CONTENT_CHUNK_SIZEt   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  t rt j d  d% k 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]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt   <lambda>\   s    t   idc         S@  s   |  d S(   Ni   (    (   R>   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR?   `   s    t   libt   libct   distrot   darwini    s   OS Xt   systemt   releaset   cpui   i   t   openssl_versions9   {data[installer][name]}/{data[installer][version]} {json}t   datat   jsont
   separatorst   ,t   :t	   sort_keys(   i   i   (   RL   RM   (   R1   t   __version__t   platformt   python_versiont   python_implementationt   syst   pypy_version_infot   releaselevelt   joint   strt
   startswitht   dictt   filtert   zipt   linux_distributiont   libc_vert   mac_verRE   t
   setdefaultRF   t   machinet   HAS_TLSt   version_infot   sslt   OPENSSL_VERSIONt   formatRJ   t   dumpst   True(   RI   RT   R>   RC   RB   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt
   user_agent=   sR    	-$!"%	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   selfRj   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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
   urlunparseRk   t   gett   Nonet   parse_credentialsR   t   register_hookt
   handle_401(   Rl   t   reqt   parsedRt   t   usernamet   password(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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: Ro   (   t   status_codeRj   Rq   Rr   Rs   R   t   movest   inputRt   t   getpassRk   t   contentt   rawt   release_connR   R   t
   connectiont   sendt   historyt   append(   Rl   t   respt   kwargsR}   R~   R   R|   t   new_resp(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR{      s    	$c         C@  sL   d | k rH | j  d d  d } d | k r> | j d d  S| d  f Sd S(   NRn   i   i    RM   (   NN(   Ru   t   splitRx   (   Rl   Rt   t   userinfo(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyRy      s    
(   t   __name__t
   __module__Rg   Rm   R   R{   Ry   (    (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyRi   ~   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(   Rs   R   R   t   ost   statt   OSErrorR   t   emailt   utilst
   formatdatet   st_mtimeRg   t	   mimetypest
   guess_typeR    t   st_sizet   headerst   opent   close(   Rl   R   t   streamt   timeoutt   verifyt   certt   proxiest   pathnameR   t   statst   exct   modifiedt   content_type(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR      s$    			
c         C@  s   d  S(   N(    (   Rl   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR      s    N(   R   R   Rx   R   R   (    (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   Rm   R   t	   directoryt   loggert   warningRx   (   Rl   t   argsR   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyRm      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   Rx   R   R   Rw   R$   R   t   IOError(   Rl   R   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyRw     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   Rx   R   R   t   setR$   R   R   (   Rl   R   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   Rx   R   R   t   deleteR$   R   R   (   Rl   R   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR      s    (   R   R   t   __doc__Rm   Rw   R   R   (    (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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_reqsRx   t   ca_certs(   Rl   t   connRs   R   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt   cert_verify0  s    	(   R   R   R   (    (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   popRx   R   R   Rm   Rh   R   Ri   t   authR!   t   RetryR"   R   Rg   R   R   t   mountR   Re   (	   Rl   R   R   R   R   R   t   secure_adaptert   insecure_adaptert   host(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyRm   9  s*    			c         O@  s2   | j  d |  j  t t |   j | | | |  S(   NR   (   R_   R   R   R   R   (   Rl   t   methodRs   R   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR   u  s    N(   R   R   Rx   R   Rm   R   (    (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR   5  s   	<c   
      C@  s  | d k r t d   n  t j |   } | r[| 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  | }  q[| j |   } | j   | j | j f Sn  y. t |  d
   } 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 localRM   s   \t   /t   |R   Ns$   Could not open requirements file: %s(   Rx   t	   TypeErrort
   _scheme_ret   searcht   groupt   lowerRX   R   R   t   replacet   _url_slash_drive_ret   matchRq   t   unquotet   lstripRw   t   raise_for_statusRs   t   textR   R   t   readR   RW   (
   Rs   t
   comes_fromt   sessionR   t   schemet   pathR   t   fR   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR&   }  s>    *	
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 URLRM   i   i    R   t   httpsR   t   ftp(   t   FalseR   R   R   t   all_schemes(   R2   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   \\(   RX   t   AssertionErrorRq   t   urlsplitt   urllib_requestt   url2pathname(   Rs   t   _Rt   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   abspathRq   t   urljoinR   t   pathname2url(   R   Rs   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   Rg   R   (   R2   t   ext(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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   schemesRs   (   R   t   backendR   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR     s    c         C@  s   t  t |    S(   N(   t   boolR   (   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR-     s    c         C@  s   |  j  j   j d  S(   Ns   file:(   Rs   R   RX   (   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR.     s    c         C@  s   t  |  j  } t j j |  S(   s   Return whether a file:// Link points to a directory.

    ``link`` must not have any other scheme but file://. Call is_file_url()
    first.

    (   R(   t   url_without_fragmentR   R   t   isdir(   R   t	   link_path(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt
   is_dir_url  s    c         O@  s   |  S(   N(    (   t   iterableR   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt   _progress_indicator  s    c         @  s  y t   j d  } Wn  t t t f k
 r9 d } n Xt  d t  } t j   t	 j
 k rj t } n9 | ry t } n* | d k r t } n | s t } n t } | j }  f d   }   f d   }	 t }
 | j t j k r | } n	 | j } | rM| r.t j d | t |   t d	 |  j }
 qvt j d
 |  t   j }
 n) | rft j d |  n t j d
 |  t j d |  |	 |
 | t  t   } | r| j |  n
 t |  d  S(   Ns   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   AttributeErrorRg   R   (   t
   chunk_sizet   chunk(   R   (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt	   resp_read  s    	c         3@  s'   x  |  D] }   j  |  | Vq Wd  S(   N(   t   write(   t   chunksR  (   t   content_file(    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt   written_chunks2  s    s   Downloading %s (%s)t   maxs   Downloading %ss   Using cached %ss   Downloading from URL %si@  (   t   intR   t
   ValueErrort   KeyErrorR   t   getattrR   R   t   getEffectiveLevelt   loggingt   INFORg   t   show_urlR   Rt   R   R   t   infoR   R   t   iterR   t   debugR   t   check_against_chunksR   (   R   R   R	  t   hashest   total_lengtht   cached_respt   show_progressR  R  R
  t   progress_indicatorRs   t   downloaded_chunks(    (   R	  R   s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt   _download_url  sL    
					%			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!  (   Rg   R   R   RV   t   filenamet   existsR   R	   R   R   R   t   removeR
   t   shutilt   movet   copyR  (   R"  R   R   R'  t   download_locationRp   t	   dest_file(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt
   _copy_fileX  s*    		c   	      C@  s   | d  k r t d   n  t j d d  } d  } | rN t |  | |  } n  | rp | } 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    (   Rx   R   t   tempfilet   mkdtempt   _check_download_dirR   R   t   _download_http_urlR   R*  R   t   unlinkR   (	   R   R   t   download_dirR   R  t   temp_dirt   already_downloaded_patht	   from_pathR   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR/   q  s,    c         C@  s   t  |  j  } t |   rj t j j |  r: t |  n  t j | | d t	 | rf t
 j d  n  d S| r | j |  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   R   R   R   R%  t   copytreeRg   R   R  t   check_against_pathRx   R-  R   R   R   R*  (   R   R   R0  R  R   R2  R3  R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR,     s,    	c      
   C@  s   t  j j |  r t |  n  d } t j g } | j d  | j t |  | 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   -ct   sdists
   --dist-dirs   Running setup.py sdist for %st   cwdt   show_stdoutNi    s   Unpacking sdist %s into %sR   R   (   R   R   R   R   RS   t
   executableR   R   R   R  R   R   R   RV   t   listdirR   Rx   (   R   R   t   setup_pyt
   sdist_argsR7  (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/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	   TransportRm   Rq   Rr   R   t   _schemet   _session(   Rl   t	   index_urlR   t   use_datetimet   index_parts(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyRm     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-TypeRI   R   R   s   HTTP error %s while getting %s(   RA  Rx   Rq   Rv   RB  t   postRg   R   t   verboset   parse_responseR   R   t	   HTTPErrorR   t   criticalRp   R   (
   Rl   R   t   handlert   request_bodyRG  t   partsRs   R   Rp   R   (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR     s    
	(   R   R   R   R   Rm   R   (    (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR?    s   c         C@  s   t  |   r t |  |  nV t |   rA t |  | | d | n1 | d k rY t   } n  t |  | | | d | | r t |  n  d S(   sv  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

    :param hashes: A Hashes object, one of whose embedded hashes must match,
        or HashMismatch will be raised. If the Hashes is empty, no matches are
        required, and unhashable types of requirements (like VCS ones, which
        would ordinarily raise HashUnsupported) are allowed.
    R  N(   R-   R+   R.   R,   Rx   R   R/   R   (   R   R   R0  t   only_downloadR   R  (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR0     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-typeRo   s   content-dispositionR"  t   wbN(   Rs   R   Rw   Rg   R   R   RI  R   RJ  Rp   R   R   R"  t   cgit   parse_headerR   R   t   guess_extensionR   R   RV   R   R  (   R   R   R1  R  t
   target_urlR   R   R   R"  t   content_dispositiont   typet   paramsR   t	   file_pathR	  (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR.  0  s<    		c         C@  s   t  j j | |  j  } t  j j |  r t j d |  | r y | j |  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   RV   R"  R#  R   R  R6  R   R   R/  Rx   (   R   R0  R  t   download_path(    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyR-  k  s    (v   t
   __future__R    RR  t   email.utilsR   R   RJ   R  R   R   RP   t   reR%  RS   R+  Rc   Rg   Ra   t   ImportErrorR   t   pip._vendor.six.moves.urllibR   Rq   R   R   R1   t   pip.exceptionsR   R   t
   pip.modelsR   t	   pip.utilsR   R   R   R	   R
   R   R   R   R   R   t   pip.utils.encodingR   t   pip.utils.filesystemR   t   pip.utils.loggingR   t   pip.utils.setuptools_buildR   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   R   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   Rh   Ri   R   R   R   t   SessionR   Rx   R&   t   compilet   IR   R   R'   R(   R)   R*   R+   R   R-   R.   R   R   R  R*  R/   R,   R>  R@  R?  R0   R.  R-  (    (    (    s]   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/download.pyt   <module>   s   

F			AM!BH)			
								`	&0	$'	;