a
    Œ�éip  ã                   @   s  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/m0Z0m1Z1m2Z2 d dl3m4Z4m5Z5 d dl6m7Z7m8Z8 e�r\d dlm9Z: nd dlm:Z: e4�rÈd dl;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZG d dlHmIZI eEeJeJeJf ZKeFdƒZLg d¢ZMe NeO¡ZPdd„ ZQdd„ ZRdd„ ZSdd„ ZTed d!d"�d˜d$d%„ƒZUd&d'„ ZVd(d)„ ZWd*d+„ ZXd™d-d.„ZYd/d0„ ZZd1d2„ Z[d3d4„ Z\d5d6„ Z]d7d8„ Z^d9d:„ Z_d;d<„ Z`d=d>„ Zaejbfd?d@„ZcdšdBdC„ZddDdE„ ZedFdG„ ZfdHdI„ ZgdJdK„ ZhdLdM„ ZidNdO„ ZjdPdQ„ ZkdAe1dAd#d#dfdRdS„ZldTdU„ ZmdVdW„ ZndXdY„ ZodZd[„ Zpd\d]„ ZqG d^d_„ d_erƒZsG d`da„ dae:ƒZtejudbdc„ ƒZvddde„ Zwdfdg„ Zxd›dhdi„Zydjdk„ Zzdldm„ Z{dndo„ Z|dœdqdr„Z}dsdt„ Z~dudv„ Zdwdx„ Z€dydz„ Z�d{d|„ Z‚d}d~„ Zƒdd€„ Z„d�d‚„ Z…dƒd„„ Z†G d…d†„ d†erƒZ‡d‡dˆ„ Zˆd‰dŠ„ Z‰d‹dŒ„ ZŠd�dŽ„ Z‹d�d�d‘„ZŒd’d“„ Z�d”d•„ ZŽd–d—„ Z�dS )žé    )Úabsolute_importN©Údeque)Útee)Úpkg_resources)Úcanonicalize_name)Úretry)ÚPY2Ú	text_type)ÚfilterÚfilterfalseÚinputÚmapÚzip_longest)Úparse)Úunquote)Ú__version__)ÚCommandError)Úget_major_minor_versionÚsite_packagesÚ	user_site)ÚWINDOWSÚ
expanduserÚstdlib_pkgsÚstr_to_display)ÚMYPY_CHECK_RUNNINGÚcast)Úrunning_under_virtualenvÚvirtualenv_no_global)ÚBytesIO)ÚStringIO)ÚAnyÚAnyStrÚCallableÚ	ContainerÚIterableÚIteratorÚListÚOptionalÚTextÚTupleÚTypeVarÚUnion)ÚDistributionÚT)ÚrmtreeÚdisplay_pathÚ
backup_dirÚaskÚsplitextÚformat_sizeÚis_installable_dirÚnormalize_pathÚrenamesÚget_progÚcaptured_stdoutÚ
ensure_dirÚget_installed_versionÚremove_auth_from_urlc                  C   s4   t j t j t¡dd¡} t j | ¡} d t| tƒ ¡S )Nz..zpip {} from {} (python {}))	ÚosÚpathÚjoinÚdirnameÚ__file__ÚabspathÚformatr   r   )Úpip_pkg_dir© rE   úH/home/Claro/venv/lib/python3.9/site-packages/pip/_internal/utils/misc.pyÚget_pip_versionQ   s    ÿÿrG   c                 C   sD   t | ƒdk r"| dt | ƒ d 7 } nt | ƒdkr:| dd… } td| ƒS )ax  
    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).
    é   )r   NÚVersionInfo)Úlenr   )Úpy_version_inforE   rE   rF   Únormalize_version_info]   s
    rL   c              
   C   sR   zt  | ¡ W n> tyL } z&|jtjkr8|jtjkr8‚ W Y d}~n
