관리-도구
편집 파일: compat.cpython-38.pyc
U ��.e]% � @ s~ d Z ddlmZmZ ddlZddlZddlZddlZddlZddl Z ddl mZmZ ddl mZ ddlmZ er�ddlmZmZmZmZ zddlZW n ek r� dZY nX eZzddlZW nV ek �r zddlmZ W n. ek �r ddlZeje_eje_Y nX Y nX d d ddd dddddg Z e�!e"�Z#edk �pDeZ$e�r�ddl%Z%z e%j&Z&W n e'k �rx dZ&Y nX e&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%m1Z1 d!d� Z2ndd"l3m4Z4 d#d� Z2d$d%� Z5d&d'd(hZ6e j7�8d)��pRe j7d*k�oRej9d+kZ:d,d� Z;e<ed��rrd-d� Z=nd.d� Z=dS )2zKStuff that differs in different Python versions and platform distributions.� )�absolute_import�divisionN)�PY2� text_type)�IS_PYOPENSSL)�MYPY_CHECK_RUNNING)�Optional�Text�Tuple�Union)� ipaddressr �uses_pycache�console_to_str� native_str�get_path_uid�stdlib_pkgs�WINDOWS�samefile�get_terminal_size�get_extension_suffixesT)�cache_from_sourcec sD � fdd�t � j� j�D �}dd� |D �}d�dd� |D ��� jfS )Nc 3 s | ]}� j | V qd S �N)�object)�.0�i��err� �>/usr/lib/python3.8/site-packages/pip/_internal/utils/compat.py� <genexpr>L s z-backslashreplace_decode_fn.<locals>.<genexpr>c s s | ]}t |�V qd S r )�ord)r �br r r r N s � c s s | ]}d | V qdS )z\x%xNr )r �cr r r r O s )�range�start�end�join)r Z raw_bytesr r r �backslashreplace_decode_fnK s r( �backslashreplace_decode�backslashreplacec C s� t | t�r| S t�� }|r*t�|�jdkr.d}z| �|�}W nD tk r� |dkrXd}d� |�}t �||� | j|td�}Y nX t 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-8NzBytes 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/ Zdecoded_dataZ msg_formatZoutput_encodingZoutput_encodedr r r �str_to_displayY s0 �� r>