a
    lca                     @   s4   d dl Z d dlZd dlmZ dgZG dd dZdS )    N)getincrementaldecoderPosixStdinReaderc                   @   s8   e Zd ZdZdeeeddddZdeed	d
dZdS )r   a  
    Wrapper around stdin which reads (nonblocking) the next available 1024
    bytes and decodes it.

    Note that you can't be sure that the input file is closed if the ``read``
    function returns an empty string. When ``errors=ignore`` is passed,
    ``read`` can return an empty string if all malformed input was replaced by
    an empty string. (We can't block here and wait for more input.) So, because
    of that, check the ``closed`` attribute, to be sure that the file has been
    closed.

    :param stdin_fd: File descriptor from which we read.
    :param errors:  Can be 'ignore', 'strict' or 'replace'.
        On Python3, this can be 'surrogateescape', which is the default.

        'surrogateescape' is preferred, because this allows us to transfer
        unrecognised bytes to the key bindings. Some terminals, like lxterminal
        and Guake, use the 'Mxx' notation to send mouse events, where each 'x'
        can be any possible byte.
    surrogateescapeutf-8N)stdin_fderrorsencodingreturnc                 C   s.   || _ || _t|| _| j|d| _d| _d S )N)r   F)r   r   r   Z_stdin_decoder_cls_stdin_decoderclosed)selfr   r   r    r   \/var/www/html/django/DPS/env/lib/python3.9/site-packages/prompt_toolkit/input/posix_utils.py__init__$   s
    
zPosixStdinReader.__init__   )countr	   c                 C   s   | j r
dS z"t| jgg g dd s*W dS W n tyD   d| _ Y n0 z&t| j|}|dkrjd| _ W dS W n ty   d}Y n0 | j|S )z
        Read the input and return it as a string.

        Return the text. Note that this can return an empty string, even when
        the input stream was not yet closed. This means that something went
        wrong during the decoding.
         r   T    )r   selectr   OSErrorosreadr
   decode)r   r   datar   r   r   r   3   s    


zPosixStdinReader.read)r   r   )r   )__name__
__module____qualname____doc__intstrr   r   r   r   r   r   r   
   s    )r   r   codecsr   __all__r   r   r   r   r   <module>   s
   