
вEbc           @@  sM  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 m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d	 l m Z m Z m Z m Z m Z d  d
 l  m! Z" d  d l# m$ Z% d  d l& m' Z' d  d l( m) Z) d  d l* m+ Z+ m, Z, m- Z- d  d l. m/ Z/ m0 Z0 m1 Z1 m2 Z2 d  d l3 m4 Z4 m5 Z5 d  d l6 m7 Z7 m8 Z8 e rd  d l m9 Z: n d  d l m: Z: e4 rd  d l; m< Z< m= Z= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD mE ZE mF ZF mG ZG d  d lH mI ZI eE eJ eJ eJ f ZK eF d  ZL n  d d d d d d d d d d  d! d" d# d$ g ZM e jN eO  ZP d%   ZQ d&   ZR d'   ZS d(   ZT e d) d* d+ d,  eU d-   ZV d.   ZW d/   ZX d0   ZY d1 d2  ZZ d3   Z[ d4   Z\ d5   Z] d6   Z^ d7   Z_ d8   Z` d9   Za d:   Zb e jc d;  Zd ee d<  Zf d=   Zg d>   Zh d?   Zi d@   Zj dA   Zk dB   Zl dC   Zm ee e1 ee eU eU d dD  Zo dE   Zp dF   Zq dG   Zr dH   Zs dI   Zt dJ eu f dK     YZv dL e: f dM     YZw e jx dN    Zy dO   Zz dP   Z{ d dQ  Z| dR   Z} dS   Z~ dT   Z dU dV  Z dW   Z dX   Z dY   Z dZ   Z d[   Z d\   Z d]   Z d^   Z d_   Z d` eu f da     YZ db   Z dc   Z dd   Z de   Z dl dh  Z di   Z dj   Z dk   Z d S(m   i    (   t   absolute_importN(   t   deque(   t   tee(   t   pkg_resources(   t   canonicalize_name(   t   retry(   t   PY2t	   text_type(   t   filtert   filterfalset   inputt   mapt   zip_longest(   t   parse(   t   unquote(   t   __version__(   t   CommandError(   t   get_major_minor_versiont   site_packagest	   user_site(   t   WINDOWSt
   expandusert   stdlib_pkgst   str_to_display(   t   MYPY_CHECK_RUNNINGt   cast(   t   running_under_virtualenvt   virtualenv_no_global(   t   BytesIO(   t   StringIO(   t   Anyt   AnyStrt   Callablet	   Containert   Iterablet   Iteratort   Listt   Optionalt   Textt   Tuplet   TypeVart   Union(   t   Distributiont   Tt   rmtreet   display_patht
   backup_dirt   askt   splitextt   format_sizet   is_installable_dirt   normalize_patht   renamest   get_progt   captured_stdoutt
   ensure_dirt   get_installed_versiont   remove_auth_from_urlc          C@  sL   t  j j t  j j t  d d  }  t  j j |   }  d j t |  t    S(   Ns   ..s   pip {} from {} (python {})(	   t   ost   patht   joint   dirnamet   __file__t   abspatht   formatR   R   (   t   pip_pkg_dir(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   get_pip_versionQ   s    $c         C@  sY   t  |   d k  r- |  d t  |   d 7}  n t  |   d k rL |  d  }  n  t d |   S(   sx  
    Convert a tuple of ints representing a Python version to one of length
    three.

    :param py_version_info: a tuple of ints representing a Python version,
        or None to specify no version. The tuple can have any length.

    :return: a tuple of length three if `py_version_info` is non-None.
        Otherwise, return `py_version_info` unchanged (i.e. None).
    i   i    t   VersionInfo(   i    (   t   lenR   (   t   py_version_info(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   normalize_version_info]   s
    c         C@  sU   y t  j |   Wn= t k
 rP } | j t j k rQ | j t j k rQ   qQ n Xd S(   s    os.path.makedirs without EEXIST.N(   R:   t   makedirst   OSErrort   errnot   EEXISTt	   ENOTEMPTY(   R;   t   e(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR7   q   s
    $c          C@  s^   y= t  j j t j d  }  |  d k r8 d j t j  S|  SWn t t t	 f k
 rY n Xd S(   Ni    s   __main__.pys   -cs	   {} -m pipt   pip(   s   __main__.pys   -c(
   R:   R;   t   basenamet   syst   argvR@   t
   executablet   AttributeErrort	   TypeErrort
   IndexError(   t   prog(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR5   |   s    t   stop_max_delayi  t
   wait_fixedi  c         C@  s   t  j |  d | d t d  S(   Nt   ignore_errorst   onerror(   t   shutilR,   t   rmtree_errorhandler(   t   dirRX   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR,      s    c         C@  sg   y t  j |  j t j @} Wn t t f k
 r8 d SX| r` t  j | t j  |  |  d S  d S(   s   On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems.N(   R:   t   statt   st_modet   S_IWRITEt   IOErrorRH   t   chmod(   t   funcR;   t   exc_infot   has_attr_readonly(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR[      s    
c         C@  s   |  d k r d St |  t  r# |  Sy |  j t j   d  } Wn; t k
 r| t rm t d j	 |    } q} t
 |   } n X| S(   s   
    Convert a bytes (or text) path to text (unicode in Python 2) for display
    and logging purposes.

    This function should never error out. Also, this function is mainly needed
    for Python 2 since in Python 3 str paths are already text.
    t   stricts   b{!r}N(   t   Nonet
   isinstanceR   t   decodeRO   t   getfilesystemencodingt   UnicodeDecodeErrorR   R   R@   t   ascii(   R;   R-   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   path_to_display   s    	c         C@  s   t  j j t  j j |    }  t j d d k rd |  j t j   d  }  |  j t j	   d  }  n  |  j
 t  j   t  j j  r d |  t t  j    }  n  |  S(   sT   Gives the display value for a given path, making it relative to cwd
    if possible.i    i   t   replacet   .(   R:   R;   t   normcaseR?   RO   t   version_infoRh   Ri   t   encodet   getdefaultencodingt
   startswitht   getcwdt   sepRD   (   R;   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR-      s    s   .bakc         C@  sK   d } | } x4 t  j j |  |  rB | d 7} | t |  } q W|  | S(   s\   Figure out the name of a directory to back up the given dir to
    (adding .bak, .bak2, etc)i   (   R:   R;   t   existst   str(   R\   t   extt   nt	   extension(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR.      s    
c         C@  sC   x3 t  j j d d  j   D] } | | k r | Sq Wt |  |  S(   Nt   PIP_EXISTS_ACTIONt    (   R:   t   environt   gett   splitR/   (   t   messaget   optionst   action(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   ask_path_exists   s    "c         C@  s.   t  j j d  r* t d j |     n  d S(   s&   Raise an error if no input is allowed.t   PIP_NO_INPUTs7   No input was expected ($PIP_NO_INPUT set); question: {}N(   R:   R}   R~   t	   ExceptionR@   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   _check_no_input   s    c         C@  s`   xY t  |   t |   } | j   j   } | | k rT d j | d j |   GHq | Sq Wd S(   s@   Ask the message interactively, with the given possible responsess>   Your response ({!r}) was not one of the expected responses: {}s   , N(   R   R
   t   stript   lowerR@   R<   (   R   R   t   response(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR/      s    
c         C@  s   t  |   t |   S(   s   Ask for input interactively.(   R   R
   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt	   ask_input  s    
c         C@  s   t  |   t j |   S(   s!   Ask for a password interactively.(   R   t   getpass(   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   ask_password	  s    
c         C@  sx   |  d k r! d j  |  d d  S|  d	 k rD d j  t |  d   S|  d k ra d j  |  d  Sd j  t |    Sd  S(
   Ni  s	   {:.1f} MBg     @@i
   s   {} kBs	   {:.1f} kBs   {} bytesi@B i'  (   R@   t   int(   t   bytes(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR1     s    c         C@  s   g  |  D] } t  t t |   ^ q }  g  t d d |   D] } t t t |   ^ q; } g  |  D]* } d j t t j | |   j   ^ qc } | | f S(   s   Return a list of formatted rows and a list of column sizes.

    For example::

    >>> tabulate([['foobar', 2000], [0xdeadbeef]])
    (['foobar     2000', '3735928559'], [10, 4])
    t	   fillvalueR|   t    (	   t   tupleR   Rw   R   t   maxRD   R<   t   ljustt   rstrip(   t   rowst   rowt   colt   sizest   table(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   tabulate  s    	(47c         C@  sp   t  j j |   s t St  j j |  d  } t  j j |  rA t St  j j |  d  } t  j j |  rl t St S(   sB   Is path is a directory containing setup.py or pyproject.toml?
    s   setup.pys   pyproject.toml(   R:   R;   t   isdirt   FalseR<   t   isfilet   True(   R;   t   setup_pyt   pyproject_toml(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR2   +  s    c         c@  s/   x( t  r* |  j |  } | s" Pn  | Vq Wd S(   s7   Yield pieces of data from a file-like object until EOF.N(   R   t   read(   t   filet   sizet   chunk(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   read_chunks:  s
    	c         C@  sI   t  |   }  | r' t j j |   }  n t j j |   }  t j j |   S(   sN   
    Convert a path to its canonical, case-normalized, absolute version.

    (   R   R:   R;   t   realpathR?   Ro   (   R;   t   resolve_symlinks(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR3   C  s
    c         C@  sO   t  j |   \ } } | j   j d  rE | d | } | d  } n  | | f S(   s,   Like os.path.splitext, but take off .tar toos   .tari(   t	   posixpathR0   R   t   endswith(   R;   t   baseRx   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR0   Q  s
    c         C@  s   t  j j |  \ } } | rG | rG t  j j |  rG t  j |  n  t j |  |  t  j j |   \ } } | r | r y t  j |  Wq t k
 r q Xn  d S(   s7   Like os.renames(), but handles renaming across devices.N(	   R:   R;   R   Rv   RG   RZ   t   movet
   removedirsRH   (   t   oldt   newt   headt   tail(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR4   [  s    c         C@  s#   t    s t S|  j t t j   S(   s   
    Return True if path is within sys.prefix, if we're running in a virtualenv.

    If we're not in a virtualenv, all paths are considered "local."

    Caution: this function assumes the head of path has been normalized
    with normalize_path.
    (   R   R   Rs   R3   RO   t   prefix(   R;   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   is_localm  s    
	c         C@  s   t  t |    S(   s   
    Return True if given Distribution object is installed locally
    (i.e. within current virtualenv).

    Always True if we're not in a virtualenv.

    (   R   t   dist_location(   t   dist(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   dist_is_local|  s    	c         C@  s   t  |   j t t   S(   sF   
    Return True if given Distribution is installed in user site.
    (   R   Rs   R3   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   dist_in_usersite  s    c         C@  s   t  |   j t t   S(   s[   
    Return True if given Distribution is installed in
    sysconfig.get_python_lib().
    (   R   Rs   R3   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   dist_in_site_packages  s    c         C@  sJ   xC t  j D]8 } t j j | |  j d  } t j j |  r
 t Sq
 Wt S(   sC   
    Return True if given Distribution is an editable install.
    s	   .egg-link(   RO   R;   R:   R<   t   project_nameR   R   R   (   R   t	   path_itemt   egg_link(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   dist_is_editable  s
    c         C@  s   | r t  j |  } n	 t  j } |  r0 t } n	 d   } | rK d   } n	 d   } | rf d   }	 n	 d   }	 | r~ t }
 n	 d   }
 g  | D]K } | |  r | j | k r | |  r |	 |  r |
 |  r | ^ q S(   s^  
    Return a list of installed Distribution objects.

    If ``local_only`` is True (default), only return installations
    local to the current virtualenv, if in a virtualenv.

    ``skip`` argument is an iterable of lower-case project names to
    ignore; defaults to stdlib_pkgs

    If ``include_editables`` is False, don't report editables.

    If ``editables_only`` is True , only report editables.

    If ``user_only`` is True , only report installations in the user
    site directory.

    If ``paths`` is set, only report the distributions present at the
    specified list of locations.
    c         S@  s   t  S(   N(   R   (   t   d(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt
   local_test  s    c         S@  s   t  S(   N(   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   editable_test  s    c         S@  s   t  |   S(   N(   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR     s    c         S@  s
   t  |   S(   N(   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   editables_only_test  s    c         S@  s   t  S(   N(   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR     s    c         S@  s   t  S(   N(   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt	   user_test  s    (   R   t
   WorkingSett   working_setR   R   t   key(   t
   local_onlyt   skipt   include_editablest   editables_onlyt	   user_onlyt   pathsR   R   R   R   R   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   get_installed_distributions  s*    							c         C@  sV   t  |   }  t d t d d d t d t d t d d	  } d   | D } | j |   S(
   s   Find a distribution matching the ``req_name`` in the environment.

    This searches from *all* distributions available in the environment, to
    match the behavior of ``pkg_resources.get_distribution()``.
    R   R   R   R   R   R   c         S@  s"   i  |  ] } | t  | j   q S(    (   R   R   (   t   .0t   p(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pys
   <dictcomp>  s   	 (    N(   R   R   R   R   Rf   R~   (   t   req_namet   packagest   pkg_dict(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   _search_distribution  s    
	c         C@  sK   t  |   } | sA y t j j |   WqA t j k
 r= d SXn  t  |   S(   s   Given a requirement name, return the installed Distribution object.

    This searches from *all* distributions available in the environment, to
    match the behavior of ``pkg_resources.get_distribution()``.
    N(   R   R   R   t   requiret   DistributionNotFoundRf   (   R   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   get_distribution   s    	c         C@  s   g  } t    r? | j t  t   rb t rb | j t  qb n# t rU | j t  n  | j t  x@ | D]8 } t j j | |  j  d } t j j	 |  ri | Sqi Wd S(   s  
    Return the path for the .egg-link file if it exists, otherwise, None.

    There's 3 scenarios:
    1) not in a virtualenv
       try to find in site.USER_SITE, then site_packages
    2) in a no-global virtualenv
       try to find in site_packages
    3) in a yes-global virtualenv
       try to find in site_packages, then site.USER_SITE
       (don't look in global location)

    For #1 and #3, there could be odd cases, where there's an egg-link in 2
    locations.

    This method will just return the first one found.
    s	   .egg-linkN(   R   t   appendR   R   R   R:   R;   R<   R   R   Rf   (   R   t   sitest   sitet   egglink(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   egg_link_path  s    	c         C@  s)   t  |   } | r t |  St |  j  S(   sO  
    Get the site-packages location of this distribution. Generally
    this is dist.location, except in the case of develop-installed
    packages, where dist.location is the source code location, and we
    want to know where the egg-link file is.

    The returned location is normalized (in particular, with symlinks removed).
    (   R   R3   t   location(   R   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR   @  s    

c         G@  s   t  j |  |  d  S(   N(   t   loggert   info(   t   msgt   args(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   write_outputP  s    t   FakeFilec           B@  s)   e  Z d  Z d   Z d   Z d   Z RS(   sQ   Wrap a list of lines in an object with readline() to make
    ConfigParser happy.c         C@  s   t  |  |  _ d  S(   N(   t   itert   _gen(   t   selft   lines(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   __init__X  s    c         C@  s*   y t  |  j  SWn t k
 r% d SXd  S(   NR|   (   t   nextR   t   StopIteration(   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   readline[  s    c         C@  s   |  j  S(   N(   R   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   __iter__a  s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR   U  s   		t   StreamWrapperc           B@  s&   e  Z e d     Z e d    Z RS(   c         C@  s   | |  _  |    S(   N(   t   orig_stream(   t   clsR   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   from_streamg  s    	c         C@  s
   |  j  j S(   N(   R   t   encoding(   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR   m  s    (   R   R   t   classmethodR   t   propertyR   (    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR   e  s   c         c@  sR   t  t |   } t t |  t j |   z t  t |   VWd t t |  |  Xd S(   s   Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.

    Taken from Lib/support/__init__.py in the CPython repo.
    N(   t   getattrRO   t   setattrR   R   (   t   stream_namet   orig_stdout(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   captured_outputr  s
    c           C@  s
   t  d  S(   s   Capture the output of sys.stdout:

       with captured_stdout() as stdout:
           print('hello')
       self.assertEqual(stdout.getvalue(), 'hello
')

    Taken from Lib/support/__init__.py in the CPython repo.
    t   stdout(   R   (    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR6     s    	c           C@  s
   t  d  S(   s    
    See captured_stdout().
    t   stderr(   R   (    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   captured_stderr  s    c         C@  sM   t  j j |   } | d k r- t  j   } n  | j |  } | rI | j Sd S(   sC   Get the installed version of dist_name avoiding pkg_resources cacheN(   R   t   RequirementR   Rf   R   t   findt   version(   t	   dist_nameR   t   reqR   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR8     s
    c         C@  s   t  |  d d d S(   s   Consume an iterable at C speed.t   maxleni    N(   R   (   t   iterator(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   consume  s    c          O@  sT   t  t |  t t |     |  } d   | j   D } | | d <t d d |  S(   Nc         S@  s   i  |  ] \ } } | |  q S(    (    (   R   R   t   value(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pys
   <dictcomp>  s   	 t   reverse_mappingt   Enum(    (   t   dictt   zipt   rangeRD   t   itemst   type(   t
   sequentialt   namedt   enumst   reverse(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   enum  s    $
c         C@  s>   | d k r |  Sd |  k r. d j |   }  n  d j |  |  S(   s.   
    Build a netloc from a host-port pair
    t   :s   [{}]s   {}:{}N(   Rf   R@   (   t   hostt   port(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   build_netloc  s
    t   httpsc         C@  sO   |  j  d  d k r? d |  k r? d |  k r? d j |   }  n  d j | |   S(   s)   
    Build a full URL from a netloc.
    R  i   t   @t   [s   [{}]s   {}://{}(   t   countR@   (   t   netloct   scheme(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   build_url_from_netloc  s    -c         C@  s+   t  |   } t j |  } | j | j f S(   s2   
    Return the host-port pair from a netloc.
    (   R  t   urllib_parset   urlparset   hostnameR  (   R  t   urlt   parsed(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   parse_netloc  s    c         C@  s{   d |  k r |  d f S|  j d d  \ } }  d | k rO | j d d  } n | d f } t d   | D  } |  | f S(   sp   
    Parse out and remove the auth information from a netloc.

    Returns: (netloc, (username, password)).
    R  i   R  c         s@  s-   |  ]# } | d  k r d  n	 t |  Vq d  S(   N(   Rf   t   urllib_unquote(   R   t   x(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pys	   <genexpr>  s    N(   NN(   Rf   t   rsplitR   R   (   R  t   autht	   user_pass(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   split_auth_from_netloc  s    
c         C@  st   t  |   \ }  \ } } | d k r( |  S| d k rC d } d } n t j |  } d } d j d | d | d |   S(	   s   
    Replace the sensitive data in a netloc with "****", if it exists.

    For example:
        - "user:pass@example.com" returns "user:****@example.com"
        - "accesstoken@example.com" returns "****@example.com"
    s   ****R|   s   :****s   {user}{password}@{netloc}t   usert   passwordR  N(   R&  Rf   R  t   quoteR@   (   R  R'  R(  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   redact_netloc  s    		c         C@  s\   t  j |   } | | j  } | j | d | j | j | j f } t  j |  } | | f S(   sR  Transform and replace netloc in a url.

    transform_netloc is a function taking the netloc and returning a
    tuple. The first element of this tuple is the new netloc. The
    entire tuple is returned.

    Returns a tuple containing the transformed url as item 0 and the
    original tuple returned by transform_netloc as item 1.
    i    (   R  t   urlsplitR  R  R;   t   queryt   fragmentt
   urlunsplit(   R  t   transform_netloct   purlt   netloc_tuplet
   url_piecest   surl(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   _transform_url  s
    
%c         C@  s
   t  |   S(   N(   R&  (   R  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   _get_netloc  s    c         C@  s   t  |   f S(   N(   R*  (   R  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   _redact_netloc   s    c         C@  s(   t  |  t  \ } \ } } | | | f S(   s   
    Parse a url into separate netloc, auth, and url with no auth.

    Returns: (url_without_auth, netloc, (username, password))
    (   R4  R5  (   R  t   url_without_authR  R$  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   split_auth_netloc_from_url$  s    c         C@  s   t  |  t  d S(   s7   Return a copy of url with 'username:password@' removed.i    (   R4  R5  (   R  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR9   /  s    c         C@  s   t  |  t  d S(   s.   Replace the password in a given url with ****.i    (   R4  R6  (   R  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   redact_auth_from_url7  s    t
   HiddenTextc           B@  s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C@  s   | |  _  | |  _ d  S(   N(   t   secrett   redacted(   R   R;  R<  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR   >  s    	c         C@  s   d j  t |    S(   Ns   <HiddenText {!r}>(   R@   Rw   (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   __repr__G  s    c         C@  s   |  j  S(   N(   R<  (   R   (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   __str__K  s    c         C@  s,   t  |   t  |  k r t S|  j | j k S(   N(   R
  R   R;  (   R   t   other(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   __eq__P  s    c         C@  s   |  | k S(   N(    (   R   R?  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   __ne__[  s    (   R   R   R   R=  R>  R@  RA  (    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyR:  =  s
   					c         C@  s   t  |  d d S(   NR<  s   ****(   R:  (   R  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt
   hide_value`  s    c         C@  s   t  |   } t |  d | S(   NR<  (   R9  R:  (   R  R<  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   hide_urle  s    c         C@  s   d d j  t j d  d j  t j d    g } |  oW t oW t j j t j d  | k } | r t j d d g t j d } t	 d	 j  d
 j
 |     n  d S(   s   Protection of pip.exe from modification on Windows

    On Windows, any operation modifying pip should be run as:
        python -m pip ...
    s   pip.exes	   pip{}.exei    s   pip{}.{}.exei   s   -mRM   i   s3   To modify pip, please run the following command:
{}R   N(   R@   RO   Rp   R   R:   R;   RN   RP   RQ   R   R<   (   t   modifying_pipt	   pip_namest   should_show_use_python_msgt   new_command(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt(   protect_pip_from_modification_on_windowsk  s    c           C@  s   t  j d k	 o t  j j   S(   s!   Is this console interactive?
    N(   RO   t   stdinRf   t   isatty(    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   is_console_interactive  s    i   i   c         C@  sn   t  j   } d } t |  d  A } x7 t | d | D]# } | t |  7} | j |  q7 WWd QX| | f S(   s:   Return (hash, length) for path using hashlib.sha256()
    i    t   rbR   N(   t   hashlibt   sha256t   openR   RD   t   update(   R;   t	   blocksizet   ht   lengtht   ft   block(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt	   hash_file  s    c          C@  s)   y d d l  }  Wn t k
 r$ t SXt S(   s8   
    Return whether the wheel package is installed.
    i    N(   t   wheelt   ImportErrorR   R   (   RW  (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   is_wheel_installed  s
    c         C@  s   t  |   }  t |  |   S(   sb   
    Return paired elements.

    For example:
        s -> (s0, s1), (s2, s3), (s4, s5), ...
    (   R   R   (   t   iterable(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   pairwise  s    c         C@  s.   t  |  \ } } t |  |  t |  |  f S(   s   
    Use a predicate to partition entries into false entries and true entries,
    like

        partition(is_odd, range(10)) --> 0 2 4 6 8   and  1 3 5 7 9
    (   R   R	   R   (   t   predRZ  t   t1t   t2(    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt	   partition  s    i   (   t
   __future__R    t
   contextlibRI   R   RM  t   iot   loggingR:   R   RZ   R]   RO   t   collectionsR   t	   itertoolsR   t   pip._vendorR   t   pip._vendor.packaging.utilsR   t   pip._vendor.retryingR   t   pip._vendor.sixR   R   t   pip._vendor.six.movesR   R	   R
   R   R   t   pip._vendor.six.moves.urllibR   R  t"   pip._vendor.six.moves.urllib.parseR   R!  RM   R   t   pip._internal.exceptionsR   t   pip._internal.locationsR   R   R   t   pip._internal.utils.compatR   R   R   R   t   pip._internal.utils.typingR   R   t   pip._internal.utils.virtualenvR   R   R   R   t   typingR   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   t   pip._vendor.pkg_resourcesR*   R   RC   R+   t   __all__t	   getLoggerR   R   RB   RF   R7   R5   R   R,   R[   Rl   R-   R.   R   R   R/   R   R   R1   R   R2   t   DEFAULT_BUFFER_SIZER   R   R3   R0   R4   R   R   R   R   R   Rf   R   R   R   R   R   R   t   objectR   R   t   contextmanagerR   R6   R   R8   R  R  R  R  R   R&  R*  R4  R5  R6  R8  R9   R9  R:  RB  RC  RH  RK  RV  RY  R[  R_  (    (    (    s5   /tmp/pip-build-UPPWic/pip/pip/_internal/utils/misc.pyt   <module>   s   ("R							"			
								
							>			$								
								#						