Ë
    KU h  ã                  ó  — 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j2                  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y)é    )Ú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y)Ú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Ú_closedc              ƒ  ób   K  — | j                   j                  «       ƒ d {  –—†  d| _        y 7 Œ­w)NT)r   Úacloser#   ©Úselfs    úN/var/www/timesheet/venv/lib/python3.12/site-packages/anyio/streams/buffered.pyr%   z BufferedByteReceiveStream.aclose#   s*   è ø€ Ø×!Ñ!×(Ñ(Ó*×*Ð*Øˆ�ð 	+ús   ‚/ -¡/c                ó,   — t        | j                  «      S )z"The bytes currently in the buffer.)Úbytesr    r&   s    r(   Úbufferz BufferedByteReceiveStream.buffer'   s   € ô �T—\‘\Ó"Ð"ó    c                ó.   — | j                   j                  S ©N)r   Úextra_attributesr&   s    r(   r/   z*BufferedByteReceiveStream.extra_attributes,   s   € à×"Ñ"×3Ñ3Ð3r,   c               ó:   — | j                   j                  |«       y)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_dataz#BufferedByteReceiveStream.feed_data0   s   € ð 	�‰×Ñ˜DÕ!r,   c              ƒ  óÄ  K  — | j                   rt        ‚| j                  r)t        | j                  d | «      }| j                  d |…= |S t	        | j
                  t        «      r#| j
                  j                  |«      ƒ d {  –—† S | j
                  j                  «       ƒ d {  –—† }t        |«      |kD  r#| j                  j                  ||d  «       |d | S |S 7 ŒY7 Œ9­wr.   )
r#   r   r    r*   Ú
isinstancer   r   ÚreceiveÚlenr1   )r'   Ú	max_bytesÚchunks      r(   r6   z!BufferedByteReceiveStream.receive=   sË   è ø€ Ø�<Š<Ü%Ð%à�<Š<Ü˜$Ÿ,™, z¨	Ð2Ó3ˆEØ—‘˜Z˜i˜ZÐ(ØˆLÜ˜×+Ñ+Ô->Ô?Ø×,Ñ,×4Ñ4°YÓ?×?Ð?ð ×-Ñ-×5Ñ5Ó7×7ˆEÜ�5‹z˜IÒ%à—‘×#Ñ# E¨)¨*Ð$5Ô6Ø˜Z˜iÐ(Ð(à�ð @øð 8ús$   ‚B C ÂCÂ!C Â$CÂ%8C ÃC c              ƒ  óÊ  K  — 	 |t        | j                  «      z
  }|dk  r)| j                  d| }| j                  d|…= t        |«      S 	 t        | j                  t
        «      r$| j                  j                  |«      ƒ d{  –—† }n"| j                  j                  «       ƒ d{  –—† }| j                  j                  |«       ŒÃ7 ŒC7 Œ"# t        $ r}t        |‚d}~ww xY w­w)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

        r   N)