d}~0 0 dS )z os.path.makedirs without EEXIST.N)r=   ÚmakedirsÚOSErrorÚerrnoÚEEXISTÚ	ENOTEMPTY)r>   ÚerE   rE   rF   r:   q   s
    r:   c               
   C   sP   z2t j tjd ¡} | dv r*d tj¡W S | W S W n ttt	fyJ   Y n0 dS )Nr   )z__main__.pyz-cz	{} -m pipÚpip)
r=   r>   ÚbasenameÚsysÚargvrC   Ú
executableÚAttributeErrorÚ	TypeErrorÚ
IndexError)ÚprogrE   rE   rF   r8   |   s    
r8   i¸  iô  )Ústop_max_delayÚ
wait_fixedFc                 C   s   t j| |td� d S )N)Úignore_errorsÚonerror)Úshutilr/   Úrmtree_errorhandler)Údirr^   rE   rE   rF   r/   Š   s    ÿr/   c              	   C   sV   zt  |¡jtj@  }W n ttfy0   Y dS 0 |rPt  |tj¡ | |ƒ dS ‚ dS )zÑ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=   ÚstatÚst_modeÚS_IWRITEÚIOErrorrN   Úchmod)Úfuncr>   Úexc_infoÚhas_attr_readonlyrE   rE   rF   ra   ‘   s    ra   c                 C   sb   | du rdS t | tƒr| S z|  t ¡ d¡}W n. ty\   trPtd | ¡ƒ}nt	| ƒ}Y n0 |S )zû
    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.
    NÚstrictzb{!r})
Ú
isinstancer
   ÚdecoderU   ÚgetfilesystemencodingÚUnicodeDecodeErrorr	   r   rC   Úascii)r>   r0   rE   rE   rF   Úpath_to_display¥   s    	
rq   c                 C   st   t j t j | ¡¡} tjd dkrB|  t ¡ d¡} |  t 	¡ d¡} |  
t  ¡ t jj ¡rpd| tt  ¡ ƒd…  } | S )zTGives the display value for a given path, making it relative to cwd
    if possible.r   é   ÚreplaceÚ.N)r=   r>   ÚnormcaserB   rU   Úversion_inform   rn   ÚencodeÚgetdefaultencodingÚ
startswithÚgetcwdÚseprJ   )r>   rE   rE   rF   r0   Ç   s    r0   ú.bakc                 C   s6   d}|}t j | | ¡r.|d7 }|t|ƒ }q| | S )z\Figure out the name of a directory to back up the given dir to
    (adding .bak, .bak2, etc)é   )r=   r>   ÚexistsÚstr)rb   ÚextÚnÚ	extensionrE   rE   rF   r1   Ô   s    r1   c                 C   s2   t j dd¡ ¡ D ]}||v r|  S qt| |ƒS )NÚPIP_EXISTS_ACTIONÚ )r=   ÚenvironÚgetÚsplitr2   )ÚmessageÚoptionsÚactionrE   rE   rF   Úask_path_existsà   s    
r‹   c                 C   s   t j d¡rtd | ¡ƒ‚dS )z&Raise an error if no input is allowed.ÚPIP_NO_INPUTz7No input was expected ($PIP_NO_INPUT set); question: {}N)r=   r…   r†   Ú	ExceptionrC   ©rˆ   rE   rE   rF   Ú_check_no_inputè   s    ÿÿr�   c                 C   sF   t | ƒ t| ƒ}| ¡  ¡ }||vr<td |d |¡¡ƒ q |S q dS )z@Ask the message interactively, with the given possible responsesz>Your response ({!r}) was not one of the expected responses: {}z, N)r�   r   ÚstripÚlowerÚprintrC   r?   )rˆ   r‰   ÚresponserE   rE   rF   r2   ò   s    
ÿÿr2   c                 C   s   t | ƒ t| ƒS )zAsk for input interactively.)r�   r   rŽ   rE   rE   rF   Ú	ask_input  s    r”   c                 C   s   t | ƒ t | ¡S )z!Ask for a password interactively.)r�   ÚgetpassrŽ   rE   rE   rF   Úask_password	  s    r–   c                 C   s\   | dkrd  | d d ¡S | dkr4d  t| d ƒ¡S | dkrJd  | d ¡S d  t| ƒ¡S d S )	Ni@B z	{:.1f} MBg     @�@iè  i'  z{} kBz	{:.1f} kBz{} bytes)rC   Úint)ÚbytesrE   rE   rF   r4     s    r4   c                    s@   dd„ | D ƒ} dd„ t | ddiŽD ƒ‰ ‡ fdd„| D ƒ}|ˆ fS )z¸Return a list of formatted rows and a list of column sizes.

    For example::

    >>> tabulate([['foobar', 2000], [0xdeadbeef]])
    (['foobar     2000', '3735928559'], [10, 4])
    c                 S   s   g | ]}t tt|ƒƒ‘qS rE   )Útupler   r   ©Ú.0ÚrowrE   rE   rF   Ú
