
^Wc           @   s  d  d l  Z  d  d l m Z d  d l Z d  d l Z 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 d  d l Z y d  d l Z Wn e k
 rd  d l Z n Xd  d l 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% m& Z& m' Z' m( Z) m* Z* m+ Z+ m, Z, m- Z- m. Z. m/ Z/ m0 Z0 m1 Z1 m2 Z2 e
 j3 e4  Z5 d Z6 e j7 e6  Z8 d Z9 d	 e9 d
 Z: e9 d Z; d Z< d e< d e; d e6 d e< d e; d Z= d Z> d e= d e> d e= d Z? e: d e6 e: d Z@ d e@ d ZA d e9 d eA d e? d ZB e j7 eB  ZC d e< d e; d
 ZD e j7 eD  ZE d   ZF d    ZG d!   ZH d"   ZI d d d#  ZK d$   ZL d%   ZM d&   ZN e jO d'    ZP e jO d(    ZQ e jO d) d*   ZR d+ eS f d,     YZT d-   ZU d. eS f d/     YZV d0   ZW d1 eS f d2     YZX e j7 d3 e jY  ZZ d4   Z[ d d5  Z\ d6   Z] d7   Z^ d8   Z_ d9   Z` d:   Za e j7 d; e jb  Zc e j7 d<  Zd d d=  Ze e j7 d>  Zf d?   Zg d@   Zh dA   Zi dB Zj dC   Zk dD   Zl dE eS f dF     YZm dG eS f dH     YZn dI eS f dJ     YZo d~ Zp d eq dR  Zr dS   Zs d Zt dZ eS f d[     YZu e j7 d\  Zv e j7 d]  Zw e j7 d^  Zx d_   Z d`   Zy da e$ jz f db     YZz dc e) f dd     YZ( de e( e' f df     YZ{ e j| dg  Z} e} d k rdi e$ j~ f dj     YZ~ dk e$ j f dl     YZ n  dm e% j f dn     YZ do e% j f dp     YZ dq e% j f dr     YZ ds   Z dt eS f du     YZ dv e f dw     YZ dx e f dy     YZ dz e* f d{     YZ d| eS f d}     YZ d S(   iN(   t   deque(   t   iglobi   (   t   DistlibException(   t   string_typest	   text_typet   shutilt	   raw_inputt   StringIOt   cache_from_sourcet   urlopent   urljoint   httplibt	   xmlrpclibt	   splittypet   HTTPHandlert   HTTPSHandlert   BaseConfiguratort   valid_identt	   Containert   configparsert   URLErrort   match_hostnamet   CertificateErrort   ZipFilet   fsdecodes   \s*,\s*s
   (\w|[.-])+s   (\*|:(\*|\w+):|t   )s   \*?s   ([<>=!~]=)|[<>]t   (s   )?\s*(s   )(s   )\s*(s   ))*s   (from\s+(?P<diref>.*))s   \(\s*(?P<c1>t   |s   )\s*\)|(?P<c2>s   \s*)s   )*s   \[\s*(?P<ex>s   )?\s*\]s   (?P<dn>s	   \s*)?(\s*s   )?$s   (?P<op>s   )\s*(?P<vn>c         C   sk  d   } d  } t j |   } | rg| j   } | d } | d pK | d } | d sa d  } n d  } | d j   } | s d  } d } | d }	 n{ | d d k r d	 | } n  t j |  }
 g  |
 D] } | |  ^ q } d
 | d j g  | D] } d | ^ q  f }	 | d s$d  } n t j	 | d  } t
 d | d | d | d |	 d |  d |  } n  | S(   Nc         S   s   |  j    } | d | d f S(   Nt   opt   vn(   t	   groupdict(   t   mt   d(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_constraintW   s    t   dnt   c1t   c2t   direft    i    s   <>!=s   ~=s   %s (%s)s   , s   %s %st   ext   namet   constraintst   extrast   requirementt   sourcet   url(   t   Nonet   REQUIREMENT_REt   matchR   t   stript   RELOP_IDENT_REt   finditert   joint   COMMA_REt   splitR   (   t   sR!   t   resultR   R    R(   t   consR-   t   constrt   rst   iteratort   conR*   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   parse_requirementU   s4    	

	0
	c         C   s   d   } i  } x | D] \ } } } t  j j |  |  } x t |  D] } t  j j | |  }	 x t |	  D]v }
 | |  |
  } | d k r | j | d  qo | | |
  } | j t  j j d  j d  } | d | | | <qo WqG Wq W| S(   s%   Find destinations for resources filesc         S   s\   |  j  t j j d  }  | j  t j j d  } | j |   sE t  | t |   j d  S(   Nt   /(   t   replacet   ost   patht   sept
   startswitht   AssertionErrort   lent   lstrip(   t   baseRB   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_rel_path}   s    R?   N(	   RA   RB   R4   R   R.   t   popR@   RC   t   rstrip(   t   resources_roott   rulesRI   t   destinationsRH   t   suffixt   destt   prefixt   abs_baset   abs_globt   abs_patht   resource_filet   rel_patht   rel_dest(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_resources_destsz   s    	!c          C   s:   t  t d  r t }  n t j t t d t j  k }  |  S(   Nt   real_prefixt   base_prefix(   t   hasattrt   syst   TrueRQ   t   getattr(   R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   in_venv   s    	c          C   s7   t  j j t j  }  t |  t  s3 t |   }  n  |  S(   N(   RA   RB   t   normcaseR\   t
   executablet
   isinstanceR   R   (   R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_executable   s    
c         C   s   |  } xw t  r t |  } |  } | r7 | r7 | } n  | r	 | d j   } | | k r] Pn  | r| d | | |  f } q| q	 q	 W| S(   Ni    s	   %c: %s
%s(   R]   R   t   lower(   t   promptt   allowed_charst   error_promptt   defaultt   pR7   t   c(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   proceed   s    		c         C   sV   t  | t  r | j   } n  i  } x+ | D]# } | |  k r+ |  | | | <q+ q+ W| S(   N(   Rb   R   R6   (   R    t   keysR8   t   key(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   extract_by_key   s    c         C   s  t  j d d k r+ t j d  |   }  n  |  j   } t |  }  y t j |   } | d d d } xo | j   D]a \ } } xR | j   D]D \ } } d | | f } t	 |  }	 |	 d  k	 s t  |	 | | <q Wqt W| SWn! t k
 r|  j d d  n Xd   }
 t j   } y |
 | |   WnF t j k
 rp|  j   t j |  } t |  }  |
 | |   n Xi  } xz | j   D]l } i  | | <} xU | j |  D]D \ } } d | | f } t	 |  }	 |	 d  k	 st  |	 | | <qWqW| S(	   Ni    i   s   utf-8t
   extensionss   python.exportst   exportss   %s = %sc         S   s0   t  |  d  r |  j |  n |  j |  d  S(   Nt	   read_file(   R[   Rq   t   readfp(   t   cpt   stream(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   read_stream   s    (   R\   t   version_infot   codecst	   getreadert   readR   t   jsont   loadt   itemst   get_export_entryR.   RE   t	   Exceptiont   seekR   t   ConfigParsert   MissingSectionHeaderErrort   closet   textwrapt   dedentt   sections(   Rt   t   datat   jdataR8   t   groupt   entriest   kt   vR7   t   entryRu   Rs   Rm   R(   t   value(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   read_exports   sD    	
c         C   s   t  j d d k r+ t j d  |  } n  t j   } x |  j   D] \ } } | j |  x | j   D]u } | j	 d  k r | j } n d | j | j	 f } | j r d | d j | j  f } n  | j | | j |  qj WqD W| j |  d  S(   Ni    i   s   utf-8s   %s:%ss   %s [%s]s   , (   R\   Rv   Rw   t	   getwriterR   R   R|   t   add_sectiont   valuesRO   R.   RQ   t   flagsR4   t   setR(   t   write(   Rp   Rt   Rs   R   R   R   R7   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   write_exports   s    	c          c   s*   t  j   }  z	 |  VWd  t j |   Xd  S(   N(   t   tempfilet   mkdtempR   t   rmtree(   t   td(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   tempdir
  s    	c         c   s7   t  j   } z t  j |   d  VWd  t  j |  Xd  S(   N(   RA   t   getcwdt   chdir(   R    t   cwd(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s
    	i   c         c   s7   t  j   } z t  j |   d  VWd  t  j |  Xd  S(   N(   t   sockett   getdefaulttimeoutt   setdefaulttimeout(   t   secondst   cto(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   socket_timeout  s
    	t   cached_propertyc           B   s   e  Z d    Z d d  Z RS(   c         C   s   | |  _  d  S(   N(   t   func(   t   selfR   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   __init__'  s    c         C   s<   | d  k r |  S|  j |  } t j | |  j j |  | S(   N(   R.   R   t   objectt   __setattr__t   __name__(   R   t   objt   clsR   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   __get__,  s
    N(   R   t
   __module__R   R.   R   (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   &  s   	c         C   s   t  j d k r |  S|  s |  S|  d d k r@ t d |    n  |  d d k rc t d |    n  |  j d  } x# t  j | k r | j t  j  qu W| s t  j St  j j |   S(   s  Return 'pathname' as a name that will work on the native filesystem.

    The path is split on '/' and put back together again using the current
    directory separator.  Needed because filenames in the setup script are
    always supplied in Unix style, and have to be converted to the local
    convention before we can actually use them in the filesystem.  Raises
    ValueError on non-Unix-ish systems if 'pathname' either starts or
    ends with a slash.
    R?   i    s   path '%s' cannot be absoluteis   path '%s' cannot end with '/'(   RA   RC   t
   ValueErrorR6   t   curdirt   removeRB   R4   (   t   pathnamet   paths(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   convert_path4  s    
t   FileOperatorc           B   s   e  Z e d   Z d   Z d   Z d   Z e d  Z d d  Z
 d   Z d   Z d   Z d	   Z d
   Z e e d d  Z d   Z d   Z d   Z d   Z RS(   c         C   s#   | |  _  t   |  _ |  j   d  S(   N(   t   dry_runR   t   ensuredt   _init_record(   R   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   P  s    	c         C   s%   t  |  _ t   |  _ t   |  _ d  S(   N(   t   Falset   recordR   t   files_writtent   dirs_created(   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   U  s    	c         C   s    |  j  r |  j j |  n  d  S(   N(   R   R   t   add(   R   RB   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   record_as_writtenZ  s    	c         C   si   t  j j |  s1 t d t  j j |    n  t  j j |  sG t St  j |  j t  j |  j k S(   s  Tell if the target is newer than the source.

        Returns true if 'source' exists and is more recently modified than
        'target', or if 'source' exists and 'target' doesn't.

        Returns false if both exist and 'target' is the same age or younger
        than 'source'. Raise PackagingFileError if 'source' does not exist.

        Note that this test is not very accurate: files created in the same
        second will have the same "age".
        s   file '%r' does not exist(   RA   RB   t   existsR   t   abspathR]   t   statt   st_mtime(   R   R,   t   target(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   newer^  s    c         C   s   |  j  t j j |   t j d | |  |  j s d } | r t j j |  r` d | } q t j j	 |  r t j j
 |  r d | } q n  | r t | d   n  t j | |  n  |  j |  d S(   s8   Copy a file respecting dry-run and force flags.
        s   Copying %s to %ss   %s is a symlinks   %s is a non-regular files    which would be overwrittenN(   t
   ensure_dirRA   RB   t   dirnamet   loggert   infoR   R.   t   islinkR   t   isfileR   R   t   copyfileR   (   R   t   infilet   outfilet   checkt   msg(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt	   copy_filer  s    	%c         C   s   t  j j |  s t  |  j t  j j |   t j d | |  |  j s | d  k rl t
 | d  } n t j
 | d d | } z t j | |  Wd  | j   Xn  |  j |  d  S(   Ns   Copying stream %s to %st   wbt   wt   encoding(   RA   RB   t   isdirRE   R   R   R   R   R   R.   t   openRw   R   t   copyfileobjR   R   (   R   t   instreamR   R   t	   outstream(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   copy_stream  s    	c         C   s[   |  j  t j j |   |  j sJ t | d   } | j |  Wd  QXn  |  j |  d  S(   NR   (   R   RA   RB   R   R   R   R   R   (   R   RB   R   t   f(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   write_binary_file  s
    	c         C   sd   |  j  t j j |   |  j sS t | d   } | j | j |   Wd  QXn  |  j |  d  S(   NR   (	   R   RA   RB   R   R   R   R   t   encodeR   (   R   RB   R   R   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   write_text_file  s
    	c         C   s   t  j d k s- t  j d k r t  j d k r xj | D]_ } |  j rV t j d |  q4 t  j |  j | B| @} t j d | |  t  j | |  q4 Wn  d  S(   Nt   posixt   javas   changing mode of %ss   changing mode of %s to %o(	   RA   R(   t   _nameR   R   R   R   t   st_modet   chmod(   R   t   bitst   maskt   filesR   t   mode(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   set_mode  s    -	c         C   s   |  j  d d |  S(   Nim  i  (   R   (   R7   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   <lambda>  s    c         C   s   t  j j |  } | |  j k r t  j j |  r |  j j |  t  j j |  \ } } |  j |  t j	 d |  |  j
 s t  j |  n  |  j r |  j j |  q n  d  S(   Ns   Creating %s(   RA   RB   R   R   R   R   R6   R   R   R   R   t   mkdirR   R   (   R   RB   R    R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    "		c         C   s   t  | |  } t j d | |  |  j s | sD |  j | |  r{ | sS d  } q{ | j |  sh t  | t |  } n  t	 j
 | | | t  n  |  j |  | S(   Ns   Byte-compiling %s to %s(   R   R   R   R   R   R.   RD   RE   RF   t
   py_compilet   compileR]   R   (   R   RB   t   optimizet   forceRQ   t   dpatht   diagpath(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   byte_compile  s    		c         C   s  t  j j |  rt  j j |  r t  j j |  r t j d |  |  j s` t j	 |  n  |  j
 r| |  j k r |  j j |  q qqt  j j |  r d } n d } t j d | |  |  j s t  j |  n  |  j
 r| |  j k r|  j j |  qqn  d  S(   Ns   Removing directory tree at %st   linkt   files   Removing %s %s(   RA   RB   R   R   R   R   t   debugR   R   R   R   R   R   R   (   R   RB   R7   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   ensure_removed  s"    %					c         C   sj   t  } x] | se t j j |  r: t j | t j  } Pn  t j j |  } | | k r\ Pn  | } q	 W| S(   N(   R   RA   RB   R   t   accesst   W_OKR   (   R   RB   R8   t   parent(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   is_writable  s    	
c         C   s/   |  j  s t  |  j |  j f } |  j   | S(   sV   
        Commit recorded changes, turn off recording, return
        changes.
        (   R   RE   R   R   R   (   R   R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   commit  s    
c         C   s   |  j  s x9 t |  j  D]( } t j j |  r t j |  q q Wt |  j d t	 } xq | D]f } t j
 |  } | r | d g k s t  t j j | | d  } t j |  n  t j |  qa Wn  |  j   d  S(   Nt   reverset   __pycache__i    (   R   t   listR   RA   RB   R   R   t   sortedR   R]   t   listdirRE   R4   t   rmdirR   (   R   R   t   dirsR    t   flistt   sd(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   rollback  s    	N(   R   R   R   R   R   R   R   R]   R   R.   R   R   R   R   t   set_executable_modeR   R   R   R   R   R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   O  s    											
c         C   s   |  t  j k r t  j |  } n t |   } | d  k r@ | } nG | j d  } t | | j d   } x | D] } t | |  } qn W| S(   Nt   .i    (   R\   t   modulest
   __import__R.   R6   R^   RJ   (   t   module_namet   dotted_patht   modR8   t   partsRi   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   resolve  s    	t   ExportEntryc           B   s;   e  Z d    Z e d    Z d   Z d   Z e j Z RS(   c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   R(   RQ   RO   R   (   R   R(   RQ   RO   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    			c         C   s   t  |  j |  j  S(   N(   R  RQ   RO   (   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    c         C   s    d |  j  |  j |  j |  j f S(   Ns   <ExportEntry %s = %s:%s %s>(   R(   RQ   RO   R   (   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   __repr__  s    c         C   sd   t  | t  s t } nH |  j | j k o] |  j | j k o] |  j | j k o] |  j | j k } | S(   N(   Rb   R  R   R(   RQ   RO   R   (   R   t   otherR8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   __eq__#  s    	(	   R   R   R   R   R   R  R  R   t   __hash__(    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR    s
   			
s   (?P<name>(\w|[-.+])+)
                      \s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
                      \s*(\[\s*(?P<flags>\w+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
                      c         C   sS  t  j |   } | sI d  } d |  k s3 d |  k rOt d |    qOn| j   } | d } | d } | j d  } | d k r | d  } } n4 | d k r t d |    n  | j d  \ } } | d	 }	 |	 d  k rd |  k s d |  k r	t d |    n  g  }	 n( g  |	 j d
  D] }
 |
 j   ^ q"}	 t | | | |	  } | S(   Nt   [t   ]s   Invalid specification %rR(   t   callablet   :i    i   R   t   ,(	   t   ENTRY_REt   searchR.   R   R   t   countR6   R1   R  (   t   specificationR   R8   R    R(   RB   t   colonsRQ   RO   R   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR}   5  s2    


	(c         C   s  |  d
 k r d }  n  t j d k rH d t j k rH t j j d  } n t j j d  } t j j |  r t j | t j	  } | s t
 j d |  q nG y t j |  t } Wn- t k
 r t
 j d | d t t } n X| s	t j   } t
 j d	 |  n  t j j | |   S(   s  
    Return the default base location for distlib caches. If the directory does
    not exist, it is created. Use the suffix provided for the base directory,
    and default to '.distlib' if it isn't provided.

    On Windows, if LOCALAPPDATA is defined in the environment, then it is
    assumed to be a directory, and will be the parent directory of the result.
    On POSIX, and on Windows if LOCALAPPDATA is not defined, the user's home
    directory - using os.expanduser('~') - will be the parent directory of
    the result.

    The result is just the directory '.distlib' in the parent directory as
    determined above, or with the name specified with ``suffix``.
    s   .distlibt   ntt   LOCALAPPDATAs   $localappdatat   ~s(   Directory exists but is not writable: %ss   Unable to create %st   exc_infos#   Default location unusable, using %sN(   R.   RA   R(   t   environRB   t
   expandvarst
   expanduserR   R   R   R   t   warningt   makedirsR]   t   OSErrorR   R   R   R4   (   RO   R8   t   usable(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_cache_baseT  s&    	

c         C   s`   t  j j t  j j |    \ } } | r? | j d d  } n  | j t  j d  } | | d S(   s  
    Convert an absolute path to a directory name for use in a cache.

    The algorithm used is:

    #. On Windows, any ``':'`` in the drive is replaced with ``'---'``.
    #. Any occurrence of ``os.sep`` is replaced with ``'--'``.
    #. ``'.cache'`` is appended.
    R  s   ---s   --s   .cache(   RA   RB   t
   splitdriveR   R@   RC   (   RB   R    Ri   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   path_to_cache_dir}  s
    
$c         C   s   |  j  d  s |  d S|  S(   NR?   (   t   endswith(   R7   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   ensure_slash  s    c         C   sk   d  } } d |  k r^ |  j d d  \ } }  d | k rC | } q^ | j d d  \ } } n  | | |  f S(   Nt   @i   R  (   R.   R6   (   t   netloct   usernamet   passwordRQ   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   parse_credentials  s    
	c          C   s    t  j d  }  t  j |   |  S(   Ni   (   RA   t   umask(   R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_process_umask  s    c         C   sX   t  } d  } x3 t |   D]% \ } } t | t  s t } Pq q W| d  k	 sT t  | S(   N(   R]   R.   t	   enumerateRb   R   R   RE   (   t   seqR8   t   iR7   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   is_string_sequence  s    s3   ([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)s   -py(\d\.?\d?)c         C   s  d } d } t j |   } | rC | j d  } |  | j    }  n  | r t |   t |  d k r t j t j |  d |   } | r | j	   } |  |  |  | d | f } q n  | d k r t
 j |   } | r | j d  | j d  | f } q n  | S(   sw   
    Extract name, version, python version from a filename (no extension)

    Return name, version, pyver or None
    i   s   \bi   N(   R.   t   PYTHON_VERSIONR  R   t   startRF   t   reR0   t   escapet   endt   PROJECT_NAME_AND_VERSION(   t   filenamet   project_nameR8   t   pyverR   t   n(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   split_filename  s     "!'s-   (?P<name>[\w .-]+)\s*\(\s*(?P<ver>[^\s)]+)\)$c         C   sR   t  j |   } | s( t d |    n  | j   } | d j   j   | d f S(   s   
    A utility method used to get name and version from a string.

    From e.g. a Provides-Dist value.

    :param p: A value in a form 'foo (1.0)'
    :return: The name and version as a tuple.
    s$   Ill-formed name/version string: '%s'R(   t   ver(   t   NAME_VERSION_RER0   R   R   R1   Rd   (   Ri   R   R    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   parse_name_and_version  s
    	c         C   s	  t    } t  |  p g   }  t  | p' g   } d |  k rS |  j d  | | O} n  x |  D] } | d k r| | j |  qZ | j d  r | d } | | k r t j d |  n  | | k r| j |  qqZ | | k r t j d |  n  | j |  qZ W| S(   Nt   *t   -i   s   undeclared extra: %s(   R   R   R   RD   R   R#  (   t	   requestedt	   availableR8   t   rt   unwanted(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt
   get_extras  s&    	
c         C   s   i  } yq t  |   } | j   } | j d  } | j d  sR t j d |  n$ t j d  |  } t j	 |  } Wn& t
 k
 r } t j d |  |  n X| S(   Ns   Content-Types   application/jsons(   Unexpected response for JSON request: %ss   utf-8s&   Failed to get external data for %s: %s(   R	   R   t   getRD   R   R   Rw   Rx   Rz   R{   R~   t	   exception(   R-   R8   t   respt   headerst   ctt   readert   e(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   _get_external_data  s    s'   https://www.red-dove.com/pypi/projects/c         C   s9   d |  d j    |  f } t t |  } t |  } | S(   Ns   %s/%s/project.jsoni    (   t   upperR
   t   _external_data_base_urlRS  (   R(   R-   R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_project_data  s    c         C   s6   d |  d j    |  | f } t t |  } t |  S(   Ns   %s/%s/package-%s.jsoni    (   RT  R
   RU  RS  (   R(   t   versionR-   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_package_data  s    t   Cachec           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   
    A class implementing a cache for resources that need to live in the file system
    e.g. shared libraries. This class was moved from resources to here because it
    could be used by other modules, e.g. the wheel module.
    c         C   sv   t  j j |  s" t  j |  n  t  j |  j d @d k rQ t j d |  n  t  j j t  j j	 |   |  _
 d S(   su   
        Initialise an instance.

        :param base: The base directory where the cache should be located.
        i?   i    s   Directory '%s' is not privateN(   RA   RB   R   R$  R   R   R   R#  R   t   normpathRH   (   R   RH   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s
    c         C   s
   t  |  S(   sN   
        Converts a resource prefix to a directory name in the cache.
        (   R)  (   R   RQ   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   prefix_to_dir-  s    c         C   s   g  } x t  j |  j  D] } t  j j |  j |  } yZ t  j j |  s^ t  j j |  rn t  j |  n" t  j j |  r t	 j
 |  n  Wq t k
 r | j |  q Xq W| S(   s"   
        Clear the cache.
        (   RA   R   RH   RB   R4   R   R   R   R   R   R   R~   t   append(   R   t   not_removedt   fn(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   clear3  s    $(   R   R   t   __doc__R   R[  R_  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyRY    s   		t
   EventMixinc           B   s>   e  Z d  Z d   Z e d  Z d   Z d   Z d   Z RS(   s1   
    A very simple publish/subscribe system.
    c         C   s   i  |  _  d  S(   N(   t   _subscribers(   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   H  s    c         C   s\   |  j  } | | k r+ t | g  | | <n- | | } | rK | j |  n | j |  d S(   s`  
        Add a subscriber for an event.

        :param event: The name of an event.
        :param subscriber: The subscriber to be added (and called when the
                           event is published).
        :param append: Whether to append or prepend the subscriber to an
                       existing subscriber list for the event.
        N(   Rb  R    R\  t
   appendleft(   R   t   eventt
   subscriberR\  t   subst   sq(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   K  s    
	
c         C   s=   |  j  } | | k r( t d |   n  | | j |  d S(   s   
        Remove a subscriber for an event.

        :param event: The name of an event.
        :param subscriber: The subscriber to be removed.
        s   No subscribers: %rN(   Rb  R   R   (   R   Rd  Re  Rf  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   _  s    	c         C   s   t  |  j j | d   S(   s   
        Return an iterator for the subscribers for an event.
        :param event: The event to return subscribers for.
        (    (   t   iterRb  RL  (   R   Rd  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   get_subscribersk  s    c         O   s   g  } xa |  j  |  D]P } y | | | |  } Wn$ t k
 rX t j d  d } n X| j |  q Wt j d | | | |  | S(   s^  
        Publish a event and return a list of values returned by its
        subscribers.

        :param event: The event to publish.
        :param args: The positional arguments to pass to the event's
                     subscribers.
        :param kwargs: The keyword arguments to pass to the event's
                       subscribers.
        s"   Exception during event publications/   publish %s: args = %s, kwargs = %s, result = %sN(   Ri  R~   R   RM  R.   R\  R   (   R   Rd  t   argst   kwargsR8   Re  R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   publishr  s    
	(	   R   R   R`  R   R]   R   R   Ri  Rl  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyRa  D  s   			t	   Sequencerc           B   sh   e  Z d    Z d   Z e d  Z d   Z d   Z d   Z d   Z	 e
 d    Z e
 d    Z RS(	   c         C   s"   i  |  _  i  |  _ t   |  _ d  S(   N(   t   _predst   _succsR   t   _nodes(   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    		c         C   s   |  j  j |  d  S(   N(   Rp  R   (   R   t   node(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   add_node  s    c         C   s  | |  j  k r" |  j  j |  n  | r	x3 t |  j j | d   D] } |  j | |  qD Wx3 t |  j j | d   D] } |  j | |  qz Wx6 t |  j j    D] \ } } | s |  j | =q q Wx9 t |  j j    D] \ } } | s |  j | =q q Wn  d  S(   N(    (    (   Rp  R   R   Rn  RL  Ro  R   R|   (   R   Rq  t   edgesRi   R7   R   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   remove_node  s    """"c         C   sT   | | k s t   |  j j | t    j |  |  j j | t    j |  d  S(   N(   RE   Rn  t
   setdefaultR   R   Ro  (   R   t   predt   succ(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    c         C   s   | | k s t   y |  j | } |  j | } Wn! t k
 rS t d |   n Xy | j |  | j |  Wn' t k
 r t d | | f   n Xd  S(   Ns   %r not a successor of anythings   %r not a successor of %r(   RE   Rn  Ro  t   KeyErrorR   R   (   R   Rv  Rw  t   predst   succs(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    c         C   s+   | |  j  k p* | |  j k p* | |  j k S(   N(   Rn  Ro  Rp  (   R   t   step(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   is_step  s    c         C   s   |  j  |  s" t d |   n  g  } g  } t   } | j |  x | r | j d  } | | k r | | k r | j |  | j |  q qG | j |  | j |  |  j j | d  } | j	 |  qG Wt
 |  S(   Ns   Unknown: %ri    (    (   R|  R   R   R\  RJ   R   R   Rn  RL  t   extendt   reversed(   R   t   finalR8   t   todot   seenR{  Ry  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt	   get_steps  s"    		c            sy   d g  g   i   i   g   |  j            f d    x'   D] } |  k rR  |  qR qR W S(   Ni    c            s@   d  |  < d  |  < d c d 7< j  |   y   |  } Wn t k
 r` g  } n Xxl | D]d } |  k r  |  t  |   |   |  <qh |  k rh t  |   |   |  <qh qh W |   |  k r<g  } x3 t r j   } | j  |  | |  k r Pq q Wt |  }  j  |  n  d  S(   Ni    i   (   R\  R~   t   minR]   RJ   t   tuple(   Rq  t
   successorst	   successort   connected_componentt	   component(   t   grapht   indext   index_countert   lowlinksR8   t   stackt   strongconnect(    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR    s.    

"	 (   Ro  (   R   Rq  (    (   R  R  R  R  R8   R  R  si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   strong_connections  s    		!"c         C   s   d g } xF |  j  D]; } |  j  | } x% | D] } | j d | | f  q- Wq Wx" |  j D] } | j d |  q\ W| j d  d j |  S(   Ns   digraph G {s     %s -> %s;s     %s;t   }s   
(   Rn  R\  Rp  R4   (   R   R8   Rw  Ry  Rv  Rq  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   dot  s    	(   R   R   R   Rr  R   Rt  R   R   R|  R  t   propertyR  R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyRm    s   						3s   .tar.gzs   .tar.bz2s   .tars   .zips   .tgzs   .tbzs   .whlc   
         s     f d   } t  j j      t     d  } | d  k r |  j d  rZ d } q |  j d  rx d } d } q |  j d  r d } d } q |  j d  r d } d } q t d |    n  z| d k rt |  d  } | rZ| j   } x | D] } | |  q WqZnB t	 j
 |  |  } | rZ| j   } x | D] } | |  qCWn  | d k rt j d d k  rxA | j   D]0 }	 t |	 j t  s|	 j j d  |	 _ qqWn  | j    Wd  | r| j   n  Xd  S(   Nc            s|   t  |  t  s! |  j d  }  n  t j j t j j   |    } | j    se |  t j k rx t	 d |   n  d  S(   Ns   utf-8s   path outside destination: %r(
   Rb   R   t   decodeRA   RB   R   R4   RD   RC   R   (   RB   Ri   (   t   dest_dirt   plen(    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt
   check_path  s
    !#s   .zips   .whlt   zips   .tar.gzs   .tgzt   tgzs   r:gzs   .tar.bz2s   .tbzt   tbzs   r:bz2s   .tart   tarRI  s   Unknown format for %ri    i   s   utf-8(   s   .zips   .whl(   s   .tar.gzs   .tgz(   s   .tar.bz2s   .tbz(   RA   RB   R   RF   R.   R*  R   R   t   namelistt   tarfileR   t   getnamesR\   Rv   t
   getmembersRb   R(   R   R  t
   extractallR   (
   t   archive_filenameR  t   formatR   R  t   archiveR   t   namesR(   t   tarinfo(    (   R  R  si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt	   unarchive  sH    				c      	   C   s   t  j   } t |   } t | d   } xu t j |   D]d \ } } } xR | D]J } t j j | |  } | | }	 t j j |	 |  }
 | j | |
  qP Wq: WWd QX| S(   s*   zip a directory tree into a BytesIO objectR   N(	   t   iot   BytesIORF   R   RA   t   walkRB   R4   R   (   t	   directoryR8   t   dlent   zft   rootR   R   R(   t   fullt   relRP   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   zip_dirP  s    
R&   t   Kt   Mt   Gt   Tt   Pt   Progressc           B   s   e  Z d  Z d d d  Z d   Z d   Z d   Z d   Z e d    Z	 e d	    Z
 d
   Z e d    Z e d    Z RS(   t   UNKNOWNi    id   c         C   sV   | d  k s | | k s t  | |  _ |  _ | |  _ d  |  _ d |  _ t |  _ d  S(   Ni    (	   R.   RE   R  t   curt   maxt   startedt   elapsedR   t   done(   R   t   minvalt   maxval(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   g  s    			c         C   s}   |  j  | k s t  |  j d  k s9 | |  j k s9 t  | |  _ t j   } |  j d  k ri | |  _ n | |  j |  _ d  S(   N(   R  RE   R  R.   R  t   timeR  R  (   R   t   curvalt   now(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   updateo  s    $	c         C   s*   | d k s t   |  j |  j |  d  S(   Ni    (   RE   R  R  (   R   t   incr(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt	   incrementy  s    c         C   s   |  j  |  j  |  S(   N(   R  R  (   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR8  }  s    c         C   s/   |  j  d  k	 r" |  j |  j   n  t |  _ d  S(   N(   R  R.   R  R]   R  (   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   stop  s    c         C   s   |  j  d  k r |  j S|  j  S(   N(   R  R.   t   unknown(   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   maximum  s    c         C   sZ   |  j  r d } nD |  j d  k r* d } n, d |  j |  j |  j |  j } d | } | S(   Ns   100 %s    ?? %g      Y@s   %3d %%(   R  R  R.   R  R  (   R   R8   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt
   percentage  s    			"
c         C   sU   | d k r |  j  d  k s- |  j |  j k r6 d } n t j d t j |   } | S(   Ni    s   ??:??:??s   %H:%M:%S(   R  R.   R  R  R  t   strftimet   gmtime(   R   t   durationR8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   format_duration  s    -	c         C   s   |  j  r d } |  j } n d } |  j d  k r9 d } ne |  j d k sZ |  j |  j k rc d } n; t |  j |  j  } | |  j |  j :} | d |  j } d | |  j |  f S(   Nt   Dones   ETA ii    i   s   %s: %s(   R  R  R  R.   R  R  t   floatR  (   R   RQ   t   t(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   ETA  s    		!	c         C   sh   |  j  d k r d } n |  j |  j |  j  } x( t D]  } | d k  rL Pn  | d :} q6 Wd | | f S(   Ni    g        i  g     @@s   %d %sB/s(   R  R  R  t   UNITS(   R   R8   t   unit(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   speed  s    	(   R   R   R  R   R  R  R8  R  R  R  R  R  R  R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR  d  s   	
					s   \{([^}]*)\}s   [^/\\,{]\*\*|\*\*[^/\\,}]s   ^[^{]*\}|\{[^}]*$c         C   sZ   t  j |   r( d } t | |    n  t j |   rP d } t | |    n  t |   S(   sA   Extended globbing function that supports ** and {opt1,opt2,opt3}.s7   invalid glob %r: recursive glob "**" must be used alones2   invalid glob %r: mismatching set marker '{' or '}'(   t   _CHECK_RECURSIVE_GLOBR  R   t   _CHECK_MISMATCH_SETt   _iglob(   t	   path_globR   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    c         c   s  t  j |  d  } t |  d k r t |  d k sB t |   | \ } } } x3| j d  D]4 } x+ t d j | | | f   D] } | Vq Wqa Wn d |  k r x t |   D] } | Vq Wn |  j d d  \ } } | d k r d } n  | d k r	d } n | j d  } | j d	  } x] t j	 |  D]L \ } } }	 t j
 j |  } x( t t j
 j | |   D] }
 |
 VqtWq7Wd  S(
   Ni   i   R  R&   s   **R  RE  R?   s   \(   t	   RICH_GLOBR6   RF   RE   R  R4   t	   std_iglobRG   RA   R  RB   RZ  (   R  t   rich_path_globRQ   R   RO   t   itemRB   t   radicalt   dirR   R^  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR    s*    %		"t   HTTPSConnectionc           B   s   e  Z d Z e Z d    Z RS(   c      
   C   s  t  j |  j |  j f |  j  } t |  d t  rI | |  _ |  j   n  t	 t
 d  s |  j rm t
 j } n	 t
 j } t
 j | |  j |  j d | d t
 j d |  j |  _ n t
 j t
 j  } | j t
 j O_ |  j r | j |  j |  j  n  i  } |  j rHt
 j | _ | j d |  j  t t
 d t  rH|  j | d <qHn  | j | |  |  _ |  j r|  j ry0 t |  j j   |  j  t j d	 |  j  Wqt k
 r|  j j t  j  |  j j      qXn  d  S(
   Nt   _tunnel_hostt
   SSLContextt	   cert_reqst   ssl_versiont   ca_certst   cafilet   HAS_SNIt   server_hostnames   Host verified: %s(!   R   t   create_connectiont   hostt   portt   timeoutR^   R   t   sockt   _tunnelR[   t   sslR  t   CERT_REQUIREDt	   CERT_NONEt   wrap_sockett   key_filet	   cert_filet   PROTOCOL_SSLv23R  t   optionst   OP_NO_SSLv2t   load_cert_chaint   verify_modet   load_verify_locationst   check_domainR   t   getpeercertR   R   R   t   shutdownt	   SHUT_RDWRR   (   R   R  R  t   contextRk  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   connect  s>    !						N(   R   R   R.   R  R]   R  R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR    s   R   c           B   s&   e  Z e d   Z d   Z d   Z RS(   c         C   s#   t  j |   | |  _ | |  _ d  S(   N(   t   BaseHTTPSHandlerR   R  R  (   R   R  R  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    	c         O   s7   t  | |   } |  j r3 |  j | _ |  j | _ n  | S(   s  
        This is called to create a connection instance. Normally you'd
        pass a connection class to do_open, but it doesn't actually check for
        a class, and just expects a callable. As long as we behave just as a
        constructor would have, we should be OK. If it ever changes so that
        we *must* pass a class, we'll create an UnsafeHTTPSConnection class
        which just sets check_domain to False in the class definition, and
        choose which one to pass to do_open.
        (   R  R  R  (   R   Rj  Rk  R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   _conn_maker"  s
    
	c         C   s_   y |  j  |  j |  SWnA t k
 rZ } d t | j  k rT t d | j   q[   n Xd  S(   Ns   certificate verify faileds*   Unable to verify server certificate for %s(   t   do_openR  R   t   strt   reasonR   R  (   R   t   reqRR  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt
   https_open2  s    (   R   R   R]   R   R  R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s   	t   HTTPSOnlyHandlerc           B   s   e  Z d    Z RS(   c         C   s   t  d |   d  S(   NsA   Unexpected HTTP request on what should be a secure connection: %s(   R   (   R   R  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt	   http_openF  s    (   R   R   R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR  E  s   i   i   t   HTTPc           B   s   e  Z d  d d  Z RS(   R&   c         K   s5   | d k r d  } n  |  j |  j | | |   d  S(   Ni    (   R.   t   _setupt   _connection_class(   R   R  R  Rk  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   R  s    	N(   R   R   R.   R   (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR  Q  s   t   HTTPSc           B   s   e  Z d  d d  Z RS(   R&   c         K   s5   | d k r d  } n  |  j |  j | | |   d  S(   Ni    (   R.   R  R	  (   R   R  R  Rk  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   Y  s    	N(   R   R   R.   R   (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR
  X  s   t	   Transportc           B   s   e  Z d  d  Z d   Z RS(   i    c         C   s    | |  _  t j j |  |  d  S(   N(   R  R   R  R   (   R   R  t   use_datetime(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   `  s    	c         C   s   |  j  |  \ } } } t d k r< t | d |  j } nN |  j sY | |  j d k r} | |  _ | t j |  f |  _ n  |  j d } | S(   Ni   i   R  i    i   (   i   i   (   t   get_host_infot	   _ver_infoR  R  t   _connectiont   _extra_headersR   t   HTTPConnection(   R   R  t   ht   eht   x509R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   make_connectiond  s    	(   R   R   R   R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR  _  s   t   SafeTransportc           B   s   e  Z d  d  Z d   Z RS(   i    c         C   s    | |  _  t j j |  |  d  S(   N(   R  R   R  R   (   R   R  R  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR   p  s    	c         C   s   |  j  |  \ } } } | s' i  } n  |  j | d <t d k rU t | d  |  } nT |  j sr | |  j d k r | |  _ | t j | d  |  f |  _ n  |  j d } | S(   NR  i   i   i    i   (   i   i   (	   R  R  R  R
  R.   R  R  R   R  (   R   R  R  R  Rk  R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR  t  s    		(   R   R   R   R  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR  o  s   t   ServerProxyc           B   s   e  Z d    Z RS(   c   	      K   s   | j  d d   |  _ } | d  k	 r t |  \ } } | j d d  } | d k r^ t } n t } | | d | | d <} | |  _ n  t j	 j
 |  | |  d  S(   NR  R  i    t   httpst	   transport(   RJ   R.   R  R   RL  R  R  R  R   R  R   (	   R   t   uriRk  R  t   schemet   _R  t   tclsR  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    	(   R   R   R   (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR    s   c         K   s:   t  j d d k  r  | d 7} n
 d | d <t |  | |  S(   Ni    i   t   bR&   t   newline(   R\   Rv   R   (   R^  R   Rk  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt	   _csv_open  s    
t   CSVBasec           B   sG   e  Z i e d   d 6e d  d 6e d  d 6Z d   Z d   Z RS(   R  t	   delimitert   "t	   quotechars   
t   lineterminatorc         C   s   |  S(   N(    (   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt	   __enter__  s    c         G   s   |  j  j   d  S(   N(   Rt   R   (   R   R  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   __exit__  s    (   R   R   R  t   defaultsR&  R'  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR!    s   	t	   CSVReaderc           B   s)   e  Z d    Z d   Z d   Z e Z RS(   c         K   s   d | k rM | d } t  j d d k rA t j d  |  } n  | |  _ n t | d d  |  _ t j |  j |  j  |  _ d  S(   NRt   i    i   s   utf-8RB   RI  (	   R\   Rv   Rw   Rx   Rt   R   t   csvRQ  R(  (   R   Rk  Rt   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    
c         C   s   |  S(   N(    (   R   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   __iter__  s    c         C   sk   t  |  j  } t j d d k  rg xB t |  D]1 \ } } t | t  s/ | j d  | | <q/ q/ Wn  | S(   Ni    i   s   utf-8(   t   nextRQ  R\   Rv   R3  Rb   R   R  (   R   R8   R5  R  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR,    s    (   R   R   R   R+  R,  t   __next__(    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR)    s   			t	   CSVWriterc           B   s   e  Z d    Z d   Z RS(   c         K   s1   t  | d  |  _ t j |  j |  j  |  _ d  S(   NR   (   R   Rt   R*  t   writerR(  (   R   R^  Rk  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    c         C   su   t  j d d k  ra g  } x< | D]4 } t | t  rG | j d  } n  | j |  q  W| } n  |  j j |  d  S(   Ni    i   s   utf-8(   R\   Rv   Rb   R   R   R\  R/  t   writerow(   R   t   rowRI  R  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR0    s    	(   R   R   R   R0  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR.    s   	t   Configuratorc           B   sH   e  Z e e j  Z d  e d <d d  Z d   Z d   Z d   Z	 RS(   t   inc_convertt   incc         C   s/   t  t |   j |  | p% t j   |  _ d  S(   N(   t   superR2  R   RA   R   RH   (   R   t   configRH   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    c            s!     f d     | j  d  } t |  s?  j |  } n  | j  d d   } | j  d d  } | r t g  | D] }   |  ^ qs  } n  g  | D]( } t |  r |   | |  f ^ q } t |  } | | |   }	 | rx3 | j   D]" \ }
 } t |	 |
   |   q Wn  |	 S(   Nc            s   t  |  t t f  rC t |   g  |  D] }   |  ^ q%  } nj t  |  t  r d |  k rp  j |   } q i  } x4 |  D] }   |  |  | | <q} Wn  j |   } | S(   Ns   ()(   Rb   R   R  t   typet   dictt   configure_customt   convert(   t   oR5  R8   R   (   R:  R   (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR:    s    .s   ()R  s   [](    (	   RJ   R  R  R.   R  R   R8  R|   t   setattr(   R   R6  Rj   t   propsRj  R;  R   R|   Rk  R8   R@  R   (    (   R:  R   si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR9    s    (5c         C   sI   |  j  | } t | t  rE d | k rE |  j |  |  j  | <} n  | S(   Ns   ()(   R6  Rb   R8  R9  (   R   Rm   R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   __getitem__  s    c         C   sa   t  j j |  s- t  j j |  j |  } n  t j | d d d  } t j |  } Wd QX| S(   s*   Default converter for the inc:// protocol.RI  R   s   utf-8N(	   RA   RB   t   isabsR4   RH   Rw   R   Rz   R{   (   R   R   R   R8   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR3  	  s
    N(
   R   R   R8  R   t   value_convertersR.   R   R9  R>  R3  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR2    s   
		t   SubprocessMixinc           B   s)   e  Z e d d   Z d   Z d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   t   verboset   progress(   R   RB  RC  (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyR     s    	c         C   s   |  j  } |  j } x{ t r | j   } | s1 Pn  | d k	 rM | | |  q | sf t j j d  n t j j | j d   t j j	   q W| j
   d S(   s   
        Read lines from a subprocess' output stream and either pass to a progress
        callable (if specified) or write progress information to sys.stderr.
        R  s   utf-8N(   RC  RB  R]   t   readlineR.   R\   t   stderrR   R  t   flushR   (   R   Rt   R  RC  RB  R7   (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyRQ    s    			c         K   s   t  j | d t  j d t  j | } t j d |  j d | j d f  } | j   t j d |  j d | j d f  } | j   | j	   | j
   | j
   |  j d  k	 r |  j d d  n |  j r t j j d  n  | S(   Nt   stdoutRE  R   Rj  s   done.t   mains   done.
(   t
   subprocesst   Popent   PIPEt	   threadingt   ThreadRQ  RG  R8  RE  t   waitR4   RC  R.   RB  R\   R   (   R   t   cmdRk  Ri   t   t1t   t2(    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   run_command/  s    $
$



	N(   R   R   R   R.   R   RQ  RR  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyRA    s   	(   s   .tar.gzs   .tar.bz2s   .tars   .zips   .tgzs   .tbzs   .whl(   R&   R  R  R  R  R  (   i   i   (   Rw   t   collectionsR    t
   contextlibR*  t   globR   R  R  Rz   t   loggingRA   R   R9  R   R   R  RI  R\   R  R   R   RL  t   ImportErrort   dummy_threadingR  R&   R   t   compatR   R   R   R   R   R	   R
   R   R   R   R   R   R  R   R   R   R   R   R   R   R   R   t	   getLoggerR   R   t   COMMAR   R5   t   IDENTt   EXTRA_IDENTt   VERSPECt   RELOPt   BARE_CONSTRAINTSt
   DIRECT_REFt   CONSTRAINTSt
   EXTRA_LISTt   EXTRASt   REQUIREMENTR/   t   RELOP_IDENTR2   R>   RX   R_   Rc   R.   Rk   Rn   R   R   t   contextmanagerR   R   R   R   R   R   R   R  R  t   VERBOSER  R}   R'  R)  R+  R0  R2  R6  t   IR<  R7  RA  RC  RD  RK  RS  RU  RV  RX  RY  Ra  Rm  t   ARCHIVE_EXTENSIONSR]   R  R  R  R  R  R  R  R  R  R  Rv   R  R  R
  R  R  R  R   R!  R)  R.  R2  RA  (    (    (    si   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/_vendor/distlib/util.pyt   <module>   s   
.	%		
				/	
				)					
						,H 6	]		!*)		: