
    +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	m
Z
 ddlmZmZmZmZmZmZ  ed       G d	 d
ee                Z ed       G d dee                Z ed       G d dee                Zy)    )annotationsN)InitVar	dataclassfield)AnyCallableMapping   )AnyByteReceiveStreamAnyByteSendStreamAnyByteStreamObjectReceiveStreamObjectSendStreamObjectStreamF)eqc                  ~    e Zd ZU dZded<   dZded<   dZded<    ed	
      Zded<   ddZ	ddZ
ddZedd       Zy)TextReceiveStreama  
    Stream wrapper that decodes bytes to strings using the given encoding.

    Decoding is done using :class:`~codecs.IncrementalDecoder` which returns any completely
    received unicode characters as soon as they come in.

    :param transport_stream: any bytes-based receive stream
    :param encoding: character encoding to use for decoding bytes to strings (defaults to
        ``utf-8``)
    :param errors: handling scheme for decoding errors (defaults to ``strict``; see the
        `codecs module documentation`_ for a comprehensive list of options)

    .. _codecs module documentation: https://docs.python.org/3/library/codecs.html#codec-objects
    r   transport_streamutf-8InitVar[str]encodingstricterrorsFinitzcodecs.IncrementalDecoder_decoderc                J    t        j                  |      } ||      | _        y )N)r   )codecsgetincrementaldecoderr   )selfr   r   decoder_classs       E/var/www/html/venv/lib/python3.12/site-packages/anyio/streams/text.py__post_init__zTextReceiveStream.__post_init__'   s    44X>%V4    c                   K   	 | j                   j                          d {   }| j                  j                  |      }|r|S B7 $wN)r   receiver   decode)r    chunkdecodeds      r"   r'   zTextReceiveStream.receive+   sD     //7799Emm**51G	 9s   AA%Ac                   K   | j                   j                          d {    | j                  j                          y 7 wr&   )r   acloser   resetr    s    r"   r,   zTextReceiveStream.aclose2   s3     ##**,,, 	-s   AA  Ac                .    | j                   j                  S r&   r   extra_attributesr.   s    r"   r1   z"TextReceiveStream.extra_attributes6       $$555r$   Nr   strr   r4   returnNoner5   r4   r5   r6   r5   zMapping[Any, Callable[[], Any]])__name__
__module____qualname____doc____annotations__r   r   r   r   r#   r'   r,   propertyr1    r$   r"   r   r      sV     +*$Hl$#FL#*/U*;H';5 6 6r$   r   c                  ~    e Zd ZU dZded<   dZded<   dZded	<    ed
      Zded<   ddZ	ddZ
ddZedd       Zy)TextSendStreama  
    Sends strings to the wrapped stream as bytes using the given encoding.

    :param AnyByteSendStream transport_stream: any bytes-based send stream
    :param str encoding: character encoding to use for encoding strings to bytes (defaults to
        ``utf-8``)
    :param str errors: handling scheme for encoding errors (defaults to ``strict``; see the
        `codecs module documentation`_ for a comprehensive list of options)

    .. _codecs module documentation: https://docs.python.org/3/library/codecs.html#codec-objects
    r   r   r   r   r   r   r4   r   Fr   z Callable[..., tuple[bytes, int]]_encoderc                8    t        j                  |      | _        y r&   )r   
getencoderrC   )r    r   s     r"   r#   zTextSendStream.__post_init__N   s    ))(3r$   c                   K   | j                  || j                        d   }| j                  j                  |       d {    y 7 w)Nr   )rC   r   r   send)r    itemencodeds      r"   rG   zTextSendStream.sendQ   s9     --dkk215##((111s   >A AAc                T   K   | j                   j                          d {    y 7 wr&   )r   r,   r.   s    r"   r,   zTextSendStream.acloseU   s     ##**,,,   (&(c                .    | j                   j                  S r&   r0   r.   s    r"   r1   zTextSendStream.extra_attributesX   r2   r$   N)r   r4   r5   r6   rH   r4   r5   r6   r8   r9   )r:   r;   r<   r=   r>   r   r   r   rC   r#   rG   r,   r?   r1   r@   r$   r"   rB   rB   ;   sV    
 ('$Hl$FC16E1BH.B42- 6 6r$   rB   c                      e Zd ZU dZded<   dZded<   dZded<    ed	
      Zded<    ed	
      Z	ded<   ddZ
ddZddZddZddZedd       Zy)
TextStreama  
    A bidirectional stream that decodes bytes to strings on receive and encodes strings to bytes on
    send.

    Extra attributes will be provided from both streams, with the receive stream providing the
    values in case of a conflict.

    :param AnyByteStream transport_stream: any bytes-based stream
    :param str encoding: character encoding to use for encoding/decoding strings to/from bytes
        (defaults to ``utf-8``)
    :param str errors: handling scheme for encoding errors (defaults to ``strict``; see the
        `codecs module documentation`_ for a comprehensive list of options)

    .. _codecs module documentation: https://docs.python.org/3/library/codecs.html#codec-objects
    r   r   r   r   r   r   r   Fr   r   _receive_streamrB   _send_streamc                x    t        | j                  ||      | _        t        | j                  ||      | _        y )N)r   r   )r   r   rP   rB   rQ   )r    r   r   s      r"   r#   zTextStream.__post_init__u   s8    0!!HV 
 +!!HV
r$   c                R   K   | j                   j                          d {   S 7 wr&   )rP   r'   r.   s    r"   r'   zTextStream.receive}   s!     ))113333s   '%'c                V   K   | j                   j                  |       d {    y 7 wr&   )rQ   rG   )r    rH   s     r"   rG   zTextStream.send   s      $$T***s   )')c                T   K   | j                   j                          d {    y 7 wr&   )r   send_eofr.   s    r"   rV   zTextStream.send_eof   s     ##,,...rK   c                   K   | j                   j                          d {    | j                  j                          d {    y 7 '7 wr&   )rQ   r,   rP   r.   s    r"   r,   zTextStream.aclose   s?     &&(((""))+++ 	)+s!   AA!AA
A
Ac                ^    i | j                   j                  | j                  j                  S r&   )rQ   r1   rP   r.   s    r"   r1   zTextStream.extra_attributes   s4    
00
""33
 	
r$   Nr3   r7   rM   r8   r9   )r:   r;   r<   r=   r>   r   r   r   rP   rQ   r#   r'   rG   rV   r,   r?   r1   r@   r$   r"   rO   rO   ]   so      $#$Hl$#FL#).E):O&:#(e#4L.4
4+/, 
 
r$   rO   )
__future__r   r   dataclassesr   r   r   typingr   r   r	   abcr   r   r   r   r   r   r4   r   rB   rO   r@   r$   r"   <module>r]      s    "  1 1 ) )  e&6+C0 &6 &6R e6%c* 6 6B e1
c" 1
 1
r$   