a
    ˆÀàg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   )Zpip_pkg_dir© rD   úQ/var/www/sistema_ama/venv/lib/python3.9/site-packages/pip/_internal/utils/misc.pyÚget_pip_versionQ   s    ÿÿrF   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_inforD   rD   rE   Únormalize_version_info]   s
    rK   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ÚEEXISTZ	ENOTEMPTY)r>   ÚerD   rD   rE   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)ÚprogrD   rD   rE   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\   rD   rD   rE   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ÚIOErrorrM   Úchmod)Úfuncr>   Úexc_infoZhas_attr_readonlyrD   rD   rE   r_   ‘   s    r_   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
   ÚdecoderS   ÚgetfilesystemencodingÚUnicodeDecodeErrorr	   r   rC   Úascii)r>   r0   rD   rD   rE   Úpath_to_display¥   s    	
rn   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   rS   Úversion_inforj   rk   ÚencodeÚgetdefaultencodingÚ
startswithÚgetcwdÚseprI   )r>   rD   rD   rE   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)r`   ÚextÚnÚ	extensionrD   rD   rE   r1   Ô   s    r1   c                 C   s2   t j dd¡ ¡ D ]}||v r|  S qt| |ƒS )NZPIP_EXISTS_ACTIONÚ )r=   ÚenvironÚgetÚsplitr2   )ÚmessageÚoptionsÚactionrD   rD   rE   Ú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.ZPIP_NO_INPUTz7No input was expected ($PIP_NO_INPUT set); question: {}N)r=   r�   r‚   Ú	ExceptionrC   ©r„   rD   rD   rE   Ú_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…   ÚresponserD   rD   rE   r2   ò   s    
ÿÿr2   c                 C   s   t | ƒ t| ƒS )zAsk for input interactively.)rŠ   r   r‰   rD   rD   rE   Ú	ask_input  s    r�   c                 C   s   t | ƒ t | ¡S )z!Ask for a password interactively.)rŠ   Úgetpassr‰   rD   rD   rE   Ú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)ÚbytesrD   rD   rE   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 rD   )Útupler   r|   ©Ú.0ÚrowrD   rD   rE   Ú
<listcomp>%  ó    ztabulate.<locals>.<listcomp>c                 S   s   g | ]}t tt|ƒƒ‘qS rD   )Úmaxr   rI   )r–   ÚcolrD   rD   rE   r˜   &  r™   Ú	fillvaluer€   c                    s$   g | ]}d   ttj|ˆ ƒ¡ ¡ ‘qS )ú )r?   r   r|   ÚljustÚrstripr•   ©ZsizesrD   rE   r˜   '  r™   )r   )ZrowsÚtablerD   r    rE   Ú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>   Zsetup_pyZpyproject_tomlrD   rD   rE   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ÚchunkrD   rD   rE   Ú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   rr   )r>   Zresolve_symlinksrD   rD   rE   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}   rD   rD   rE   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{   rL   r^   ÚmoveÚ
removedirsrM   )ÚoldÚnewÚheadÚtailrD   rD   rE   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   rv   rS   ÚprefixÚpip._internal.locationsrµ   Úvalues)r>   r¶   rµ   Z
local_pathrD   rD   rE   Ú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©ÚdistrD   rD   rE   Údist_is_local‘  s    r½   c                 C   s   t | ƒ ttƒ¡S )zF
    Return True if given Distribution is installed in user site.
    )rº   rv   r6   r   r»   rD   rD   rE   Ú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º   rv   r6   r   r»   rD   rD   rE   Ú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»   rD   rD   rE   Ú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 ©NTrD   ©ÚdrD   rD   rE   Ú
local_testØ  s    z/get_installed_distributions.<locals>.local_testc                 S   s   dS rÃ   rD   rÄ   rD   rD   rE   Úeditable_testÜ  s    z2get_installed_distributions.<locals>.editable_testc                 S   s
   t | ƒ S ©N©rÂ   rÄ   rD   rD   rE   rÇ   ß  s    c                 S   s   t | ƒS rÈ   rÉ   rÄ   rD   rD   rE   Úeditables_only_testã  s    z8get_installed_distributions.<locals>.editables_only_testc                 S   s   dS rÃ   rD   rÄ   rD   rD   rE   rÊ   æ  s    c                 S   s   dS rÃ   rD   rÄ   rD   rD   rE   Ú	user_testì  s    z.get_installed_distributions.<locals>.user_testc                    s:   g | ]2}ˆ|ƒr|j ˆvrˆ |ƒrˆ|ƒrˆ|ƒr|‘qS rD   )Úkey)r–   rÅ   ©rÇ   rÊ   rÆ   ÚskiprË   rD   rE   r˜   ï  s   
ûz/get_installed_distributions.<locals>.<listcomp>)r   Ú
WorkingSetÚworking_setr½   r¾   )Ú
local_onlyrÎ   Úinclude_editablesÚeditables_onlyÚ	user_onlyÚpathsrÐ   rD   rÍ   rE   Ú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()``.
    FrD   TN)rÑ   rÎ   rÒ   rÓ   rÔ   rÕ   c                 S   s   i | ]}t |jƒ|“qS rD   )r   rÌ   )r–   ÚprD   rD   rE   Ú
<dictcomp>  r™   z(_search_distribution.<locals>.<dictcomp>)r   rÖ   r‚   )Úreq_nameÚpackagesZpkg_dictrD   rD   rE   Ú_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¼   rD   rD   rE   Ú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¼   ZsitesÚsiteZegglinkrD   rD   rE   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¼   Zegg_linkrD   rD   rE   rº   O  s    
rº   c                 G   s   t j| g|¢R Ž  d S rÈ   )ÚloggerÚinfo)ÚmsgÚargsrD   rD   rE   Ú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ÚlinesrD   rD   rE   Ú__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ë   rD   rD   rE   Úreadlinej  s    zFakeFile.readlinec                 C   s   | j S rÈ   )rê   rð   rD   rD   rE   Ú__iter__p  s    zFakeFile.__iter__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rí   rñ   rò   rD   rD   rD   rE   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ø   rD   rD   rE   Úfrom_streamv  s    zStreamWrapper.from_streamc                 C   s   | j jS rÈ   )rø   Úencodingrð   rD   rD   rE   rû   |  s    zStreamWrapper.encodingN)ró   rô   rõ   Úclassmethodrú   Úpropertyrû   rD   rD   rD   rE   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)ÚgetattrrS   Úsetattrr÷   rú   )Zstream_nameÚorig_stdoutrD   rD   rE   Ú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  rD   rD   rD   rE   r9   �  s    	r9   c                   C   s   t dƒS )z 
    See captured_stdout().
    Ústderrr  rD   rD   rD   rE   Ú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)Z	dist_namerÐ   Úreqr¼   rD   rD   rE   r;   £  s
    
r;   c                 C   s   t | dd� dS )zConsume an iterable at C speed.r   )ÚmaxlenNr   )ÚiteratorrD   rD   rE   Ú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 rD   rD   )r–   rÌ   ÚvaluerD   rD   rE   rØ   ½  r™   zenum.<locals>.<dictcomp>Zreverse_mappingÚEnumrD   )ÚdictÚzipÚrangerI   ÚitemsÚtype)Z
sequentialÚnamedÚenumsÚreverserD   rD   rE   Ú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ÚportrD   rD   rE   Ú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  ro   ú@ú[r  z{}://{})ÚcountrC   )ÚnetlocÚschemerD   rD   rE   Úbuild_url_from_netlocÏ  s    
r#  c                 C   s   t | ƒ}t |¡}|j|jfS )z2
    Return the host-port pair from a netloc.
    )r#  Úurllib_parseÚurlparseÚhostnamer  )r!  ÚurlÚparsedrD   rD   rE   Ú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)).
    r  )NNrz   r  Nc                 s   s"   | ]}|d u rd nt |ƒV  qd S rÈ   )Úurllib_unquote)r–   ÚxrD   rD   rE   Ú	<genexpr>ù  s   z)split_auth_from_netloc.<locals>.<genexpr>)Úrsplitrƒ   r”   )r!  ÚauthÚ	user_passrD   rD   rE   Úsplit_auth_from_netlocä  s    ÿr0  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Úpasswordr!  )r0  r$  ÚquoterC   )r!  r2  r3  rD   rD   rE   Úredact_netloc   s    	
þr5  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   )r$  Úurlsplitr!  r"  r>   ÚqueryÚfragmentÚ
urlunsplit)r'  Ztransform_netlocZpurlZnetloc_tupleZ
url_piecesZsurlrD   rD   rE   Ú_transform_url  s    


ÿ
r:  c                 C   s   t | ƒS rÈ   )r0  ©r!  rD   rD   rE   Ú_get_netloc+  s    r<  c                 C   s
   t | ƒfS rÈ   )r5  r;  rD   rD   rE   Ú_redact_netloc/  s    r=  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))
    ©r:  r<  )r'  Zurl_without_authr!  r.  rD   rD   rE   Úsplit_auth_netloc_from_url3  s    r?  c                 C   s   t | tƒd S )z7Return a copy of url with 'username:password@' removed.r   r>  ©r'  rD   rD   rE   r<   >  s    r<   c                 C   s   t | tƒd S )z.Replace the password in a given url with ****.r   )r:  r=  r@  rD   rD   rE   Úredact_auth_from_urlF  s    rA  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ë   rC  rD  rD   rD   rE   rí   M  s    zHiddenText.__init__c                 C   s   d  t| ƒ¡S )Nz<HiddenText {!r}>)rC   r|   rð   rD   rD   rE   Ú__repr__V  s    zHiddenText.__repr__c                 C   s   | j S rÈ   ©rD  rð   rD   rD   rE   Ú__str__Z  s    zHiddenText.__str__c                 C   s    t | ƒt |ƒkrdS | j|jkS )NF)r  rC  ©rë   ÚotherrD   rD   rE   Ú__eq___  s    zHiddenText.__eq__c                 C   s
   | |k S rÈ   rD   rH  rD   rD   rE   Ú__ne__j  s    zHiddenText.__ne__N)ró   rô   rõ   rí   rE  rG  rJ  rK  rD   rD   rD   rE   rB  L  s
   	rB  c                 C   s   t | dd�S )Nr1  rF  )rB  )r  rD   rD   rE   Ú
hide_valueo  s    rL  c                 C   s   t | ƒ}t| |d�S )NrF  )rA  rB  )r'  rD  rD   rD   rE   Úhide_urlt  s    rM  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{}.{}.exeNro   z-mrQ   rz   z3To modify pip, please run the following command:
{}r�   )rC   rS   rs   r   r=   r>   rR   rT   rU   r   r?   )Zmodifying_pipZ	pip_namesZshould_show_use_python_msgZnew_commandrD   rD   rE   Ú(protect_pip_from_modification_on_windowsz  s&    ýÿýÿþÿÿrN  c                   C   s   t jduot j ¡ S )z!Is this console interactive?
    N)rS   ÚstdinÚisattyrD   rD   rD   rE   Úis_console_interactive˜  s    rQ  é   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©   rI   Úupdate)r>   Ú	blocksizeÚhÚlengthÚfÚblockrD   rD   rE   Ú	hash_fileŸ  s    *r]  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^  rD   rD   rE   Ú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   )ÚiterablerD   rD   rE   Úpairwise¹  s    rb  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   )Úpredra  Út1Út2rD   rD   rE   Ú	partitionÅ  s    rf  )F)ry   )T)N)r  )rR  )�Ú
__future__r   Ú
contextlibrN   r�   rT  ÚioÚloggingr=   r¬   r^   ra   rS   Úcollectionsr   Ú	itertoolsr   Úpip._vendorr   Úpip._vendor.packaging.utilsr   Zpip._vendor.retryingr   Úpip._vendor.sixr	   r
   Zpip._vendor.six.movesr   r   r   r   r   Zpip._vendor.six.moves.urllibr   r$  Z"pip._vendor.six.moves.urllib.parser   r*  rQ   r   Úpip._internal.exceptionsr   r·   r   r   r   Úpip._internal.utils.compatr   r   r   r   Úpip._internal.utils.typingr   r   Z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’   rH   r.   Ú__all__Ú	getLoggerró   rã   rF   rK   r:   r8   r/   r_   rn   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  r#  r)  r0  r5  r:  r<  r=  r?  r<   rA  rB  rL  rM  rN  rQ  r]  r`  rb  rf  rD   rD   rD   rE   Ú<module>   sÐ   8	

"

	

$
		ú
D$



#
