
    vg                    8    d dl mZ d dlmZ  G d d          ZdS )    )annotations)	Generatorc                  R    e Zd ZdZddZddZdd
Z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    O/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/websockets/streams.py__init__zStreamReader.__init__   s    kk    mintGenerator[None, None, bytes]c              #  f  K   d}d}	 | j                             d|          dz   }|dk    rnOt          | j                   }||k    rt          d| d| d          | j        rt          d| d	          d
V  t||k    rt          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.

        Raises:
            EOFError: If the stream ends without a LF.
            RuntimeError: If the stream 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lenRuntimeErrorr   EOFError)r   r   nprs        r   	read_linezStreamReader.read_line   s        		  **Q.A1uuDK  A1uu"#U1#U#UA#U#U#UVVVx SQAQQQRRREEE		 q55QqQQQQQRRR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_exact6   s       Avvvv$+""x S$$QAQQQQQRRREEE	 $+""
 KOKOr   c              #     K   | j         s;t          | j                  }||k    rt          d| d| d          dV  | j         ;| 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.

        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_eofM   s       ( 	DK  A1uu"#U1#U#UA#U#U#UVVV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_eofc   s9      	{ ux t EEE	r   databytesc                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_datas   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   )__name__
__module____qualname____doc__r   r#   r%   r'   r*   r/   r1   r3    r   r   r   r      s                   D   .   ,       "        r   r   N)
__future__r   collections.abcr   r   r8   r   r   <module>r;      se    " " " " " " % % % % % %Q Q Q Q Q Q Q Q Q Qr   