<listcomp>%  ó    ztabulate.<locals>.<listcomp>c                 S   s   g | ]}t tt|ƒƒ‘qS rE   )Úmaxr   rJ   )r›   ÚcolrE   rE   rF   r�   &  rž   Ú	fillvaluer„   c                    s$   g | ]}d   ttj|ˆ ƒ¡ ¡ ‘qS )ú )r?   r   r   ÚljustÚrstriprš   ©ÚsizesrE   rF   r�   '  rž   )r   )ÚrowsÚtablerE   r¥   rF   Útabulate  s    	r©   c                 C   sP   t j | ¡sdS t j | d¡}t j |¡r.dS t j | d¡}t j |¡rLdS dS )zBIs path is a directory containing setup.py or pyproject.toml?
    Fzsetup.pyTzpyproject.toml)r=   r>   Úisdirr?   Úisfile)r>   Úsetup_pyÚpyproject_tomlrE   rE   rF   r5   +  s    r5   c                 c   s   |   |¡}|sq|V  q dS )z7Yield pieces of data from a file-like object until EOF.N)Úread)ÚfileÚsizeÚchunkrE   rE   rF   Úread_chunks:  s    
r²   Tc                 C   s2   t | ƒ} |rtj | ¡} ntj | ¡} tj | ¡S )zN
    Convert a path to its canonical, case-normalized, absolute version.

    )r   r=   r>   ÚrealpathrB   ru   )r>   Úresolve_symlinksrE   rE   rF   r6   C  s
    r6   c                 C   s@   t  | ¡\}}| ¡  d¡r8|dd… | }|dd… }||fS )z,Like os.path.splitext, but take off .tar tooz.taréüÿÿÿN)Ú	posixpathr3   r‘   Úendswith)r>   Úbaser€   rE   rE   rF   r3   Q  s
    r3   c                 C   sx   t j |¡\}}|r.|r.t j |¡s.t  |¡ t | |¡ t j | ¡\}}|rt|rtzt  |¡ W n tyr   Y n0 dS )z7Like os.renames(), but handles renaming across devices.N)	r=   r>   r‡   r~   rM   r`   ÚmoveÚ
removedirsrN   )ÚoldÚnewÚheadÚtailrE   rE   rF   r7   [  s    
r7   c                 C   sj   t | ƒ} d}tƒ r"|  t tjƒ¡S ddlm} |  |¡rb|dƒ ¡ D ]}|  t |ƒ¡rD dS qDdS dS dS )a£  
    Return True if this is a path pip is allowed to modify.

    If we're in a virtualenv, sys.prefix points to the virtualenv's
    prefix; only sys.prefix is considered local.

    If we're not in a virtualenv, in general we can modify anything.
    However, if the OS vendor has configured distutils to install
    somewhere other than sys.prefix (which could be a subdirectory of
    sys.prefix, e.g. /usr/local), we consider sys.prefix itself nonlocal
    and the domain of the OS vendor. (In other words, everything _other
    than_ sys.prefix is considered local.)

    Caution: this function assumes the head of path has been normalized
    with normalize_path.
    z/usrr   )Údistutils_schemer„   TFN)r6   r   ry   rU   ÚprefixÚpip._internal.locationsr¿   Úvalues)r>   rÀ   r¿   Ú
local_pathrE   rE   rF   Úis_localm  s    
rÄ   c                 C   s   t t| ƒƒS )zh
    Return True if given Distribution object is installed somewhere pip
    is allowed to modify.

    )rÄ   Údist_location©ÚdistrE   rE   rF   Údist_is_local‘  s    rÈ   c                 C   s   t | ƒ ttƒ¡S )zF
    Return True if given Distribution is installed in user site.
    )rÅ   ry   r6   r   rÆ   rE   rE   rF   Údist_in_usersite›  s    rÉ   c                 C   s   t | ƒ ttƒ¡S )z[
    Return True if given Distribution is installed in
    sysconfig.get_python_lib().
    )rÅ   ry   r6   r   rÆ   rE   rE   rF   Údist_in_site_packages£  s    rÊ   c                 C   s   t t| ƒƒS )zC
    Return True if given Distribution is an editable install.
    )ÚboolÚegg_link_pathrÆ   rE   rE   rF   Údist_is_editable¬  s    rÍ   c                    s€   |rt  |¡}nt j}| r t‰ndd„ ‰|r6dd„ ‰ ndd„ ‰ |rLdd„ ‰ndd„ ‰|r^t‰nd	d
„ ‰‡ ‡‡‡‡fdd„|D ƒS )a^  
    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   dS ©NTrE   ©ÚdrE   rE   rF   Ú
local_testØ  s    z/get_installed_distributions.<locals>.local_testc                 S   s   dS rÎ   rE   rÏ   rE   rE   rF   Úeditable_testÜ  s    z2get_installed_distributions.<locals>.editable_testc                 S   s
   t | ƒ S ©N©rÍ   rÏ   rE   rE   rF   rÒ   ß  s    c                 S   s   t | ƒS rÓ   rÔ   rÏ   rE   rE   rF   Úeditables_only_testã  s    z8get_installed_distributions.<locals>.editables_only_testc                 S   s   dS rÎ   rE   rÏ   rE   rE   rF   rÕ   æ  s    c                 S   s   dS rÎ   rE   rÏ   rE   rE   rF   Ú	user_testì  s    z.get_installed_distributions.<locals>.user_testc                    s:   g | ]2}ˆ|ƒr|j ˆvrˆ |ƒrˆ|ƒrˆ|ƒr|‘qS rE   )Úkey)r›   rÐ   ©rÒ   rÕ   rÑ   ÚskiprÖ   rE   rF   r�   ï  s   
ûz/get_installed_distributions.<locals>.<listcomp>)r   Ú
WorkingSetÚworking_setrÈ   rÉ   )Ú
local_onlyrÙ   Úinclude_editablesÚeditables_onlyÚ	user_onlyÚpathsrÛ   rE   rØ   rF   Úget_installed_distributions´  s     

rá   c                 C   s4   t | ƒ} tddddddd�}dd„ |D ƒ}| | ¡S )zÓ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()``.
    FrE   TN)rÜ   rÙ   rÝ   rÞ   rß   rà   c                 S   s   i | ]}t |jƒ|“qS rE   )r   r×   )r›   ÚprE   rE   rF   Ú
<dictcomp>  rž   z(_search_distribution.<locals>.<dictcomp>)r   rá   r†   )Úreq_nameÚpackagesÚpkg_dictrE   rE   rF   Ú_search_distributionø  s    
úrç   c                 C   s<   t | ƒ}|s4ztj | ¡ W n tjy2   Y dS 0 t | ƒS )zÕ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Û   ÚrequireÚDistributionNotFound)rä   rÇ   rE   rE   rF   Úget_distribution  s    	rê   c                 C   sx   g }t ƒ r*| t¡ tƒ sBtrB| t¡ ntr8| t¡ | t¡ |D ],}tj || j¡d }tj 	|¡rF|  S qFdS )a  
    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.
    z	.egg-linkN)
r   Úappendr   r   r   r=   r>   r?   Úproject_namer«   )rÇ   ÚsitesÚsiteÚegglinkrE   rE   rF   rÌ   +  s    




rÌ   c                 C   s   t | ƒ}|rt|ƒS t| jƒS )aO  
    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Ì   r6   Úlocation)rÇ   Úegg_linkrE   rE   rF   rÅ   O  s    
rÅ   c                 G   s   t j| g|¢R Ž  d S rÓ   )ÚloggerÚinfo)ÚmsgÚargsrE   rE   rF   Úwrite_output_  s    rö   c                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	ÚFakeFilezQWrap a list of lines in an object with readline() to make
    ConfigParser happy.c                 C   s   t |ƒ| _d S rÓ   )ÚiterÚ_gen)ÚselfÚlinesrE   rE   rF   Ú__init__g  s    zFakeFile.__init__c                 C   s&   zt | jƒW S  ty    Y dS 0 d S )Nr„   )Únextrù   ÚStopIteration©rú   rE   rE   rF   Úreadlinej  s    zFakeFile.readlinec                 C   s   | j S rÓ   )rù   rÿ   rE   rE   rF   Ú__iter__p  s    zFakeFile.__iter__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rü   r   r  rE   rE   rE   rF   r÷   d  s   r÷   c                   @   s$   e Zd Zedd„ ƒZedd„ ƒZdS )ÚStreamWrapperc                 C   s   || _ | ƒ S rÓ   )Úorig_stream)Úclsr  rE   rE   rF   Úfrom_streamv  s    zStreamWrapper.from_streamc                 C   s   | j jS rÓ   )r  Úencodingrÿ   rE   rE   rF   r
  |  s    zStreamWrapper.encodingN)r  r  r  Úclassmethodr	  Úpropertyr
  rE   rE   rE   rF   r  t  s   
r  c              
   c   sL   t t| ƒ}tt| t |¡ƒ zt t| ƒV  W tt| |ƒ ntt| |ƒ 0 dS )zË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)ÚgetattrrU   Úsetattrr  r	  )Ústream_nameÚorig_stdoutrE   rE   rF   Úcaptured_output�  s
    
r  c                   C   s   t dƒS )zÜ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.
    Ústdout©r  rE   rE   rE   rF   r9   �  s    	r9   c                   C   s   t dƒS )z 
    See captured_stdout().
    Ústderrr  rE   rE   rE   rF   Úcaptured_stderrœ  s    r  c                 C   s4   t j | ¡}|du rt  ¡ }| |¡}|r0|jS dS )zCGet the installed version of dist_name avoiding pkg_resources cacheN)r   ÚRequirementr   rÚ   ÚfindÚversion)Ú	dist_namerÛ   ÚreqrÇ   rE   rE   rF   r;   £  s
    
r;   c                 C   s   t | dd� dS )zConsume an iterable at C speed.r   )ÚmaxlenNr   )ÚiteratorrE   rE   rF   Úconsumeµ  s    r  c                  O   sD   t t| tt| ƒƒƒfi |¤Ž}dd„ | ¡ D ƒ}||d< tdd|ƒS )Nc                 S   s   i | ]\}}||“qS rE   rE   )r›   r×   ÚvaluerE   rE   rF   rã   ½  rž   zenum.<locals>.<dictcomp>Úreverse_mappingÚEnumrE   )ÚdictÚzipÚrangerJ   ÚitemsÚtype)Ú
sequentialÚnamedÚenumsÚreverserE   rE   rF   Úenum»  s    r*  c                 C   s*   |du r| S d| v rd  | ¡} d  | |¡S )z.
    Build a netloc from a host-port pair
    Nú:ú[{}]z{}:{})rC   )ÚhostÚportrE   rE   rF   Úbuild_netlocÂ  s
    
r/  Úhttpsc                 C   s4   |   d¡dkr(d| vr(d| vr(d | ¡} d || ¡S )z)
    Build a full URL from a netloc.
    r+  rr   ú@ú[r,  z{}://{})ÚcountrC   )ÚnetlocÚschemerE   rE   rF   Úbuild_url_from_netlocÏ  s    
r6  c                 C   s   t | ƒ}t |¡}|j|jfS )z2
    Return the host-port pair from a netloc.
    )r6  Úurllib_parseÚurlparseÚhostnamer.  )r4  ÚurlÚparsedrE   rE   rF   Úparse_netlocÚ  s    
r<  c                 C   sX   d| vr| dfS |   dd¡\}} d|v r6| dd¡}n|df}tdd„ |D ƒƒ}| |fS )zp
    Parse out and remove the auth information from a netloc.

    Returns: (netloc, (username, password)).
    r1  )NNr}   r+  Nc                 s   s"   | ]}|d u rd nt |ƒV  qd S rÓ   )Úurllib_unquote)r›   ÚxrE   rE   rF   Ú	<genexpr>ù  s   z)split_auth_from_netloc.<locals>.<genexpr>)Úrsplitr‡   r™   )r4  ÚauthÚ	user_passrE   rE   rF   Úsplit_auth_from_netlocä  s    ÿrC  c                 C   sL   t | ƒ\} \}}|du r| S |du r.d}d}nt |¡}d}dj||| d�S )zÞ
    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"
    Nú****r„   z:****z{user}{password}@{netloc})ÚuserÚpasswordr4  )rC  r7  ÚquoterC   )r4  rE  rF  rE   rE   rF   Úredact_netloc   s    	
þrH  c                 C   s@   t  | ¡}||jƒ}|j|d |j|j|jf}t  |¡}||fS )aR  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.
    r   )r7  Úurlsplitr4  r5  r>   ÚqueryÚfragmentÚ
urlunsplit)r:  Útransform_netlocÚpurlÚnetloc_tupleÚ
url_piecesÚsurlrE   rE   rF   Ú_transform_url  s    


ÿ
rR  c                 C   s   t | ƒS rÓ   )rC  ©r4  rE   rE   rF   Ú_get_netloc+  s    rT  c                 C   s
   t | ƒfS rÓ   )rH  rS  rE   rE   rF   Ú_redact_netloc/  s    rU  c                 C   s   t | tƒ\}\}}|||fS )z†
    Parse a url into separate netloc, auth, and url with no auth.

    Returns: (url_without_auth, netloc, (username, password))
    ©rR  rT  )r:  Úurl_without_authr4  rA  rE   rE   rF   Úsplit_auth_netloc_from_url3  s    rX  c                 C   s   t | tƒd S )z7Return a copy of url with 'username:password@' removed.r   rV  ©r:  rE   rE   rF   r<   >  s    r<   c                 C   s   t | tƒd S )z.Replace the password in a given url with ****.r   )rR  rU  rY  rE   rE   rF   Úredact_auth_from_urlF  s    rZ  c                   @   s4   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ ZdS )Ú
HiddenTextc                 C   s   || _ || _d S rÓ   )ÚsecretÚredacted)rú   r\  r]  rE   rE   rF   rü   M  s    zHiddenText.__init__c                 C   s   d  t| ƒ¡S )Nz<HiddenText {!r}>)rC   r   rÿ   rE   rE   rF   Ú__repr__V  s    zHiddenText.__repr__c                 C   s   | j S rÓ   ©r]  rÿ   rE   rE   rF   Ú__str__Z  s    zHiddenText.__str__c                 C   s    t | ƒt |ƒkrdS | j|jkS )NF)r%  r\  ©rú   ÚotherrE   rE   rF   Ú__eq___  s    zHiddenText.__eq__c                 C   s
   | |k S rÓ   rE   ra  rE   rE   rF   Ú__ne__j  s    zHiddenText.__ne__N)r  r  r  rü   r^  r`  rc  rd  rE   rE   rE   rF   r[  L  s
   	r[  c                 C   s   t | dd�S )NrD  r_  )r[  )r  rE   rE   rF   Ú
