a
    hbòfM  ã                   @   s^   d dl Z d dlmZmZmZmZ ddlmZ ddlm	Z	 erHddl
mZ G dd„ de jƒZdS )	é    N)ÚListÚAnyÚIOÚTYPE_CHECKINGé   )ÚAnsiDecoder)ÚText)ÚConsolec                   @   sj   e Zd ZdZdee ddœdd„Zeee dœdd	„ƒZee	d
œdd„Z
eedœdd„Zddœdd„ZdS )Ú	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   úX/home/httpd/docs/test/DocsMgr/lib/python3.9/site-packages/pip/_vendor/rich/file_proxy.pyÚ__init__   s    zFileProxy.__init__)r   c                 C   s   | j S )zGet proxied file.)r   ©r   r   r   r   Úrich_proxied_file   s    zFileProxy.rich_proxied_file)Únamer   c                 C   s   t | j|ƒS r   )Úgetattrr   )r   r   r   r   r   Ú__getattr__   s    zFileProxy.__getattr__)Útextr   c                    sÊ   t |tƒstdt|ƒj› �ƒ‚ˆ j}g }|rn| d¡\}}}|r`| d |¡| ¡ |d d …= q(| |¡ qnq(|rÂˆ j	}|�6 t
dƒ ‡ fdd„|D ƒ¡}| |¡ W d   ƒ n1 s¸0    Y  t|ƒS )Nz"write() argument must be str, not Ú
Ú c                 3   s   | ]}ˆ j  |¡V  qd S r   )r   Údecode_line)Ú.0Úliner   r   r   Ú	<genexpr>,   s   z"FileProxy.write.<locals>.<genexpr>)Ú
isinstanceÚstrÚ	TypeErrorÚtypeÚ__name__r   Ú	partitionÚappendÚjoinr   r   ÚprintÚlen)r   r   ÚbufferÚlinesr!   Únew_liner   Úoutputr   r   r   Úwrite   s&    

ÿ(zFileProxy.writec                 C   s*   | j }|r&| j d |¡¡ |d d …= d S )Nr   )r   r   r+   r*   )r   r-   r   r   r   Úflush2   s    zFileProxy.flush)r'   Ú
__module__Ú__qualname__Ú__doc__r   r$   r   Úpropertyr   r   r   Úintr1   r2   r   r   r   r   r
      s   r
   )ÚioÚtypingr   r   r   r   Úansir   r   r   r   r	   Ú
TextIOBaser
   r   r   r   r   Ú<module>   s   