
    pT:iw                       S SK Jr  S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  \R4                  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)    )annotations)BufferedByteReceiveStreamBufferedByteStreamBufferedConnectableN)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)r      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    Z/var/www/html/aadhar_voter_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+   r4   *BufferedByteReceiveStream.extra_attributes2   s    ""333r1   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_data6   s     	D!r1   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r3   )
r&   r   r#   r.   
isinstancer   r   receivelenr7   )r*   	max_byteschunks      r+   r=   !BufferedByteReceiveStream.receiveC   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   r7   )r*   nbytes	remainingretvalr@   excs         r+   receive_exactly)BufferedByteReceiveStream.receive_exactlyX   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   maxr7   )	r*   	delimiterr?   delimiter_sizeoffsetindexfoundr8   rF   s	            r+   receive_until'BufferedByteReceiveStream.receive_untils   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)rU   r.   )rU   zMapping[Any, Callable[[], Any]])r8   zIterable[SupportsIndex]rU   rV   )i   )r?   intrU   r.   )rC   rW   rU   r.   )rM   r.   r?   rW   rU   r.   )__name__
__module____qualname____firstlineno____doc____annotations__r   r"   r#   r&   r(   propertyr/   r4   r9   r=   rG   rR   __static_attributes__ r1   r+   r   r      sr    
 )(E9EGYEue4GT4 # # 4 4"*'6$&r1   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
$ )
r      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+   re   BufferedByteStream.__init__   s    
 	 r1   c                T   #    U R                   R                  5       I S h  vN   g  N7fr3   )rf   send_eofr)   s    r+   rk   BufferedByteStream.send_eof   s     ll##%%%s   (&(c                V   #    U R                   R                  U5      I S h  vN   g  N7fr3   )rf   send)r*   items     r+   rn   BufferedByteStream.send   s     ll%%%s   )'))rf   )rg   r   rT   )ro   r.   rU   rV   )rX   rY   rZ   r[   r\   re   r   rk   rn   r_   __classcell__)rh   s   @r+   r   r      s5    
 & & & &r1   r   c                  2    \ rS rSrSS jr\SS j5       rSrg)r      c                    Xl         g)z.
:param connectable: the connectable to wrap

Nconnectable)r*   rv   s     r+   re   BufferedConnectable.__init__   s
    
 'r1   c                h   #    U R                   R                  5       I S h  vN n[        U5      $  N7fr3   )rv   connectr   )r*   rg   s     r+   ry   BufferedConnectable.connect   s,     ''//11!&)) 2s   202ru   N)rv   r   )rU   r   )rX   rY   rZ   r[   re   r   ry   r_   r`   r1   r+   r   r      s    ' * *r1   r   ) 
__future__r   __all__syscollections.abcr   r   r	   dataclassesr
   r   typingr   r    r   r   r   r   abcr   r   r   r   r   r   version_infor   typing_extensionsr   r   r   r`   r1   r+   <module>r      s    "  7 7 ( % R R  w* ex& 1 x& x&v&2J &.*/ *r1   