§
    xÅj©  ã                  ó8   — d dl mZ d dlmZ  G d„ d¦  «        ZdS )é    )Úannotations)Ú	Generatorc                  óZ   — e Zd ZdZdd„Zefdd
„Zdd„Zef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    úCC:\Projects\Historical\venv\Lib\site-packages\websockets/streams.pyÚ__init__zStreamReader.__init__   s   € Ý‘k”kˆŒØˆŒˆˆó    ÚmÚintÚtoo_long_exc_typeútype[Exception]ú Generator[None, None, bytearray]c              #  óV  K  — d}d}	 | j                              d|¦  «        dz   }|dk    rnKt          | j         ¦  «        }||k    r |d|› d|› d�¦  «        ‚| j        rt	          d|› d	�¦  «        ‚d
V — Œp||k    r |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.
            too_long_exc_type: exception to raise if the line ends in more
                than ``m`` bytes; defaults to :exc:`RuntimeError`.

        Raises:
            EOFError: If the stream ends without a LF.
            RuntimeError: If the line 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Úlenr   ÚEOFError)r   r   r   ÚnÚpÚrs         r   Ú	read_linezStreamReader.read_line   s  è è € ð, ˆØˆð	Ø”× Ò  ¨Ñ*Ô*¨QÑ.ˆAØ�1ŠuˆuØÝ�D”KÑ Ô ˆAØ�1ŠuˆuØ'Ð'ØF˜AÐFÐF¸QÐFÐFÐFñô ð ð Œxð SÝÐQ°AÐQÐQÐQÑRÔRÐRØˆEˆEˆEð	ð ˆqŠ5ˆ5Ø#Ð#Ð$V¨AÐ$VÐ$VÈQÐ$VÐ$VÐ$VÑWÔWÐWØŒ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_exact>   s©   è è € ð �AŠvˆvˆvˆvÝ�$”+ÑÔ Ò"Ð"ØŒxð SÝ˜œÑ$Ô$�ÝÐQ°AÐQÐQÈÐQÐQÐQÑRÔRÐRØˆEˆEˆEõ	 �$”+ÑÔ Ò"Ð"ð
 ŒK˜˜˜ŒOˆØŒK˜˜˜ˆOØˆr   c              #  ó¸   K  — | j         s7t          | j        ¦  «        }||k    r |d|› d|› d�¦  «        ‚dV — | j         ¯7| 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.
            too_long_exc_type: exception to raise if the stream ends in more
                than ``m`` bytes; defaults to :exc:`RuntimeError`.

        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_eofU   s�   è è € ð& ”(ð 	Ý�D”KÑ Ô ˆAØ�1ŠuˆuØ'Ð'ØF˜AÐFÐF¸QÐFÐFÐFñô ð ð ˆEˆEˆEð ”(ð 	ð Œ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_eofs   s9   è è € ð	ØŒ{ð Ø�uØŒxð Ø�tð ˆEˆEˆEð	r   Údataúbytes | bytearrayc                ó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_dataƒ   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˜˜˜ˆNˆNˆNr   N)r   r   )r   r   r   r   r   r   )r!   r   r   r   )r   r)   )r,   r-   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚRuntimeErrorr$   r&   r(   r+   r0   r2   r4   © r   r   r   r      sÓ   € € € € € ðð ðð ð ð ð .:ð(ð (ð (ð (ð (ðTð ð ð ð4 .:ðð ð ð ð ð<ð ð ð ð ð ð ð ð"ð ð ð ðð ð ð ð ð r   r   N)Ú
__future__r   Úcollections.abcr   r   r:   r   r   ú<module>r=      se   ðØ "Ð "Ð "Ð "Ð "Ð "à %Ð %Ð %Ð %Ð %Ð %ðað að að að añ aô að að að ar   