
    j                    8    d dl mZ d dlmZ  G d d          ZdS )    )annotations)	Generatorc                  Z    e Zd ZdZddZefdd
ZddZefddZddZ	ddZ
ddZddZdS )StreamReaderz
    Generator-based stream reader.

    This class doesn't support concurrent calls to :meth:`read_line`,
    :meth:`read_exact`, or :meth:`read_to_eof`. Make sure calls are
    serialized.

    returnNonec                :    t                      | _        d| _        d S )NF)	bytearraybuffereofselfs    \/workspace/show-city-briefing-agent/.venv/lib/python3.11/site-packages/websockets/streams.py__init__zStreamReader.__init__   s    kk    minttoo_long_exc_typetype[Exception] Generator[None, None, bytearray]c              #  V  K   d}d}	 | j                             d|          dz   }|dk    rnKt          | j                   }||k    r |d| d| d          | j        rt	          d| d	          d
V  p||k    r |d| d| d          | j         d
|         }| j         d
|= |S )a  
        Read a LF-terminated line from the stream.

        This is a generator-based coroutine.

        The return value includes the LF character.

        Args:
            m: Maximum number bytes to read; this is a security limit.
            too_long_exc_type: exception to raise if the line ends in more
                than ``m`` bytes; defaults to :exc:`RuntimeError`.

        Raises:
            EOFError: If the stream ends without a LF.
            RuntimeError: If the line ends in more than ``m`` bytes.

        r   T   
   read  bytes, expected no more than  bytesstream ends after z bytes, before end of lineN)r   findlenr   EOFError)r   r   r   nprs         r   	read_linezStreamReader.read_line   s     , 	  **Q.A1uuDK  A1uu''FAFFQFFF   x SQAQQQRRREEE	 q55##$VA$V$VQ$V$V$VWWWKOKOr   r!   c              #    K   |dk    sJ t          | j                  |k     rM| j        r*t          | j                  }t          d| d| d          dV  t          | j                  |k     M| j        d|         }| j        d|= |S )z
        Read a given number of bytes from the stream.

        This is a generator-based coroutine.

        Args:
            n: How many bytes to read.

        Raises:
            EOFError: If the stream ends in less than ``n`` bytes.

        r   r   z bytes, expected r   N)r   r   r   r    )r   r!   r"   r#   s       r   
read_exactzStreamReader.read_exact>   s       Avvvv$+""x S$$QAQQQQQRRREEE	 $+""
 KOKOr   c              #     K   | j         s7t          | j                  }||k    r |d| d| d          dV  | j         7| j        dd         }| j        dd= |S )a  
        Read all bytes from the stream.

        This is a generator-based coroutine.

        Args:
            m: Maximum number bytes to read; this is a security limit.
            too_long_exc_type: exception to raise if the stream ends in more
                than ``m`` bytes; defaults to :exc:`RuntimeError`.

        Raises:
            RuntimeError: If the stream ends in more than ``m`` bytes.

        r   r   r   N)r   r   r   )r   r   r   r"   r#   s        r   read_to_eofzStreamReader.read_to_eofU   s      & ( 	DK  A1uu''FAFFQFFF   EEE ( 	 KNKNr   Generator[None, None, bool]c              #  6   K   	 | j         rdS | j        rdS dV  )zy
        Tell whether the stream has ended and all data was read.

        This is a generator-based coroutine.

        TFN)r   r   r   s    r   at_eofzStreamReader.at_eofs   s9      	{ ux t EEE	r   databytes | bytearrayc                R    | j         rt          d          | xj        |z  c_        dS )z
        Write data to the stream.

        :meth:`feed_data` cannot be called after :meth:`feed_eof`.

        Args:
            data: Data to write.

        Raises:
            EOFError: If the stream has ended.

        stream endedN)r   r    r   )r   r,   s     r   	feed_datazStreamReader.feed_data   s0     8 	+>***tr   c                @    | j         rt          d          d| _         dS )z
        End the stream.

        :meth:`feed_eof` cannot be called more than once.

        Raises:
            EOFError: If the stream has ended.

        r/   TN)r   r    r   s    r   feed_eofzStreamReader.feed_eof   s'     8 	+>***r   c                    | j         dd= dS )zG
        Discard all buffered data, but don't end the stream.

        N)r   r   s    r   discardzStreamReader.discard   s    
 KNNNr   N)r   r   )r   r   r   r   r   r   )r!   r   r   r   )r   r)   )r,   r-   r   r   )__name__
__module____qualname____doc__r   RuntimeErrorr$   r&   r(   r+   r0   r2   r4    r   r   r   r      s             .:( ( ( ( (T   4 .:    <       "        r   r   N)
__future__r   collections.abcr   r   r:   r   r   <module>r=      se    " " " " " " % % % % % %a a a a a a a a a ar   