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/anyio/streams/__pycache__/buffered.cpython-310.pyc
o

�h�@s�ddlmZddlZddlmZmZmZddlmZm	Z	ddl
mZmZddl
mZmZmZmZddlmZmZmZmZmZmZejd	krLdd
l
mZndd
lmZedd�Gd
d�de��ZGdd�dee�ZGdd�de�ZdS)�)�annotationsN)�Callable�Iterable�Mapping)�	dataclass�field)�Any�
SupportsIndex�)�ClosedResourceError�DelimiterNotFound�EndOfStream�IncompleteRead)�AnyByteReceiveStream�
AnyByteStream�AnyByteStreamConnectable�ByteReceiveStream�
ByteStream�ByteStreamConnectable)��)�overrideF)�eqc@s�eZdZUdZded<eded�Zded<eddd�Zd	ed
<d%d
d�Z	e
d&dd��Ze
d'dd��Zd(dd�Z
d)d*dd�Zd+dd �Zd,d"d#�Zd$S)-�BufferedByteReceiveStreamz�
    Wraps any bytes-based receive stream and uses a buffer to provide sophisticated
    receiving capabilities in the form of a byte stream.
    r�receive_streamF)�init�default_factory�	bytearray�_buffer)r�default�bool�_closed�return�Nonec�s�|j��IdHd|_dS)NT)r�acloser!��self�r'�I/usr/local/CyberCP/lib/python3.10/site-packages/anyio/streams/buffered.pyr$#s�
z BufferedByteReceiveStream.aclose�bytescCs
t|j�S)z"The bytes currently in the buffer.)r)rr%r'r'r(�buffer's
z BufferedByteReceiveStream.buffer�Mapping[Any, Callable[[], Any]]cCs|jjS�N)r�extra_attributesr%r'r'r(r-,sz*BufferedByteReceiveStream.extra_attributes�data�Iterable[SupportsIndex]cCs|j�|�dS)a;
        Append data directly into the buffer.

        Any data in the buffer will be consumed by receive operations before receiving
        anything from the wrapped stream.

        :param data: the data to append to the buffer (can be bytes or anything else
            that supports ``__index__()``)

        N)r�extend)r&r.r'r'r(�	feed_data0sz#BufferedByteReceiveStream.feed_data��	max_bytes�intc�s��|jrt�|jrt|jd|��}|jd|�=|St|jt�r)|j�|�IdHS|j��IdH}t|�|krG|j�	||d��|d|�S|Sr,)
r!rrr)�
isinstancerr�receive�lenr0)r&r3�chunkr'r'r(r6=s�z!BufferedByteReceiveStream.receive�nbytesc
�s��	|t|j�}|dkr|jd|�}|jd|�=t|�Szt|jt�r/|j�|�IdH}n|j��IdH}WntyG}zt|�d}~ww|j�	|�q)a-
        Read exactly the given amount of bytes from the stream.

        :param nbytes: the number of bytes to read
        :return: the bytes read
        :raises ~anyio.IncompleteRead: if the stream was closed before the requested
            amount of bytes could be read from the stream

        TrN)
r7rr)r5rrr6r
rr0)r&r9�	remaining�retvalr8�excr'r'r(�receive_exactlyRs$�
����z)BufferedByteReceiveStream.receive_exactly�	delimiterc	
�s��t|�}d}	|j�||�}|dkr(|jd|�}|jd|t|��=t|�St|j�|kr3t|��z
|j��IdH}WntyL}zt|�d}~wwt	t|j�|dd�}|j�
|�q)aM
        Read from the stream until the delimiter is found or max_bytes have been read.

        :param delimiter: the marker to look for in the stream
        :param max_bytes: maximum number of bytes that will be read before raising
            :exc:`~anyio.DelimiterNotFound`
        :return: the bytes read (not including the delimiter)
        :raises ~anyio.IncompleteRead: if the stream was closed before the delimiter
            was found
        :raises ~anyio.DelimiterNotFound: if the delimiter is not found within the
            bytes read up to the maximum allowed

        rTN�)r7r�findr)rrr6r
r�maxr0)	r&r>r3�delimiter_size�offset�index�foundr.r<r'r'r(�
receive_untilms(����z'BufferedByteReceiveStream.receive_untilN�r"r#)r"r))r"r+)r.r/r"r#)r2)r3r4r"r))r9r4r"r))r>r)r3r4r"r))�__name__�
__module__�__qualname__�__doc__�__annotations__rrrr!r$�propertyr*r-r1r6r=rFr'r'r'r(rs



rcs>eZdZdZd�fdd�Zeddd	��Zeddd
��Z�ZS)�BufferedByteStreamz�
    A full-duplex variant of :class:`BufferedByteReceiveStream`. All writes are passed
    through to the wrapped stream as-is.
    �streamrcst��|�||_dS)z:
        :param stream: the stream to be wrapped

        N)�super�__init__�_stream�r&rO��	__class__r'r(rQ�s
zBufferedByteStream.__init__r"r#c�s�|j��IdHdSr,)rR�send_eofr%r'r'r(rV�s�zBufferedByteStream.send_eof�itemr)c�s�|j�|�IdHdSr,)rR�send)r&rWr'r'r(rX�s�zBufferedByteStream.send)rOrrG)rWr)r"r#)	rHrIrJrKrQrrVrX�
__classcell__r'r'rTr(rN�srNc@s$eZdZd
dd�Zeddd��Zd	S)�BufferedConnectable�connectablercCs
||_dS)z>
        :param connectable: the connectable to wrap

        N)r[)r&r[r'r'r(rQ�s
zBufferedConnectable.__init__r"rNc�s�|j��IdH}t|�Sr,)r[�connectrNrSr'r'r(r\�s�zBufferedConnectable.connectN)r[r)r"rN)rHrIrJrQrr\r'r'r'r(rZ�s
rZ)�
__future__r�sys�collections.abcrrr�dataclassesrr�typingrr	�rrr
r�abcrrrrrr�version_infor�typing_extensionsrrNrZr'r'r'r(�<module>s 
	{