� <��g���8�ddlmZddlmZGd�d��ZdS)�)� annotations)� Generatorc�R�eZdZdZdd�Zdd�Zdd �Zdd �Zdd �Zdd�Z dd�Z dd�Z dS)� 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|_dS)NF)� bytearray�buffer�eof��selfs �b/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/websockets/streams.py�__init__zStreamReader.__init__s���k�k�� �������m�int�Generator[None, None, bytes]c#�fK�d}d} |j�d|��dz}|dkrnOt|j��}||krtd|�d|�d����|jrt d|�d ����d V��t||krtd|�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�rs r� read_linezStreamReader.read_lines����� �� �� �� � � ���*�*�Q�.�A��1�u�u���D�K� � �A��1�u�u�"�#U�1�#U�#U�A�#U�#U�#U�V�V�V��x� S��Q�A�Q�Q�Q�R�R�R� �E�E�E� � �q�5�5��Q�q�Q�Q��Q�Q�Q�R�R� R� �K����O�� �K����O��rr c#�K�|dksJ�t|j��|krM|jr*t|j��}td|�d|�d����dV�t|j��|k�M|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)rr r r)rr r!r"s r� read_exactzStreamReader.read_exact6s������A�v�v�v�v��$�+����"�"��x� S��� �$�$���Q�A�Q�Q��Q�Q�Q�R�R�R� �E�E�E� �$�+����"�"� �K����O�� �K����O��rc#��K�|js;t|j��}||krtd|�d|�d����dV�|j�;|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 rr r)rrr!r"s r� read_to_eofzStreamReader.read_to_eofMs������(� ��D�K� � �A��1�u�u�"�#U�1�#U�#U�A�#U�#U�#U�V�V�V� �E�E�E� �(� � �K����N�� �K����N��r�Generator[None, None, bool]c#�6K� |jrdS|jrdSdV��)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_eofzStreamReader.at_eofcs9���� ��{� ��u��x� ��t� �E�E�E� r�data�bytesc�R�|jrtd���|xj|z c_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+s r� feed_datazStreamReader.feed_datass0�� �8� +��>�*�*� *� � � �t�� � � � rc�@�|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 s r�feed_eofzStreamReader.feed_eof�s'�� �8� +��>�*�*� *�����rc��|jdd�=dS)zG Discard all buffered data, but don't end the stream. N)r r s r�discardzStreamReader.discard�s�� �K����N�N�NrN)rr)rrrr)r rrr)rr()r+r,rr) �__name__� __module__� __qualname__�__doc__rr#r%r'r*r/r1r3�rrrrs������������� � � � �D����.����,���� ����" � � � ������rrN)� __future__r�collections.abcrrr8rr�<module>r;se��"�"�"�"�"�"�%�%�%�%�%�%�Q�Q�Q�Q�Q�Q�Q�Q�Q�Qr
Memory