r7   r    r*   r5   r   r   r6   r   r   r1   )r'   ÚnbytesÚ	remainingÚretvalr9   Úexcs         r(   Úreceive_exactlyz)BufferedByteReceiveStream.receive_exactlyR   sÏ   è ø€ ð Ø¤ T§\¡\Ó!2Ñ2ˆIØ˜AŠ~ØŸ™ g vÐ.�Ø—L‘L  & Ð)Ü˜V“}Ð$ð.Ü˜d×1Ñ1Ô3DÔEØ"&×"5Ñ"5×"=Ñ"=¸iÓ"H×H‘Eà"&×"5Ñ"5×"=Ñ"=Ó"?×?�Eð �L‰L×Ñ Ô&ð ð Iøà?ùÜò .Ü$¨#Ð-ûð.üsN   ‚AC#Á8C ÂCÂ"C Â&C	Â'C Â+C#ÃC Ã	C Ã	C ÃCÃC Ã C#c              ƒ  ó  K  — t        |«      }d}	 | j                  j                  ||«      }|dk\  r5| j                  d| }| j                  d|t        |«      z   …= t        |«      S t        | j                  «      |k\  rt	        |«      ‚	 | j
                  j                  «       ƒ d{  –—† }t        t        | j                  «      |z
  dz   d«      }| j                  j                  |«       ŒÝ7 ŒE# t        $ r}t        |‚d}~ww xY w­w)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   Né   )r7   r    Úfindr*   r   r   r6   r   r   Úmaxr1   )	r'   Ú	delimiterr8   Údelimiter_sizeÚoffsetÚindexÚfoundr2   r>   s	            r(   Úreceive_untilz'BufferedByteReceiveStream.receive_untilm   sù   è ø€ ô ˜Y›ˆØˆØà—L‘L×%Ñ% i°Ó8ˆEØ˜ŠzØŸ™ V eÐ,�Ø—L‘LÐ!; 5¬3¨y«>Ñ#9Ð!;Ð<Ü˜U“|Ð#ô �4—<‘<Ó  IÒ-Ü'¨	Ó2Ð2ð.Ø!×0Ñ0×8Ñ8Ó:×:�ô
 œ˜TŸ\™\Ó*¨^Ñ;¸aÑ?ÀÓCˆFØ�L‰L×Ñ Ô%ð) ð ;ùÜò .Ü$¨#Ð-ûð.üs=   ‚BDÂC0 Â(C.Â)C0 Â-ADÃ.C0 Ã0	DÃ9D Ä DÄDN©ÚreturnÚNone)rK   r*   )rK   zMapping[Any, Callable[[], Any]])r2   zIterable[SupportsIndex]rK   rL   )i   )r8   ÚintrK   r*   )r;   rM   rK   r*   )rD   r*   r8   rM   rK   r*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r   r   r    r#   r%   Úpropertyr+   r/   r3   r6   r?   rI   © r,   r(   r   r      sr   … ñð
 )Ó(Ù E¸9ÔE€GˆYÓEÙ˜u¨eÔ4€GˆTÓ4óð ò#ó ð#ð ò4ó ð4ó"ôó*'ô6$&r,   r   c                  óH   ‡ — 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.
    c                ó2   •— t         ‰| �  |«       || _        y)z:
        :param stream: the stream to be wrapped

        N)ÚsuperÚ__init__Ú_stream)r'   ÚstreamÚ	__class__s     €r(   rY   zBufferedByteStream.__init__š   s   ø€ ô
 	‰Ñ˜Ô Øˆ�r,   c              ƒ  óT   K  — | j                   j                  «       ƒ d {  –—†  y 7 Œ­wr.   )rZ   Úsend_eofr&   s    r(   r^   zBufferedByteStream.send_eof¢   s   è ø€ à�l‰l×#Ñ#Ó%×%Ò%ús   ‚( &¡(c              ƒ  óV   K  — | j                   j                  |«      ƒ d {  –—†  y 7 Œ­wr.   )rZ   Úsend)r'   Úitems     r(   r`   zBufferedByteStream.send¦   s   è ø€ à�l‰l×Ñ Ó%×%Ò%ús   ‚)¡'¢))r[   r   rJ   )ra   r*   rK   rL   )	rN   rO   rP   rQ   rY   r   r^   r`   Ú__classcell__)r\   s   @r(   rV   rV   ”   s5   ø„ ñõ
ð ò&ó ð&ð ò&ó ô&r,   rV   c                  ó&   — e Zd Zdd„Zedd„«       Zy)ÚBufferedConnectablec                ó   — || _         y)z>
        :param connectable: the connectable to wrap

        N)Úconnectable)r'   rf   s     r(   rY   zBufferedConnectable.__init__¬   s   € ð
 'ˆÕr,   c              ƒ  óh   K  — | j                   j                  «       ƒ d {  –—† }t        |«      S 7 Œ­wr.   )rf   ÚconnectrV   )r'   r[   s     r(   rh   zBufferedConnectable.connect³   s-   è ø€ à×'Ñ'×/Ñ/Ó1×1ˆÜ! &Ó)Ð)ð 2ús   ‚2 0¡2N)rf   r   )rK   rV   )rN   rO   rP   rY   r   rh   rT   r,   r(   rd   rd   «   s   „ ó'ð ò*ó ñ*r,   rd   )Ú
__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   rV   rd   rT   r,   r(   ú<module>rr      s~   ðÝ "ã 
ß 7Ñ 7ß (ß %ç RÓ R÷÷ ð ×Ñ�wÒÞå*ñ ˆeÔôx&Ð 1ó x&ó ðx&ôv&Ð2°Jô &ô.*Ð/õ *r,   