HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/websockets/__pycache__/streams.cpython-310.pyc
o

�h��@s*ddlmZddlmZGdd�d�ZdS)�)�annotations)�	Generatorc@s`eZdZdZddd�Zdd	d
�Zddd
�Zddd�Zddd�Zd dd�Z	ddd�Z
ddd�ZdS)!�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�NonecCst�|_d|_dS)NF)�	bytearray�buffer�eof��self�r�E/usr/local/CyberCP/lib/python3.10/site-packages/websockets/streams.py�__init__s
zStreamReader.__init__�m�int�Generator[None, None, bytes]ccs��d}d}	|j�d|�d}|dkrn#t|j�}||kr(td|�d|�d���|jr3td|�d	���d
Vq||krFtd|�d|�d���|jd
|�}|jd
|�=|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.

        rT�
��read � bytes, expected no more than � bytes�stream ends after z bytes, before end of lineN)r�find�len�RuntimeErrorr	�EOFError)rr�n�p�rrrr
�	read_lines&�
�
zStreamReader.read_linerccst�|dksJ�t|j�|kr+|jr!t|j�}td|�d|�d���dVt|j�|ks|jd|�}|jd|�=|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.

        rrz bytes, expected rN)rrr	r)rrrrrrr
�
read_exact6s�

�zStreamReader.read_exactccsZ�|jst|j�}||krtd|�d|�d���dV|jr|jdd�}|jdd�=|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.

        rrrN)r	rrr)rrrrrrr
�read_to_eofMs�
�zStreamReader.read_to_eof�Generator[None, None, bool]ccs �	|jrdS|jrdSdVq)zy
        Tell whether the stream has ended and all data was read.

        This is a generator-based coroutine.

        TFN)rr	r
rrr
�at_eofcs��zStreamReader.at_eof�data�bytescCs |jrtd��|j|7_dS)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	rr)rr$rrr
�	feed_datass
zStreamReader.feed_datacCs|jrtd��d|_dS)z�
        End the stream.

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

        Raises:
            EOFError: If the stream has ended.

        r&TN)r	rr
rrr
�feed_eof�s

zStreamReader.feed_eofcCs|jdd�=dS)zG
        Discard all buffered data, but don't end the stream.

        N)rr
rrr
�discard�szStreamReader.discardN)rr)rrrr)rrrr)rr")r$r%rr)�__name__�
__module__�__qualname__�__doc__rrr r!r#r'r(r)rrrr
rs
	

"



rN)�
__future__r�collections.abcrrrrrr
�<module>s