hide_valueo  s    re  c                 C   s   t | ƒ}t| |d�S )Nr_  )rZ  r[  )r:  r]  rE   rE   rF   Úhide_urlt  s    rf  c                 C   sz   dd  tjd ¡dj tjdd… Ž g}| oBtoBtj tjd ¡|v }|rvtjddgtjd	d…  }t	d
  d 
|¡¡ƒ‚dS )z�Protection of pip.exe from modification on Windows

    On Windows, any operation modifying pip should be run as:
        python -m pip ...
    zpip.exez	pip{}.exer   zpip{}.{}.exeNrr   z-mrS   r}   z3To modify pip, please run the following command:
{}r¢   )rC   rU   rv   r   r=   r>   rT   rV   rW   r   r?   )Úmodifying_pipÚ	pip_namesÚshould_show_use_python_msgÚnew_commandrE   rE   rF   Ú(protect_pip_from_modification_on_windowsz  s&    ýÿýÿþÿÿrk  c                   C   s   t jduot j ¡ S )z!Is this console interactive?
    N)rU   ÚstdinÚisattyrE   rE   rE   rF   Úis_console_interactive˜  s    rn  é   c                 C   sf   t  ¡ }d}t| dƒ�8}t||d�D ]}|t|ƒ7 }| |¡ q$W d  ƒ n1 sT0    Y  ||fS )z:Return (hash, length) for path using hashlib.sha256()
    r   Úrb)r°   N)ÚhashlibÚsha256Úopenr²   rJ   Úupdate)r>   Ú	blocksizeÚhÚlengthÚfÚblockrE   rE   rF   Ú	hash_fileŸ  s    *rz  c                  C   s&   zddl } W n ty    Y dS 0 dS )z8
    Return whether the wheel package is installed.
    r   NFT)ÚwheelÚImportError)r{  rE   rE   rF   Úis_wheel_installed­  s
    r}  c                 C   s   t | ƒ} t| | ƒS )zb
    Return paired elements.

    For example:
        s -> (s0, s1), (s2, s3), (s4, s5), ...
    )rø   r   )ÚiterablerE   rE   rF   Úpairwise¹  s    r  c                 C   s    t |ƒ\}}t| |ƒt| |ƒfS )z¡
    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   )Úpredr~  Út1Út2rE   rE   rF   Ú	partitionÅ  s    rƒ  )F)r|   )T)N)r0  )ro  )�Ú
