관리-도구
편집 파일: file_proxy.cpython-38.pyc
U &?�f� � @ s^ d dl Z d dlmZmZmZmZ ddlmZ ddlm Z erHddl mZ G dd� de j�Z dS ) � N)�IO� TYPE_CHECKING�Any�List� )�AnsiDecoder)�Text)�Consolec @ sx e Zd ZdZdee dd�dd�Zeee d�dd ��Zee d �dd�Z eed �dd�Zdd�dd�Z ed�dd�ZdS )� FileProxyzAWraps a file (e.g. sys.stdout) and redirects writes to a console.r N)�console�file�returnc C s || _ || _g | _t� | _d S �N)�_FileProxy__console�_FileProxy__file�_FileProxy__bufferr �_FileProxy__ansi_decoder)�selfr r � r �I/opt/hc_python/lib/python3.8/site-packages/pip/_vendor/rich/file_proxy.py�__init__ s zFileProxy.__init__)r c C s | j S )zGet proxied file.)r �r r r r �rich_proxied_file s zFileProxy.rich_proxied_file)�namer c C s t | j|�S r )�getattrr )r r r r r �__getattr__ s zFileProxy.__getattr__)�textr c s� t |t�stdt|�j� ���� j}g }|rl|�d�\}}}|r^|�d�|�| � |� � q(|�|� qlq(|r�� j }|�, td��� fdd�|D ��}|�|� W 5 Q R X t |�S )Nz"write() argument must be str, not � � c 3 s | ]}� j �|�V qd S r )r �decode_line)�.0�liner r r � <genexpr>, s z"FileProxy.write.<locals>.<genexpr>)� isinstance�str� TypeError�type�__name__r � partition�append�join�clearr r �print�len)r r �buffer�linesr! �new_liner �outputr r r �write s&