HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_internal/utils/__pycache__/misc.cpython-310.pyc
o

@%Ne�K�	@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZmZmZddlmZddlmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!ddl"m#Z#m$Z$m%Z%ddl&m'Z'ddl(m)Z)dd	l*m+Z+dd
l,m-Z-ddl.m/Z/gd�Z0e�1e2�Z3e d
�Z4eee5e5efZ6ee7e7e7fZ8ee9eee9ee9ffZ:de9fdd�Z;dee7dfdee7e7e7ffdd�Z<de9ddfdd�Z=de9fdd�Z>e#de$d�e%d�d�d�de9d e?ddfd!d"��Z@d#edefde9d$e6ddfd%d&�ZAde9de9fd'd(�ZBd�de9d*e9de9fd+d,�ZCd-e9d.ee9de9fd/d0�ZDd-e9ddfd1d2�ZEd-e9d.ee9de9fd3d4�ZFd-e9de9fd5d6�ZGd-e9de9fd7d8�ZHd9e9de7fd:d;�ZId<eJde9fd=d>�ZKd?eeedeee9ee7ffd@dA�ZLde9de?fdBdC�ZMejNfdDedEe7deeOfdFdG�ZPd�de9dHe?de9fdIdJ�ZQde9dee9e9ffdKdL�ZRdMe9dNe9ddfdOdP�ZSde9de?fdQdR�ZTdSedTeddfdUdV�ZUGdWdX�dXe
�ZVejWdYe9deeVfdZd[��ZXdeeVfd\d]�ZYdeeVfd^d_�ZZd`edaedeefdbdc�Z[dde9deee7de9fdfdg�Z\d�die9dje9de9fdkdl�Z]die9dee9ee7ffdmdn�Z^die9de:fdodp�Z_die9de9fdqdr�Z`dse9dtee9geedffdee9e:ffdudv�Zadie9de:fdwdx�Zbdie9dee9fdydz�Zcdse9dee9e9ee9e9fffd{d|�Zddse9de9fd}d~�Zedse9de9fdd��ZfGd�d��d��Zgd�e9degfd�d��Zhdse9degfd�d��Zid�e?ddfd�d��Zjde?fd�d��Zkd�de9d�e7deee7ffd�d��Zlde?fd�d��Zmd�eedeeeeffd�d��Znd�ee4ge?fd�ee4deee4ee4ffd�d��ZodS)��N)�StringIO)�filterfalse�tee�zip_longest)�
TracebackType)
�Any�BinaryIO�Callable�ContextManager�Iterable�Iterator�List�Optional�TextIO�Tuple�Type�TypeVar�cast)�retry�stop_after_delay�
wait_fixed)�__version__)�CommandError)�get_major_minor_version)�WINDOWS)�running_under_virtualenv)
�rmtree�display_path�
backup_dir�ask�splitext�format_size�is_installable_dir�normalize_path�renames�get_prog�captured_stdout�
ensure_dir�remove_auth_from_url�T�returncCs4tj�tj�t�dd�}tj�|�}d�t|t��S)Nz..zpip {} from {} (python {}))	�os�path�join�dirname�__file__�abspath�formatrr)�pip_pkg_dir�r3�:/usr/lib/python3/dist-packages/pip/_internal/utils/misc.py�get_pip_versionDs�r5�py_version_info.cCsDt|�dkr|dt|�d7}nt|�dkr|dd�}td|�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).
    �)rN�VersionInfo)�lenr)r6r3r3r4�normalize_version_infoOs

