File: //opt/saltstack/salt/lib/python3.10/site-packages/rich/__pycache__/file_proxy.cpython-310.pyc
o
;j� � @ s^ d dl Z d dlmZmZmZmZ ddlmZ ddlm Z er$ddl
mZ G dd� de j�Z
dS ) � N)�IO�
TYPE_CHECKING�Any�List� )�AnsiDecoder)�Text)�Consolec @ s� e Zd ZdZdddee ddfdd�Zedee fd d
��Zdede fdd
�Z
dedefdd�Zddd�Z
defdd�Zdefdd�ZdS )� FileProxyzAWraps a file (e.g. sys.stdout) and redirects writes to a console.�consoler �file�returnNc C s || _ || _g | _t� | _d S �N)�_FileProxy__console�_FileProxy__file�_FileProxy__bufferr �_FileProxy__ansi_decoder)�selfr r � r �C/opt/saltstack/salt/lib/python3.10/site-packages/rich/file_proxy.py�__init__ s zFileProxy.__init__c C s | j S )zGet proxied file.)r �r r r r �rich_proxied_file s zFileProxy.rich_proxied_file�namec C s t | j|�S r )�getattrr )r r r r r �__getattr__ s zFileProxy.__getattr__�textc s� t |t�stdt|�j� ���� j}g }|r7|�d�\}}}|r/|�d�|�| � |� � n|�|� n|s|rd� j
}|� td��� fdd�|D ��}|�|� W d � t
|�S 1 s_w Y t
|�S )Nz"write() argument must be str, not �
� c 3 s � | ] }� j �|�V qd S r )r Zdecode_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 Znew_liner �outputr r r �write s.
��
��zFileProxy.writec C s, d� | j�}|r| j�|� | jd d �= d S )Nr )r) r r r+ )r r/ r r r �flush2 s zFileProxy.flushc C �
| j �� S r )r �filenor r r r r3 8 �
zFileProxy.filenoc C r2 r )r �isattyr r r r r5 ; r4 zFileProxy.isatty)r
N)r&