
    ,h                    0    d dl mZ d dlmZ  G d d      Zy)    )annotations)	Generatorc                  P    e Zd ZdZddZddZddZddZddZddZ	ddZ
dd	Zy
)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.

    c                0    t               | _        d| _        y )NF)	bytearraybuffereofselfs    T/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/websockets/streams.py__init__zStreamReader.__init__   s    k    c              #  d  K   d}d}	 | j                   j                  d|      dz   }|dkD  rnLt        | j                         }||kD  rt        d| d| d      | j                  rt        d| d      d	 q||kD  rt        d| d| d      | j                   d	| }| j                   d	|= |S w)
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.

        r      
   read  bytes, expected no more than  bytesstream ends after z bytes, before end of lineN)r	   findlenRuntimeErrorr
   EOFError)r   mnprs        r   	read_linezStreamReader.read_line   s         *Q.A1uDKK A1u"U1#-KA3f#UVVxx!3A36PQRR  q5qc)Gs&QRRKKOKKOs   B.B0c              #  (  K   |dk\  sJ t        | j                        |k  rP| j                  r't        | j                        }t        d| d| d      d t        | j                        |k  rP| j                  d| }| j                  d|= |S w)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_exact6   s      Av$++"xx$!3A36Gs&QRR	 $++"
 KKOKKOs   A/B2 Bc              #     K   | j                   s=t        | j                        }||kD  rt        d| d| d      d | j                   s=| j                  dd }| j                  dd= |S w)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.

        r   r   r   N)r
   r   r	   r   )r   r   r   r   s       r   read_to_eofzStreamReader.read_to_eofM   sj      ((DKK A1u"U1#-KA3f#UVV	 ((
 KKNKKNs   A	A, A,c              #  J   K   	 | j                   ry| j                  ryd w)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_eofc   s)      {{xx  s   !#c                \    | j                   rt        d      | xj                  |z  c_        y)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   datas     r   	feed_datazStreamReader.feed_datas   s$     88>**tr   c                @    | j                   rt        d      d| _         y)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     88>**r   c                "    | j                   dd= y)zG
        Discard all buffered data, but don't end the stream.

        N)r	   r   s    r   discardzStreamReader.discard   s    
 KKNr   N)returnNone)r   intr.   Generator[None, None, bytes])r   r0   r.   r1   )r.   zGenerator[None, None, bool])r(   bytesr.   r/   )__name__
__module____qualname____doc__r   r   r!   r#   r%   r)   r+   r-    r   r   r   r      s0     D., "r   r   N)
__future__r   collections.abcr   r   r7   r   r   <module>r:      s    " %Q Qr   