
    	h                    0   d dl mZ d dlZd dlmZmZmZ d dlmZm	Z	 d dl
mZmZ ddlmZmZmZmZ ddlmZmZmZmZmZmZ ej        d	k    rd d
l
mZ nd d
lmZ  ed           G d de                      Z G d dee          Z G d de          ZdS )    )annotationsN)CallableIterableMapping)	dataclassfield)AnySupportsIndex   )ClosedResourceErrorDelimiterNotFoundEndOfStreamIncompleteRead)AnyByteReceiveStreamAnyByteStreamAnyByteStreamConnectableByteReceiveStream
ByteStreamByteStreamConnectable)      )overrideF)eqc                      e Zd ZU dZded<    ede          Zded<    edd          Zd	ed
<   ddZ	e
dd            Ze
d d            Zd!dZd"d#dZd$dZd%dZd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                V   K   | j                                          d {V  d| _        d S )NT)r   acloser#   selfs    c/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/anyio/streams/buffered.pyr'   z BufferedByteReceiveStream.aclose#   s8      !((*********    bytesc                *    t          | j                  S )z"The bytes currently in the buffer.)r,   r    r(   s    r*   bufferz BufferedByteReceiveStream.buffer'   s     T\"""r+   Mapping[Any, Callable[[], Any]]c                    | j         j        S N)r   extra_attributesr(   s    r*   r2   z*BufferedByteReceiveStream.extra_attributes,   s    "33r+   dataIterable[SupportsIndex]c               :    | j                             |           dS )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)   r3   s     r*   	feed_dataz#BufferedByteReceiveStream.feed_data0   s      	D!!!!!r+      	max_bytesintc                  K   | j         rt          | j        r(t          | j        d |                   }| j        d |= |S t	          | j        t                    r | j                            |           d {V S | j                                         d {V }t          |          |k    r,| j        	                    ||d                     |d |         S |S r1   )
r#   r   r    r,   
isinstancer   r   receivelenr6   )r)   r9   chunks      r*   r=   z!BufferedByteReceiveStream.receive=   s      < 	&%%< 	$,z	z233EZiZ(L+->?? 	,44Y????????? -5577777777E5zzI%%##E)**$5666ZiZ((r+   nbytesc                  K   	 |t          | j                  z
  }|dk    r(| j        d|         }| j        d|= t          |          S 	 t          | j        t
                    r!| j                            |           d{V }n| j                                         d{V }n# t          $ r}t          |d}~ww xY w| j        	                    |           )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

        Tr   N)
r>   r    r,   r<   r   r   r=   r   r   r6   )r)   r@   	remainingretvalr?   excs         r*   receive_exactlyz)BufferedByteReceiveStream.receive_exactlyR   s     	'T\!2!22IA~~gvg.L&)V}}$.d13DEE @"&"5"="=i"H"HHHHHHHEE"&"5"="="?"???????E . . .$#-. L&&&	's   
AB% %
B</B77B<	delimiterc                &  K   t          |          }d}	 | j                            ||          }|dk    r8| j        d|         }| j        d|t          |          z   = t          |          S t          | j                  |k    rt	          |          	 | j                                         d{V }n# t          $ r}t          |d}~ww xY wt          t          | j                  |z
  dz   d          }| j        
                    |           )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

        r   TN   )r>   r    findr,   r   r   r=   r   r   maxr6   )	r)   rF   r9   delimiter_sizeoffsetindexfoundr3   rD   s	            r*   receive_untilz'BufferedByteReceiveStream.receive_untilm   s-      Y	&L%%i88EzzVeV,L!;53y>>#9!;<U||# 4<  I--'	222.!088:::::::: . . .$#-. T\**^;a?CCFL%%%)	&s   B6 6
C CCNr$   r%   )r$   r,   )r$   r/   )r3   r4   r$   r%   )r8   )r9   r:   r$   r,   )r@   r:   r$   r,   )rF   r,   r9   r:   r$   r,   )__name__
__module____qualname____doc____annotations__r   r   r    r#   r'   propertyr.   r2   r7   r=   rE   rO    r+   r*   r   r      s         
 )(((E9EEEGEEEEEue444G4444    # # # X# 4 4 4 X4" " " "    *' ' ' '6$& $& $& $& $& $&r+   r   c                  T     e Zd ZdZd fdZedd            Zedd
            Z xZS )BufferedByteStreamz
    A full-duplex variant of :class:`BufferedByteReceiveStream`. All writes are passed
    through to the wrapped stream as-is.
    streamr   c                X    t                                          |           || _        dS )z:
        :param stream: the stream to be wrapped

        N)super__init___stream)r)   rZ   	__class__s     r*   r]   zBufferedByteStream.__init__   s(    
 	   r+   r$   r%   c                H   K   | j                                          d {V  d S r1   )r^   send_eofr(   s    r*   ra   zBufferedByteStream.send_eof   s2      l##%%%%%%%%%%%r+   itemr,   c                J   K   | j                             |           d {V  d S r1   )r^   send)r)   rb   s     r*   rd   zBufferedByteStream.send   s4      l%%%%%%%%%%%r+   )rZ   r   rP   )rb   r,   r$   r%   )	rQ   rR   rS   rT   r]   r   ra   rd   __classcell__)r_   s   @r*   rY   rY      s         
      & & & X& & & & X& & & & &r+   rY   c                  .    e Zd ZddZed	d            ZdS )
BufferedConnectableconnectabler   c                    || _         dS )z>
        :param connectable: the connectable to wrap

        N)rh   )r)   rh   s     r*   r]   zBufferedConnectable.__init__   s    
 'r+   r$   rY   c                b   K   | j                                          d {V }t          |          S r1   )rh   connectrY   )r)   rZ   s     r*   rk   zBufferedConnectable.connect   s:      '//11111111!&)))r+   N)rh   r   )r$   rY   )rQ   rR   rS   r]   r   rk   rW   r+   r*   rg   rg      sH        ' ' ' ' * * * X* * *r+   rg   )
__future__r   syscollections.abcr   r   r   dataclassesr   r   typingr	   r
    r   r   r   r   abcr   r   r   r   r   r   version_infor   typing_extensionsr   rY   rg   rW   r+   r*   <module>ru      s   " " " " " " 



 7 7 7 7 7 7 7 7 7 7 ( ( ( ( ( ( ( ( % % % % % % % % R R R R R R R R R R R R                w****** ex& x& x& x& x& 1 x& x& x&v& & & & &2J & & &.* * * * */ * * * * *r+   