r:r,c
Cs`zt�|�WdSty/}z|jtjkr|jtjkr$�WYd}~dSWYd}~dSd}~ww)z os.path.makedirs without EEXIST.N)r+�makedirs�OSError�errno�EEXIST�	ENOTEMPTY)r,�er3r3r4r'bs���r'c
CsJztj�tjd�}|dvrtj�d�WS|WStttfy$YdSw)Nr)z__main__.pyz-cz -m pip�pip)	r+r,�basename�sys�argv�
executable�AttributeError�	TypeError�
IndexError)�progr3r3r4r%ls�r%Tr7g�?)�reraise�stop�waitF�dir�
ignore_errorscCstj||td�dS)N)rN�onerror)�shutilr�rmtree_errorhandler)rMrNr3r3r4rz�r�func�exc_infocCsNzt�|�jtj@}Wn
tyYdSw|r&t�|tj�||�dS�)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_IWRITEr<�chmod)rSr,rT�has_attr_readonlyr3r3r4rQs�rQcCsFtj�tj�|��}|�t��tjj�r!d|tt���d�}|S)zTGives the display value for a given path, making it relative to cwd
    if possible.�.N)r+r,�normcaser0�
startswith�getcwd�sepr9�r,r3r3r4r�sr�.bak�extcCsDd}|}tj�||�r|d7}|t|�}tj�||�s||S)z\Figure out the name of a directory to back up the given dir to
    (adding .bak, .bak2, etc)�)r+r,�exists�str)rMra�n�	extensionr3r3r4r�s�r�message�optionscCs2tj�dd���D]
}||vr|Sq	t||�S)N�PIP_EXISTS_ACTION�)r+�environ�get�splitr)rgrh�actionr3r3r4�ask_path_exists�s
�
rocCstj�d�r
td|����dS)z&Raise an error if no input is allowed.�PIP_NO_INPUTz5No input was expected ($PIP_NO_INPUT set); question: N)r+rkrl�	Exception�rgr3r3r4�_check_no_input�s
��rscCsD	t|�t|�}|����}||vrtd�|d�|���n|Sq)z@Ask the message interactively, with the given possible responsesrbz>Your response ({!r}) was not one of the expected responses: {}z, )rs�input�strip�lower�printr1r-)rgrh�responser3r3r4r�s��rcCst|�t|�S)zAsk for input interactively.)rsrtrrr3r3r4�	ask_input�srycCst|�t�|�S)z!Ask for a password interactively.)rs�getpassrrr3r3r4�ask_password�s
r{�valcCs.|��}|dvr
dS|dvrdStd|����)z�Convert a string representation of truth to true (1) or false (0).

    True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
    are 'n', 'no', 'f', 'false', 'off', and '0'.  Raises ValueError if
    'val' is anything else.
    )�y�yes�t�true�on�1rb)re�no�f�false�off�0rzinvalid truth value )rv�
ValueError)r|r3r3r4�	strtobool�sr��bytescCsX|dkr
d�|dd�S|dkrd�t|d��S|dkr%d�|d�Sd�t|��S)	Ni@Bz	{:.1f} MBg@�@i�i'z{} kBz	{:.1f} kBz{} bytes)r1�int)r�r3r3r4r!�sr!�rowscs@dd�|D�}dd�t|ddi�D���fdd�|D�}|�fS)z�Return a list of formatted rows and a list of column sizes.

    For example::

    >>> tabulate([['foobar', 2000], [0xdeadbeef]])
    (['foobar     2000', '3735928559'], [10, 4])
    cS�g|]	}ttt|���qSr3)�tuple�maprd��.0�rowr3r3r4�
<listcomp>��ztabulate.<locals>.<listcomp>cSr�r3)�maxr�r9)r��colr3r3r4r��r��	fillvaluerjcs$g|]}d�ttj|������qS)� )r-r�rd�ljust�rstripr���sizesr3r4r��s$)r)r��tabler3r�r4�tabulate�sr�cCsHtj�|�sdStj�tj�|d��rdStj�tj�|d��r"dSdS)atIs path is a directory containing pyproject.toml or setup.py?

    If pyproject.toml exists, this is a PEP 517 project. Otherwise we look for
    a legacy setuptools layout by identifying setup.py. We don't check for the
    setup.cfg because using it without setup.py is only available for PEP 517
    projects, which are already covered by the pyproject.toml check.
    Fzpyproject.tomlTzsetup.py)r+r,�isdir�isfiler-r_r3r3r4r"�sr"�file�sizeccs�	|�|�}|sdS|Vq)z7Yield pieces of data from a file-like object until EOF.TN)�read)r�r��chunkr3r3r4�read_chunkss�
�r��resolve_symlinkscCs6tj�|�}|rtj�|�}ntj�|�}tj�|�S)zN
    Convert a path to its canonical, case-normalized, absolute version.

    )r+r,�
expanduser�realpathr0r[)r,r�r3r3r4r#s
r#cCs@t�|�\}}|���d�r|dd�|}|dd�}||fS)z,Like os.path.splitext, but take off .tar tooz.tar���N)�	posixpathr rv�endswith)r,�baserar3r3r4r !s
r �old�newcCs�tj�|�\}}|r|rtj�|�st�|�t�||�tj�|�\}}|r<|r>zt�|�WdSty;YdSwdSdS)z7Like os.renames(), but handles renaming across devices.N)	r+r,rmrcr;rP�move�
removedirsr<)r�r��head�tailr3r3r4r$*s
��r$cCs|t|�}d}t�r|�ttj��Sddlm}ddlm}|�|�r<|d�}|D]}t	||�}|�t|��r9dSq(dSdS)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)�
get_scheme)�SCHEME_KEYSrjTF)
r#rr\rC�prefix�pip._internal.locationsr��pip._internal.models.schemer��getattr)r,r�r�r��scheme�key�
local_pathr3r3r4�is_local;s

�r��msg�argscGstj|g|�R�dS�N)�logger�info)r�r�r3r3r4�write_outputasr�c@s<eZdZUdZeed<ededdfdd��Zedd��Z	dS)�
StreamWrapperN�orig_streamr*cCs||_|�Sr�)r�)�clsr�r3r3r4�from_streamhszStreamWrapper.from_streamcCs|jjSr�)r��encoding��selfr3r3r4r�oszStreamWrapper.encoding)
�__name__�
__module__�__qualname__r�r�__annotations__�classmethodr��propertyr�r3r3r3r4r�es
r��stream_namec
csL�tt|�}tt|t�|��ztt|�VWtt||�dStt||�w)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)r�rC�setattrr�r�)r��orig_stdoutr3r3r4�captured_outputts�
r�cC�td�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�r3r3r3r4r&�s	r&cCr�)z 
    See captured_stdout().
    �stderrr�r3r3r3r4�captured_stderr�sr��
sequential�namedcOsDtt|tt|���fi|��}dd�|��D�}||d<tdd|�S)NcSsi|]\}}||�qSr3r3)r�r��valuer3r3r4�
<dictcomp>�szenum.<locals>.<dictcomp>�reverse_mapping�Enumr3)�dict�zip�ranger9�items�type)r�r��enums�reverser3r3r4�enum�sr��host�portcCs.|dur|Sd|vrd|�d�}|�d|��S)z.
    Build a netloc from a host-port pair
    N�:�[�]r3)r�r�r3r3r4�build_netloc�s
r��https�netlocr�cCs8|�d�dkrd|vrd|vrd|�d�}|�d|��S)z)
    Build a full URL from a netloc.
    r���@r�r�z://)�count)r�r�r3r3r4�build_url_from_netloc�sr�cCs t|�}tj�|�}|j|jfS)z2
    Return the host-port pair from a netloc.
    )r��urllib�parse�urlparse�hostnamer�)r��url�parsedr3r3r4�parse_netloc�sr�cCstd|vr|dfS|�dd�\}}d}d|vr|�dd�\}}n|d}}tj�|�}|dur4tj�|�}|||ffS)zp
    Parse out and remove the auth information from a netloc.

    Returns: (netloc, (username, password)).
    r�)NNrbNr�)�rsplitrmr�r��unquote)r��auth�pw�userr3r3r4�split_auth_from_netloc�s
r�cCsNt|�\}\}}|dur|S|durd}d}ntj�|�}d}dj|||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�****rjz:****z{user}{password}@{netloc})r��passwordr�)r�r�r��quoter1)r�r�rr3r3r4�
redact_netloc�s�rr��transform_netloccCsJtj�|�}||j�}|j|d|j|j|jf}tj�|�}|t	d|�fS)aRTransform 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�NetlocTuple)
r�r��urlsplitr�r�r,�query�fragment�
urlunsplitr)r�r�purl�netloc_tuple�
url_pieces�surlr3r3r4�_transform_url�s

rcCst|�Sr�)r��r�r3r3r4�_get_netlocsrcCs
t|�fSr�)rrr3r3r4�_redact_netlocs
rcCst|t�\}\}}|||fS)z�
    Parse a url into separate netloc, auth, and url with no auth.

    Returns: (url_without_auth, netloc, (username, password))
    �rr)r��url_without_authr�r�r3r3r4�split_auth_netloc_from_urls
rcC�t|t�dS)z7Return a copy of url with 'username:password@' removed.rr�r�r3r3r4r(sr(cCr)z.Replace the password in a given url with ****.r)rrrr3r3r4�redact_auth_from_urlsrc@sPeZdZdededdfdd�Zdefdd�Zdefd	d
�Zdedefdd
�Z	dS)�
HiddenText�secret�redactedr*NcCs||_||_dSr�)rr)r�rrr3r3r4�__init__#s
zHiddenText.__init__cCsd�t|��S)Nz<HiddenText {!r}>)r1rdr�r3r3r4�__repr__'szHiddenText.__repr__cCs|jSr��rr�r3r3r4�__str__*szHiddenText.__str__�othercCs t|�t|�kr
dS|j|jkS)NF)r�r)r�rr3r3r4�__eq__.szHiddenText.__eq__)
r�r�r�rdrrrr�boolr r3r3r3r4r"s
rr�cCst|dd�S)Nrr)r)r�r3r3r4�
hide_value7sr"cCst|�}t||d�S)Nr)rr)r�rr3r3r4�hide_url;sr#�
modifying_pipcCszdd�tjd�djtjdd��g}|o!to!tj�tjd�|v}|r;tjddgtjd	d�}t	d
�d�
|����dS)z�Protection of pip.exe from modification on Windows

    On Windows, any operation modifying pip should be run as:
        python -m pip ...
    zpip.exez	pip{}.exerzpip{}.{}.exeNr�z-mrArbz3To modify pip, please run the following command:
{}r�)r1rC�version_inforr+r,rBrDrErr-)r$�	pip_names�should_show_use_python_msg�new_commandr3r3r4�(protect_pip_from_modification_on_windows@s�����r)cCstjduo	tj��S)zIs this console interactive?N)rC�stdin�isattyr3r3r3r4�is_console_interactiveZrRr,��	blocksizecCslt��}d}t|d��}t||d�D]
}|t|�7}|�|�qWd�||fS1s-wY||fS)z5Return (hash, length) for path using hashlib.sha256()r�rb)r�N)�hashlib�sha256�openr�r9�update)r,r.�h�lengthr��blockr3r3r4�	hash_file_s�
��r7cCs$zddl}WdStyYdSw)z8
    Return whether the wheel package is installed.
    rNFT)�wheel�ImportError)r8r3r3r4�is_wheel_installedks
��r:�iterablecCst|�}t||�S)zb
    Return paired elements.

    For example:
        s -> (s0, s1), (s2, s3), (s4, s5), ...
    )�iterr)r;r3r3r4�pairwisews
r=�predcCs t|�\}}t||�t||�fS)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
    )rr�filter)r>r;�t1�t2r3r3r4�	partition�s
rB)F)r`)T)r�)r-)p�
contextlibr=rzr0�io�loggingr+r�rPrUrC�urllib.parser�r�	itertoolsrrr�typesr�typingrrr	r
rrr
rrrrrr�pip._vendor.tenacityrrrrAr�pip._internal.exceptionsrr�r�pip._internal.utils.compatr�pip._internal.utils.virtualenvr�__all__�	getLoggerr�r�r)�
BaseException�ExcInfor�r8rdrr5r:r'r%r!rrQrrrorsrryr{r��floatr!r�r"�DEFAULT_BUFFER_SIZEr�r�r#r r$r�r�r��contextmanagerr�r&r�r�r�r�r�r�rrrrrr(rrr"r#r)r,r7r:r=rBr3r3r3r4�<module>s�<
$
"	* 	
	&
	��

�$
 "���