U
    Ôðcc¡  ã                   @   st   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m	Z	 dgZ
eeddœdd„Zeee ed dœdd	„ƒZdS )
é    N)Úcontextmanager)ÚIOÚIteratorÚTextIOÚcastÚflush_stdout)ÚstdoutÚdataÚreturnc              
   C   s¶   t | dƒot | dƒ}zJt| ƒ8 |r@| j | | jp6dd¡¡ n
|  |¡ |  ¡  W 5 Q R X W nR tk
r° } z4|jrˆ|jd t	j
krˆn|jrž|jd dkržn‚ W 5 d }~X Y nX 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   ú\/var/www/html/project/venv/lib/python3.8/site-packages/prompt_toolkit/output/flush_stdout.pyr   
   s    

)Úior
   c              
   c   sn   t jdkrdV  dS z|  ¡ }t |¡}W n   d}Y nX z|sNt |d¡ dV  W 5 |sht ||¡ X 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   7   s    


r   )r   r   r   Ú
contextlibr   Útypingr   r   r   r   Ú__all__Ústrr   r   r   r   r   r   Ú<module>   s   -