__future__r   Ú
contextlibrO   r•   rq  ÚioÚloggingr=   r¶   r`   rc   rU   Úcollectionsr   Ú	itertoolsr   Úpip._vendorr   Úpip._vendor.packaging.utilsr   Zpip._vendor.retryingr   Zpip._vendor.sixr	   r
   Zpip._vendor.six.movesr   r   r   r   r   Zpip._vendor.six.moves.urllibr   r7  Z"pip._vendor.six.moves.urllib.parser   r=  rS   r   Úpip._internal.exceptionsr   rÁ   r   r   r   Úpip._internal.utils.compatr   r   r   r   Úpip._internal.utils.typingr   r   Úpip._internal.utils.virtualenvr   r   r   r    Útypingr!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   Zpip._vendor.pkg_resourcesr-   r—   rI   r.   Ú__all__Ú	getLoggerr  rò   rG   rL   r:   r8   r/   ra   rq   r0   r1   r‹   r�   r2   r”   r–   r4   r©   r5   ÚDEFAULT_BUFFER_SIZEr²   r6   r3   r7   rÄ   rÈ   rÉ   rÊ   rÍ   rá   rç   rê   rÌ   rÅ   rö   Úobjectr÷   r  Úcontextmanagerr  r9   r  r;   r  r*  r/  r6  r<  rC  rH  rR  rT  rU  rX  r<   rZ  r[  re  rf  rk  rn  rz  r}  r  rƒ  rE   rE   rE   rF   Ú<module>   sÐ   8	

"

	

$
		ú
D$



#
