a
    Šxd¤  ã                   @  st   d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
 dgZdddd	œd
d„Zedddœdd„ƒZdS )é    )ÚannotationsN)Úcontextmanager)ÚIOÚIteratorÚTextIOÚflush_stdoutr   ÚstrÚNone)ÚstdoutÚdataÚreturnc              
   C  sÌ   t | dƒot | dƒ}z^t| ƒB |r@| j | | jp6dd¡¡ n
|  |¡ |  ¡  W d   ƒ n1 sf0    Y  W nT tyÆ } z<|jrš|jd t	j
kršn|jr°|jd dkr°n‚ W Y d }~n
d }~0 0 d S )NÚencodingÚbufferzutf-8Úreplacer   )ÚhasattrÚ_blocking_ior   ÚwriteÚencoder   ÚflushÚOSErrorÚargsÚerrnoZEINTR)r
   r   Zhas_binary_ioÚe© r   úZ/var/www/html/Ranjet/env/lib/python3.9/site-packages/prompt_toolkit/output/flush_stdout.pyr      s    

*zIO[str]zIterator[None])Úior   c              
   c  s~   t jdkrdV  dS z|  ¡ }t |¡}W n   d}Y n0 z*|sNt |d¡ dV  W |szt ||¡ n|sxt ||¡ 0 dS )zA
    Ensure that the FD for `io` is set to blocking in here.
    Úwin32NT)ÚsysÚplatformÚfilenoÚosÚget_blockingÚset_blocking)r   ÚfdÚblockingr   r   r   r   8   s     

ÿr   )Ú
__future__r   r   r    r   Ú
contextlibr   Útypingr   r   r   Ú__all__r   r   r   r   r   r   Ú<module>   s   ,