???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................
abc           @   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 y d  d l Z Wn e k
 r d Z n Xd  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
 r9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 e
 j1 e2  Z3 d Z4 e j5 e4  Z6 d Z7 d	 e7 d
 Z8 e7 d Z9 d Z: d e: d e9 d e4 d e: d e9 d Z; d Z< d e; d e< d e; d Z= e8 d e4 e8 d Z> d e> d Z? d e7 d e? d e= d Z@ e j5 e@  ZA d e: d e9 d
 ZB e j5 eB  ZC d   ZD d    ZE d!   ZF d"   ZG d d d#  ZH d$   ZI d%   ZJ d&   ZK e jL d'    ZM e jL d(    ZN e jL d) d*   ZO d+ eP f d,     YZQ d-   ZR d. eP f d/     YZS d0   ZT d1 eP f d2     YZU e j5 d3 e jV  ZW d4   ZX d d5  ZY d6   ZZ d7   Z[ d8   Z\ d9   Z] d:   Z^ e j5 d; e j_  Z` e j5 d<  Za d d=  Zb e j5 d>  Zc d?   Zd d@   Ze dA   Zf dB Zg dC   Zh dD   Zi dE eP f dF     YZj dG eP f dH     YZk dI eP f dJ     YZl d Zm d en dR  Zo dS   Zp d Zq dZ eP f d[     YZr e j5 d\  Zs e j5 d]  Zt e j5 d^  Zu d_   Z d`   Zv e rd da l mw Zx my Zy mz Zz db e% j{ f dc     YZ{ dd ex f de     YZw df ew e( f dg     YZ| n  e j} dh  Z~ e~ d k rdj e% j f dk     YZ e rdl e% j f dm     YZ qn  dn e& j f do     YZ e rFdp e& j f dq     YZ n  dr e& j f ds     YZ dt   Z du eP f dv     YZ dw e f dx     YZ dy e f dz     YZ d{ e) f d|     YZ d} eP f d~     YZ d   Z 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   BaseConfiguratort   valid_identt	   Containert   configparsert   URLErrort   ZipFilet   fsdecodet   unquotes   \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(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   get_constraintY   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(   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   parse_requirementW   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   baseR@   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   get_rel_path   s    R=   N(	   R?   R@   R2   R   R,   t   popR>   RA   t   rstrip(   t   resources_roott   rulesRG   t   destinationsRF   t   suffixt   destt   prefixt   abs_baset   abs_globt   abs_patht   resource_filet   rel_patht   rel_dest(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   get_resources_dests|   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   TrueRO   t   getattr(   R6   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   in_venv   s    	c          C   s7   t  j j t j  }  t |  t  s3 t |   }  n  |  S(   N(   R?   R@   t   normcaseRZ   t
   executablet
   isinstanceR   R   (   R6   (    (    s<   /usr/lib/python2.7/site-packages/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   pR5   t   c(    (    s<   /usr/lib/python2.7/site-packages/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(   R`   R   R4   (   R   t   keysR6   t   key(    (    s<   /usr/lib/python2.7/site-packages/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(   RY   Ro   t   readfp(   t   cpt   stream(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   read_stream   s    (   RZ   t   version_infot   codecst	   getreadert   readR   t   jsont   loadt   itemst   get_export_entryR,   RC   t	   Exceptiont   seekR   t   ConfigParsert   MissingSectionHeaderErrort   closet   textwrapt   dedentt   sections(   Rr   t   datat   jdataR6   t   groupt   entriest   kt   vR5   t   entryRs   Rq   Rk   R&   t   value(    (    s<   /usr/lib/python2.7/site-packages/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   , (   RZ   Rt   Ru   t	   getwriterR   R~   Rz   t   add_sectiont   valuesRM   R,   RO   t   flagsR2   t   setR&   t   write(   Rn   Rr   Rq   R   R   R   R5   (    (    s<   /usr/lib/python2.7/site-packages/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(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   tempdir  s    	c         c   s7   t  j   } z t  j |   d  VWd  t  j |  Xd  S(   N(   R?   t   getcwdt   chdir(   R   t   cwd(    (    s<   /usr/lib/python2.7/site-packages/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(    (    s<   /usr/lib/python2.7/site-packages/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   (    (    s<   /usr/lib/python2.7/site-packages/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   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   __get__.  s
    N(   R   t
   __module__R   R,   R   (    (    (    s<   /usr/lib/python2.7/site-packages/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 '/'(   R?   RA   t
   ValueErrorR4   t   curdirt   removeR@   R2   (   t   pathnamet   paths(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   convert_path6  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   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   R  s    	c         C   s%   t  |  _ t   |  _ t   |  _ d  S(   N(   t   Falset   recordR   t   files_writtent   dirs_created(   R   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   W  s    	c         C   s    |  j  r |  j j |  n  d  S(   N(   R   R   t   add(   R   R@   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   record_as_written\  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(   R?   R@   t   existsR   t   abspathR[   t   statt   st_mtime(   R   R*   t   target(    (    s<   /usr/lib/python2.7/site-packages/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_dirR?   R@   t   dirnamet   loggert   infoR   R,   t   islinkR   t   isfileR   R   t   copyfileR   (   R   t   infilet   outfilet   checkt   msg(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt	   copy_filet  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(   R?   R@   t   isdirRC   R   R   R   R   R   R,   t   openRu   R   t   copyfileobjR   R   (   R   t   instreamR   R   t	   outstream(    (    s<   /usr/lib/python2.7/site-packages/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   R?   R@   R   R   R   R   R   (   R   R@   R   t   f(    (    s<   /usr/lib/python2.7/site-packages/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   R?   R@   R   R   R   R   t   encodeR   (   R   R@   R   R   R   (    (    s<   /usr/lib/python2.7/site-packages/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(	   R?   R&   t   _nameR   R   R   R   t   st_modet   chmod(   R   t   bitst   maskt   filesR   t   mode(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   set_mode  s    -	c         C   s   |  j  d d |  S(   Nim  i  (   R   (   R5   R   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   <lambda>  R$   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(   R?   R@   R   R   R   R   R4   R   R   R   R   t   mkdirR   R   (   R   R@   R   R   (    (    s<   /usr/lib/python2.7/site-packages/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,   RB   RC   RD   t
   py_compilet   compileR[   R   (   R   R@   t   optimizet   forceRO   t   dpatht   diagpath(    (    s<   /usr/lib/python2.7/site-packages/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(   R?   R@   R   R   R   R   t   debugR   R   R   R   R   R   R   (   R   R@   R5   (    (    s<   /usr/lib/python2.7/site-packages/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   R?   R@   R   t   accesst   W_OKR   (   R   R@   R6   t   parent(    (    s<   /usr/lib/python2.7/site-packages/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   RC   R   R   R   (   R   R6   (    (    s<   /usr/lib/python2.7/site-packages/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   R?   R@   R   R   t   sortedR   R[   t   listdirRC   R2   t   rmdirR   (   R   R   t   dirsR   t   flistt   sd(    (    s<   /usr/lib/python2.7/site-packages/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  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   Q  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    (   RZ   t   modulest
   __import__R,   R4   R\   RH   (   t   module_namet   dotted_patht   modR6   t   partsRg   (    (    s<   /usr/lib/python2.7/site-packages/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&   RO   RM   R   (   R   R&   RO   RM   R   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR     s    			c         C   s   t  |  j |  j  S(   N(   R
  RO   RM   (   R   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR     s    c         C   s    d |  j  |  j |  j |  j f S(   Ns   <ExportEntry %s = %s:%s %s>(   R&   RO   RM   R   (   R   (    (    s<   /usr/lib/python2.7/site-packages/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(   R`   R  R   R&   RO   RM   R   (   R   t   otherR6   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   __eq__%  s    	(	   R   R   R   R   R   R  R  R   t   __hash__(    (    (    s<   /usr/lib/python2.7/site-packages/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 '%s'R&   t   callablet   :i    i   R   t   ,(	   t   ENTRY_REt   searchR,   R   R   t   countR4   R/   R  (   t   specificationR   R6   R   R&   R@   t   colonsRO   RM   R   R   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR{   7  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,   R?   R&   t   environR@   t
   expandvarst
   expanduserR   R   R   R   t   warningt   makedirsR[   t   OSErrorR   R   R   R2   (   RM   R6   t   usable(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   get_cache_baseV  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(   R?   R@   t
   splitdriveR   R>   RA   (   R@   R   Rg   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   path_to_cache_dir  s
    
$c         C   s   |  j  d  s |  d S|  S(   NR=   (   t   endswith(   R5   (    (    s<   /usr/lib/python2.7/site-packages/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,   R4   (   t   netloct   usernamet   passwordRO   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   parse_credentials  s    
	c          C   s    t  j d  }  t  j |   |  S(   Ni   (   R?   t   umask(   R6   (    (    s<   /usr/lib/python2.7/site-packages/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	   enumerateR`   R   R   RC   (   t   seqR6   t   iR5   (    (    s<   /usr/lib/python2.7/site-packages/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 d d  }  t j |   } | r[ | 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
    t    t   -i   s   \bi   N(   R,   R   R>   t   PYTHON_VERSIONR  R   t   startRD   t   reR.   t   escapet   endt   PROJECT_NAME_AND_VERSION(   t   filenamet   project_nameR6   t   pyverR   t   n(    (    s<   /usr/lib/python2.7/site-packages/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_RER.   R   R   R/   Rb   (   Rg   R   R   (    (    s<   /usr/lib/python2.7/site-packages/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   *R6  i   s   undeclared extra: %s(   R   R   R   RB   R   R!  (   t	   requestedt	   availableR6   t   rt   unwanted(    (    s<   /usr/lib/python2.7/site-packages/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   getRB   R   R   Ru   Rv   Rx   Ry   R|   t	   exception(   R+   R6   t   respt   headerst   ctt   readert   e(    (    s<   /usr/lib/python2.7/site-packages/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_urlRR  (   R&   R+   R6   (    (    s<   /usr/lib/python2.7/site-packages/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    (   RS  R
   RT  RR  (   R&   t   versionR+   (    (    s<   /usr/lib/python2.7/site-packages/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(   R?   R@   R   R"  R   R   R   R!  R   t   normpathRF   (   R   RF   (    (    s<   /usr/lib/python2.7/site-packages/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   RO   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   prefix_to_dir0  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.
        (   R?   R   RF   R@   R2   R   R   R   R   R   R   R|   t   append(   R   t   not_removedt   fn(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   clear6  s    $(   R   R   t   __doc__R   RZ  R^  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyRX    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   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   K  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(   Ra  R    R[  t
   appendleft(   R   t   eventt
   subscriberR[  t   subst   sq(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   N  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(   Ra  R   R   (   R   Rc  Rd  Re  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   b  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   iterRa  RK  (   R   Rc  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   get_subscribersn  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(   Rh  R|   R   RL  R,   R[  R   (   R   Rc  t   argst   kwargsR6   Rd  R   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   publishu  s    
	(	   R   R   R_  R   R[   R   R   Rh  Rk  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR`  G  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   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR     s    		c         C   s   |  j  j |  d  S(   N(   Ro  R   (   R   t   node(    (    s<   /usr/lib/python2.7/site-packages/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(    (    (   Ro  R   R   Rm  RK  Rn  R   Rz   (   R   Rp  t   edgesRg   R5   R   R   (    (    s<   /usr/lib/python2.7/site-packages/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(   RC   Rm  t
   setdefaultR   R   Rn  (   R   t   predt   succ(    (    s<   /usr/lib/python2.7/site-packages/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(   RC   Rm  Rn  t   KeyErrorR   R   (   R   Ru  Rv  t   predst   succs(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR     s    c         C   s+   | |  j  k p* | |  j k p* | |  j k S(   N(   Rm  Rn  Ro  (   R   t   step(    (    s<   /usr/lib/python2.7/site-packages/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[  RH   R   R   Rm  RK  t   extendt   reversed(   R   t   finalR6   t   todot   seenRz  Rx  (    (    s<   /usr/lib/python2.7/site-packages/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[   RH   t   tuple(   Rp  t
   successorst	   successort   connected_componentt	   component(   t   grapht   indext   index_countert   lowlinksR6   t   stackt   strongconnect(    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR    s.    

"	 (   Rn  (   R   Rp  (    (   R  R  R  R  R6   R  R  s<   /usr/lib/python2.7/site-packages/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   
(   Rm  R[  Ro  R2   (   R   R6   Rv  Rx  Ru  Rp  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   dot
  s    	(   R   R   R   Rq  R   Rs  R   R   R{  R  t   propertyR  R  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyRl    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(
   R`   R   t   decodeR?   R@   R   R2   RB   RA   R   (   R@   Rg   (   t   dest_dirt   plen(    s<   /usr/lib/python2.7/site-packages/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   tarRH  s   Unknown format for %ri    i   s   utf-8(   s   .zips   .whl(   s   .tar.gzs   .tgz(   s   .tar.bz2s   .tbz(   R?   R@   R   RD   R,   R(  R   R   t   namelistt   tarfileR   t   getnamesRZ   Rt   t
   getmembersR`   R&   R   R  t
   extractallR   (
   t   archive_filenameR  t   formatR   R  t   archiveR   t   namesR&   t   tarinfo(    (   R  R  s<   /usr/lib/python2.7/site-packages/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   BytesIORD   R   R?   t   walkR@   R2   R   (   t	   directoryR6   t   dlent   zft   rootR   R   R&   t   fullt   relRN   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   zip_dirS  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,   RC   R  t   curt   maxt   startedt   elapsedR   t   done(   R   t   minvalt   maxval(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   j  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  RC   R  R,   R  t   timeR  R  (   R   t   curvalt   now(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   updater  s    $	c         C   s*   | d k s t   |  j |  j |  d  S(   Ni    (   RC   R  R  (   R   t   incr(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt	   increment|  s    c         C   s   |  j  |  j  |  S(   N(   R  R  (   R   (    (    s<   /usr/lib/python2.7/site-packages/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   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   stop  s    c         C   s   |  j  d  k r |  j S|  j  S(   N(   R  R,   t   unknown(   R   (    (    s<   /usr/lib/python2.7/site-packages/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   R6   R   (    (    s<   /usr/lib/python2.7/site-packages/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   durationR6   (    (    s<   /usr/lib/python2.7/site-packages/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   RO   t   t(    (    s<   /usr/lib/python2.7/site-packages/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   R6   t   unit(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   speed  s    	(   R   R   R  R   R  R  R8  R  R  R  R  R  R  R  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR  g  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   (    (    s<   /usr/lib/python2.7/site-packages/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_GLOBR4   RD   RC   R  R2   t	   std_iglobRE   R?   R  R@   RY  (   R  t   rich_path_globRO   R   RM   t   itemR@   t   radicalt   dirR   R]  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR    s*    %		"(   t   HTTPSHandlert   match_hostnamet   CertificateErrort   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   _tunnelRY   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   contextRj  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   connect  s>    !						N(   R   R   R,   R  R[   R  R  (    (    (    s<   /usr/lib/python2.7/site-packages/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  (    (    s<   /usr/lib/python2.7/site-packages/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   Ri  Rj  R6   (    (    s<   /usr/lib/python2.7/site-packages/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   reqRQ  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt
   https_open8  s    (   R   R   R[   R   R  R  (    (    (    s<   /usr/lib/python2.7/site-packages/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  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt	   http_openL  s    (   R   R   R  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR  K  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  Rj  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   X  s    	N(   R   R   R,   R   (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR	  W  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  Rj  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   `  s    	N(   R   R   R,   R   (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR  _  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(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   g  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   x509R6   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   make_connectionk  s    	(   R   R   R   R  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR  f  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  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR   x  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  Rj  R6   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR  |  s    		(   R   R   R   R  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR  w  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(   RH   R,   R  R   RK  R  R  R  R   R  R   (	   R   t   uriRj  R  t   schemet   _R  t   tclsR  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR     s    	(   R   R   R   (    (    (    s<   /usr/lib/python2.7/site-packages/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(   RZ   Rt   R   (   R]  R   Rj  (    (    s<   /usr/lib/python2.7/site-packages/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   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt	   __enter__  s    c         G   s   |  j  j   d  S(   N(   Rr   R   (   R   R  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   __exit__  s    (   R   R   R  t   defaultsR(  R)  (    (    (    s<   /usr/lib/python2.7/site-packages/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(   NRr   i    i   s   utf-8R@   RH  (	   RZ   Rt   Ru   Rv   Rr   R"  t   csvRP  R*  (   R   Rj  Rr   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR     s    
c         C   s   |  S(   N(    (   R   (    (    s<   /usr/lib/python2.7/site-packages/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   nextRP  RZ   Rt   R1  R`   R   R  (   R   R6   R3  R  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR.    s    (   R   R   R   R-  R.  t   __next__(    (    (    s<   /usr/lib/python2.7/site-packages/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"  Rr   R,  t   writerR*  (   R   R]  Rj  (    (    s<   /usr/lib/python2.7/site-packages/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(   RZ   Rt   R`   R   R   R[  R1  t   writerow(   R   t   rowRH  R  (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR2    s    	(   R   R   R   R2  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR0    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   superR4  R   R?   R   RF   (   R   t   configRF   (    (    s<   /usr/lib/python2.7/site-packages/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   ()(   R`   R   R  t   typet   dictt   configure_customt   convert(   t   oR3  R6   R   (   R<  R   (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR<    s    .s   ()R  s   [](    (	   RH   R  R
  R,   R  R   R:  Rz   t   setattr(   R   R8  Rh   t   propsRi  R=  R   Rz   Rj  R6   R@  R   (    (   R<  R   s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR;    s    (5c         C   sI   |  j  | } t | t  rE d | k rE |  j |  |  j  | <} n  | S(   Ns   ()(   R8  R`   R:  R;  (   R   Rk   R6   (    (    s<   /usr/lib/python2.7/site-packages/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.RH  R   s   utf-8N(	   R?   R@   t   isabsR2   RF   Ru   R   Rx   Ry   (   R   R   R   R6   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR5    s
    N(
   R   R   R:  R   t   value_convertersR,   R   R;  R@  R5  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyR4    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   RD  RE  (    (    s<   /usr/lib/python2.7/site-packages/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(   RE  RD  R[   t   readlineR,   RZ   t   stderrR   R  t   flushR   (   R   Rr   R  RE  RD  R5   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyRP  "  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   stdoutRG  R   Ri  s   done.t   mains   done.
(   t
   subprocesst   Popent   PIPEt	   threadingt   ThreadRP  RI  R8  RG  t   waitR2   RE  R,   RD  RZ   R   (   R   t   cmdRj  Rg   t   t1t   t2(    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   run_command7  s    $
$



	N(   R   R   R   R,   R   RP  RT  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyRC    s   	c         C   s   t  j d d |   j   S(   s,   Normalize a python package name a la PEP 503s   [-_.]+R6  (   R9  t   subRb   (   R&   (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   normalize_nameH  s    (   s   .tar.gzs   .tar.bz2s   .tars   .zips   .tgzs   .tbzs   .whl(   R$   R  R  R  R  R  (   i   i   (   Ru   t   collectionsR    t
   contextlibR,  t   globR   R  R  Rx   t   loggingR?   R   R9  R   R   R  t   ImportErrorR,   RK  RZ   R  R   R   RN  t   dummy_threadingR  R$   R   t   compatR   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   t	   getLoggerR   R   t   COMMAR   R3   t   IDENTt   EXTRA_IDENTt   VERSPECt   RELOPt   BARE_CONSTRAINTSt
   DIRECT_REFt   CONSTRAINTSt
   EXTRA_LISTt   EXTRASt   REQUIREMENTR-   t   RELOP_IDENTR0   R<   RV   R]   Ra   Ri   Rl   R   R   t   contextmanagerR   R   R   R   R   R   R   R
  R  t   VERBOSER  R{   R%  R'  R)  R.  R0  R4  t   IR<  R7  RA  RC  RD  RJ  RR  RT  RU  RW  RX  R`  Rl  t   ARCHIVE_EXTENSIONSR[   R  R  R  R  R  R  R  R  R  R   R  R  R  R  Rt   R  R	  R  R  R  R  R"  R#  R+  R0  R4  RC  RV  (    (    (    s<   /usr/lib/python2.7/site-packages/pip/_vendor/distlib/util.pyt   <module>   s   

.	%		
				/	
				)					
						,H 6	]		*)		:+