
    )i                       S SK Jr  S SKrS SKJrJrJr  S SKJrJ	r	  S SK
JrJr  SSKJrJrJrJr  SSKJrJrJrJrJrJr  \R2                  S	:  a  S S
K
Jr  OS S
KJr  \" SS9 " S S\5      5       r " S S\\5      r " S S\5      rg)    )annotationsN)CallableIterableMapping)	dataclassfield)AnySupportsIndex   )ClosedResourceErrorDelimiterNotFoundEndOfStreamIncompleteRead)AnyByteReceiveStreamAnyByteStreamAnyByteStreamConnectableByteReceiveStream
ByteStreamByteStreamConnectable)      )overrideF)eqc                      \ rS rSr% SrS\S'   \" S\S9rS\S'   \" SSS	9r	S
\S'   SS jr
\SS j5       r\SS j5       rSS jrSSS jjrSS jrSS jrSrg)BufferedByteReceiveStream   z
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                b   #    U R                   R                  5       I S h  vN   SU l        g  N7f)NT)r   acloser$   selfs    V/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/anyio/streams/buffered.pyr&    BufferedByteReceiveStream.aclose#   s)     !!((*** 	+s   /-/c                ,    [        U R                  5      $ )z"The bytes currently in the buffer.)bytesr!   r'   s    r)   buffer BufferedByteReceiveStream.buffer'   s     T\\""    c                .    U R                   R                  $ N)r   extra_attributesr'   s    r)   r2   *BufferedByteReceiveStream.extra_attributes,   s    ""333r/   c               :    U R                   R                  U5        g)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_data#BufferedByteReceiveStream.feed_data0   s     	D!r/   c                  #    U R                   (       a  [        eU R                  (       a)  [        U R                  S U 5      nU R                  S U2	 U$ [	        U R
                  [        5      (       a#  U R
                  R                  U5      I S h  vN $ U R
                  R                  5       I S h  vN n[        U5      U:  a"  U R                  R                  X!S  5        US U $ U$  NY N97fr1   )
r$   r   r!   r,   
isinstancer   r   receivelenr5   )r(   	max_byteschunks      r)   r;   !BufferedByteReceiveStream.receive=   s     <<%%<<$,,z	23EZiZ(L++->??,,44Y??? --5577E5zI%##E*$56Zi(( @ 8s$   BC/C+!C/3C-48C/-C/c                  #     U[        U R                  5      -
  nUS::  a)  U R                  SU nU R                  SU2	 [        U5      $  [        U R                  [
        5      (       a$  U R                  R                  U5      I Sh  vN nO#U R                  R                  5       I Sh  vN n U R                  R                  U5        M   NE N$! [         a  n[        UeSnAff = f7f)z
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

r   N)
r<   r!   r,   r:   r   r   r;   r   r   r5   )r(   nbytes	remainingretvalr>   excs         r)   receive_exactly)BufferedByteReceiveStream.receive_exactlyR   s      T\\!22IA~gv.LL&)V}$.d113DEE"&"5"5"="=i"HHE"&"5"5"="="??E LL&  I? .$#-.sZ   A	C,=C 	C
C C,C ,C-C 1C,C C 
C)C$$C))C,c                  #    [        U5      nSn U R                  R                  X5      nUS:  a5  U R                  SU nU R                  SU[        U5      -   2	 [        U5      $ [        U R                  5      U:  a  [	        U5      e U R
                  R                  5       I Sh  vN n[        [        U R                  5      U-
  S-   S5      nU R                  R                  U5        M   NF! [         a  n[        UeSnAff = f7f)a  
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   N   )r<   r!   findr,   r   r   r;   r   r   maxr5   )	r(   	delimiterr=   delimiter_sizeoffsetindexfoundr6   rD   s	            r)   receive_until'BufferedByteReceiveStream.receive_untilm   s      YLL%%i8EzVe,LL!;53y>#9!;<U|# 4<< I-'	22.!0088::
 T\\*^;a?CFLL%)  ; .$#-.s=   B	DC2 )C0*C2 .AD0C2 2
D<DDD)r$   NreturnNone)rS   r,   )rS   zMapping[Any, Callable[[], Any]])r6   zIterable[SupportsIndex]rS   rT   )i   )r=   intrS   r,   )rA   rU   rS   r,   )rK   r,   r=   rU   rS   r,   )__name__
__module____qualname____firstlineno____doc____annotations__r   r    r!   r$   r&   propertyr-   r2   r7   r;   rE   rP   __static_attributes__ r/   r)   r   r      sr    
 )(E9EGYEue4GT4 # # 4 4"*'6$&r/   r   c                  X   ^  \ rS rSrSrSU 4S jjr\SS j5       r\S	S j5       rSr	U =r
$ )
BufferedByteStream   zy
A full-duplex variant of :class:`BufferedByteReceiveStream`. All writes are passed
through to the wrapped stream as-is.
c                0   > [         TU ]  U5        Xl        g)z*
:param stream: the stream to be wrapped

N)super__init___stream)r(   stream	__class__s     r)   rd   BufferedByteStream.__init__   s    
 	 r/   c                T   #    U R                   R                  5       I S h  vN   g  N7fr1   )re   send_eofr'   s    r)   rj   BufferedByteStream.send_eof   s     ll##%%%s   (&(c                V   #    U R                   R                  U5      I S h  vN   g  N7fr1   )re   send)r(   items     r)   rm   BufferedByteStream.send   s     ll%%%s   )'))re   )rf   r   rR   )rn   r,   rS   rT   )rV   rW   rX   rY   rZ   rd   r   rj   rm   r]   __classcell__)rg   s   @r)   r`   r`      s5    
 & & & &r/   r`   c                  2    \ rS rSrSS jr\SS j5       rSrg)BufferedConnectable   c                    Xl         g)z.
:param connectable: the connectable to wrap

Nconnectable)r(   rv   s     r)   rd   BufferedConnectable.__init__   s
    
 'r/   c                h   #    U R                   R                  5       I S h  vN n[        U5      $  N7fr1   )rv   connectr`   )r(   rf   s     r)   ry   BufferedConnectable.connect   s,     ''//11!&)) 2s   202ru   N)rv   r   )rS   r`   )rV   rW   rX   rY   rd   r   ry   r]   r^   r/   r)   rr   rr      s    ' * *r/   rr   )
__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   r`   rr   r^   r/   r)   <module>r      s~    " 
 7 7 ( % R R  w* ex& 1 x& x&v&2J &.*/ *r/   