o
    žD®f¤  ã                   @  sf   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„Zeddd„ƒZdS )é    )ÚannotationsN)Úcontextmanager)ÚIOÚIteratorÚTextIOÚflush_stdoutÚstdoutr   ÚdataÚstrÚreturnÚNonec              
   C  sÞ   t | dƒo	t | dƒ}z2t| ƒ# |r | j | | jpdd¡¡ n|  |¡ |  ¡  W d   ƒ W d S 1 s5w   Y  W d S  tyn } z&|jrP|jd t	j
krPn|jr[|jd dkr[n‚ W Y d }~d S W Y d }~d S d }~ww )NÚencodingÚbufferzutf-8Úreplacer   )ÚhasattrÚ_blocking_ior   ÚwriteÚencoder   ÚflushÚOSErrorÚargsÚerrnoÚEINTR)r   r	   Úhas_binary_ioÚe© r   ú[/home/ubuntu/webapp/venv/lib/python3.10/site-packages/prompt_toolkit/output/flush_stdout.pyr      s$   


&õö€óÚioúIO[str]úIterator[None]c              
   c  s€    t jdkrdV  dS z|  ¡ }t |¡}W n   d}Y z|s&t |d¡ dV  W |s4t ||¡ dS dS |s?t ||¡ w w )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   )r   r   r	   r
   r   r   )r   r   r   r   )Ú
__future__r   r   r$   r!   Ú
contextlibr   Útypingr   r   r   Ú__all__r   r   r   r   r   r   Ú<module>   s    
,