U ��.e]%� @s~dZddlmZmZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddl mZddlmZer�ddlmZmZmZmZz ddlZWnek r�dZYnXeZz ddlZWnVek �rzddlmZWn.ek �rddlZeje_eje_YnXYnXd d d d d dddddg Z e�!e"�Z#edk �pDeZ$e �r�ddl%Z%z e%j&Z&Wne'k �rxdZ&YnXe&dk Z(ndZ(ddl)m&Z&e �r�dd�Z*e�+de*�dZ,ndZ,d/dd�Z-dd �Z.e �r�d0dd �Z/n d1dd �Z/dd �Z0e �r dd l%m1Z1d!d�Z2ndd"l3m4Z4d#d�Z2d$d%�Z5d&d'd(hZ6e j7�8d)��pRe j7d*k�oRej9d+kZ:d,d�Z;e/usr/lib/python3.8/site-packages/pip/_internal/utils/compat.py� Lsz-backslashreplace_decode_fn..css|]}t|�VqdSr)�ord)r�brrrrNs�css|]}d|VqdS)z\x%xNr)r�crrrrOs)�range�start�end�join)rZ raw_bytesrrr�backslashreplace_decode_fnKsr(�backslashreplace_decode�backslashreplacecCs�t|t�r|St��}|r*t�|�jdkr.d}z|�|�}WnDtk r�|dkrXd}d� |�}t � ||�|j|t d�}YnXt t tdd�dd�}|r�|j|d d�}|�|�}|S) a� For display or logging purposes, convert a bytes object (or text) to text (e.g. unicode in Python 2) safe for output. :param desc: An optional phrase describing the input data, for use in the log message if a warning is logged. Defaults to "Bytes object". This function should never error out and so can take a best effort approach. It is okay to be lossy if needed since the return value is just for display. We assume the data is in the locale preferred encoding. If it won't decode properly, we warn the user but decode as best we can. We also ensure that the output can be safely written to standard output without encoding errors. �ascii�utf-8Nz Bytes objectz&{} does not appear to be encoded as %s)�errors� __stderr__�encodingr*)� isinstancer�localeZgetpreferredencoding�codecs�lookup�name�decode�UnicodeDecodeError�format�loggerZwarningr)�getattr�sys�encode)�data�descr/Z decoded_dataZ msg_formatZoutput_encodingZoutput_encodedrrr�str_to_displayYs0    �� r>cCs t|dd�S)z)r<rrrr�sFcCst|t�r|�d�S|S)Nr,)r0rr;��s�replacerrrr�s  cCs"t|t�r|�d|rdnd�S|S)Nr,rA�strict)r0�bytesr5r?rrrr�s cCs`ttd�r6t�|tjtjB�}t�|�j}t�|�n&tj� |�sPt� |�j}n t d|��|S)a) Return path's uid. Does not follow symlinks: https://github.com/pypa/pip/pull/935#discussion_r5307003 Placed this function in compat due to differences on AIX and Jython, that should eventually go away. :raises OSError: When path is a symlink or can't be read. � O_NOFOLLOWz1%s is a symlink; Will not return uid for symlinks) �hasattr�os�open�O_RDONLYrD�fstat�st_uid�close�path�islink�stat�OSError)rL�fdZfile_uidrrrr�s    ��� get_suffixescCsdd�t�D�S)NcSsg|] }|d�qS)rr)r�suffixrrr� �sz*get_extension_suffixes..rQrrrrr�s��EXTENSION_SUFFIXEScCstSrrUrrrrr�scCs0tj�|�}|�d�r,|�d�r,|dd�}|S)zm Expand ~ and ~user constructions. Includes a workaround for https://bugs.python.org/issue14768 z~/z//�N)rFrL� expanduser� startswith)rLZexpandedrrrrX�s  rX�pythonZwsgiref�argparse�winZcli�ntcCsNttjd�rtj�||�Stj�tj�|��}tj�tj�|��}||kSdS)z>Provide an alternative for os.path.samefile on Windows/Python2rN)rErFrLr�normcase�abspath)Zfile1Zfile2Zpath1Zpath2rrrr�s  cCs tt���S)�� Returns a tuple (x, y) representing the width(x) and the height(y) in characters of the terminal window. )�tuple�shutilrrrrrrscCs�dd�}|d�p|d�p|d�}|sbz(t�t��tj�}||�}t�|�Wntk r`YnX|s�tj�dd�tj�dd �f}t|d�t|d�fS) r`cSs\z4ddl}ddl}ddl}|�d|�||jd��}Wntk rJYdSX|dkrXdS|S)NrZhhZ12345678)rr)�fcntl�termios�struct� unpack_fromZioctlZ TIOCGWINSZ� Exception)rPrcrdre�crrrr� ioctl_GWINSZs�z'get_terminal_size..ioctl_GWINSZrrW�ZLINES�ZCOLUMNS�P) rFrG�ctermidrHrKrg�environ�get�int)rirhrPrrrr s)N)F)F)>�__doc__Z __future__rrr2r1ZloggingrFrbr:Zpip._vendor.sixrrZpip._vendor.urllib3.utilrZpip._internal.utils.typingr�typingrr r r Z_ssl� ImportErrorZsslr Z pip._vendorZipaddrZ IPAddressZ ip_addressZ IPNetworkZ ip_network�__all__Z getLogger�__name__r8ZHAS_TLSZimpr�AttributeErrorr �importlib.utilr(�register_errorr)r>rrrrRrZimportlib.machineryrVrXr�platformrYr4rrrErrrrr�s�     �     � B      