← back to Atmos Game

assets/gen/.venv/lib/python3.12/site-packages/anyio/streams/__pycache__/buffered.cpython-312.pyc

73 lines

�

c�bjZ���ddlmZdZddlZddlmZmZmZddlm	Z	m
Z
ddlmZm
Z
ddlmZmZmZmZdd	lmZmZmZmZmZmZej4d
k\rddlmZnddlmZe	d�
�Gd�de��ZGd�dee�ZGd�de�Zy)�)�annotations)�BufferedByteReceiveStream�BufferedByteStream�BufferedConnectableN)�Callable�Iterable�Mapping)�	dataclass�field)�Any�
SupportsIndex�)�ClosedResourceError�DelimiterNotFound�EndOfStream�IncompleteRead)�AnyByteReceiveStream�
AnyByteStream�AnyByteStreamConnectable�ByteReceiveStream�
ByteStream�ByteStreamConnectable)��)�overrideF)�eqc��eZdZUdZded<ede��Zded<edd��Zd	ed
<dd�Z	e
dd��Ze
dd
��Zdd�Z
ddd�Zdd�Zdd�Zy)rz�
    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�_closedc��bK�|jj��d{���d|_y7��w)NT)r�acloser%��selfs �m/Users/macstudio3/Projects/atmos-game/assets/gen/.venv/lib/python3.12/site-packages/anyio/streams/buffered.pyr'z BufferedByteReceiveStream.aclose)s*�����!�!�(�(�*�*�*����	+�s�/�-�
/c�,�t|j�S)z"The bytes currently in the buffer.)�bytesr"r(s r*�bufferz BufferedByteReceiveStream.buffer-s���T�\�\�"�"�c�.�|jjS�N)r�extra_attributesr(s r*r1z*BufferedByteReceiveStream.extra_attributes2s���"�"�3�3�3r.c�:�|jj|�y)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)�datas  r*�	feed_dataz#BufferedByteReceiveStream.feed_data6s��	
�����D�!r.c���K�|dkrtd��|jrt�|jr)t	|jd|�}|jd|�=|St|jt�r#|jj|��d{���S|jj��d{���}t|�|kDr#|jj||d�|d|S|S7�Y7�9�w)N�z$max_bytes must be a positive integer)�
ValueErrorr%rr"r,�
isinstancerr�receive�lenr3)r)�	max_bytes�chunks   r*r:z!BufferedByteReceiveStream.receiveCs������q�=��C�D�D��<�<�%�%��<�<��$�,�,�z�	�2�3�E����Z�i�Z�(��L�
��+�+�->�
?��,�,�4�4�Y�?�?�?��-�-�5�5�7�7�E��5�z�I�%����#�#�E�)�*�$5�6��Z�i�(�(���@��8�s$�BC0�C,�!C0�4C.�58C0�.C0c���K�	|t|j�z
}|dkr)|jd|}|jd|�=t|�S	t|jt
�r$|jj
|��d{���}n"|jj
��d{���}|jj|���7�C7�"#t$r}t|�d}~wwxYw�w)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

        rN)
r;r"r,r9rrr:rrr3)r)�nbytes�	remaining�retvalr=�excs      r*�receive_exactlyz)BufferedByteReceiveStream.receive_exactly[s��������T�\�\�!2�2�I��A�~����g�v�.���L�L��&��)��V�}�$�
.��d�1�1�3D�E�"&�"5�"5�"=�"=�i�"H�H�E�"&�"5�"5�"=�"=�"?�?�E�
�L�L����&��I��?���
.�$�#�-��
.�sN�AC#�8C�C�"C�&C	�'C�+C#�C�	C�	C �C�C � C#c��K�t|�}d}	|jj||�}|dk\r5|jd|}|jd|t|�z�=t|�St|j�|k\rt	|��	|j
j
��d{���}tt|j�|z
dzd�}|jj|���7�E#t$r}t|�d}~wwxYw�w)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

        rNr7)r;r"�findr,rrr:rr�maxr3)	r)�	delimiterr<�delimiter_size�offset�index�foundr4rBs	         r*�
receive_untilz'BufferedByteReceiveStream.receive_untilvs������Y�������L�L�%�%�i��8�E���z����V�e�,���L�L�!;�5�3�y�>�#9�!;�<��U�|�#��4�<�<� �I�-�'�	�2�2�
.�!�0�0�8�8�:�:��
��T�\�\�*�^�;�a�?��C�F��L�L����%�)�;���
.�$�#�-��
.�s=�BD�C0�(C.�)C0�-AD�.C0�0	D�9D�D�DN��return�None)rNr,)rNzMapping[Any, Callable[[], Any]])r4zIterable[SupportsIndex]rNrO)i)r<�intrNr,)r?rPrNr,)rGr,r<rPrNr,)�__name__�
__module__�__qualname__�__doc__�__annotations__rr!r"r%r'�propertyr-r1r5r:rCrL�r.r*rrsr���
)�(��E�9�E�G�Y�E��u�e�4�G�T�4���#��#��4��4�"��0'�6$&r.rc�H��eZdZdZd�fd�Zedd��Zedd��Z�xZS)rz�
    A full-duplex variant of :class:`BufferedByteReceiveStream`. All writes are passed
    through to the wrapped stream as-is.
    c�2��t�|�|�||_y)z:
        :param stream: the stream to be wrapped

        N)�super�__init__�_stream)r)�stream�	__class__s  �r*r[zBufferedByteStream.__init__�s���
	���� ���r.c��TK�|jj��d{���y7��wr0)r\�send_eofr(s r*r`zBufferedByteStream.send_eof�s�����l�l�#�#�%�%�%�s�(�&�(c��VK�|jj|��d{���y7��wr0)r\�send)r)�items  r*rbzBufferedByteStream.send�s�����l�l����%�%�%�s�)�'�))r]rrM)rcr,rNrO)	rQrRrSrTr[rr`rb�
__classcell__)r^s@r*rr�s5����
��&��&��&��&r.rc�*�eZdZdZdd�Zedd��Zy)raw
    Wraps a byte stream connectable to produce :class:`BufferedByteStream` connections.

    Use this when you want the streams returned by :meth:`connect` to have the buffered
    receive API (e.g. :meth:`~BufferedByteReceiveStream.receive_exactly` and
    :meth:`~BufferedByteReceiveStream.receive_until`).

    :param connectable: the byte stream connectable to wrap
    c��||_y)z>
        :param connectable: the connectable to wrap

        N)�connectable)r)rgs  r*r[zBufferedConnectable.__init__�s��
'��r.c��hK�|jj��d{���}t|�S7��wr0)rg�connectr)r)r]s  r*rizBufferedConnectable.connect�s-�����'�'�/�/�1�1��!�&�)�)�2�s�2�0�2N)rgr)rNr)rQrRrSrTr[rrirWr.r*rr�s ���'��*��*r.r) �
__future__r�__all__�sys�collections.abcrrr	�dataclassesr
r�typingrr
�rrrr�abcrrrrrr�version_infor�typing_extensionsrrrrWr.r*�<module>rts���"����7�7�(�%�R�R������w���*��e��{&� 1�{&��{&�|&�2�J�&�.*�/�*r.