Format: application/x-python-code
⬇ Download File (6.2 KB)
   1  o
   2  
   3  ;'h��@s�ddlmZddlZddlmZmZddlmZmZm	Z	ddl
   4  mZddlm
   5  Z
   6  mZmZmZmZmZedd	�Gd
   7  d�dee��Zedd	�Gdd
   8  �d
   9  ee��Zedd	�Gdd�dee��ZdS)�)�annotationsN)�Callable�Mapping)�InitVar�	dataclass�field)�Any�)�AnyByteReceiveStream�AnyByteSendStream�
  10  AnyByteStream�ObjectReceiveStream�ObjectSendStream�ObjectStreamF)�eqc@speZdZUdZded<dZded<dZded<ed	d
  11  �Zded<ddd�Z	ddd�Z
  12  ddd�Zeddd��Z
  13  dS)�TextReceiveStreama�
  14      Stream wrapper that decodes bytes to strings using the given encoding.
  15  
  16      Decoding is done using :class:`~codecs.IncrementalDecoder` which returns any
  17      completely received unicode characters as soon as they come in.
  18  
  19      :param transport_stream: any bytes-based receive stream
  20      :param encoding: character encoding to use for decoding bytes to strings (defaults
  21          to ``utf-8``)
  22      :param errors: handling scheme for decoding errors (defaults to ``strict``; see the
  23          `codecs module documentation`_ for a comprehensive list of options)
  24  
  25      .. _codecs module documentation:
  26          https://docs.python.org/3/library/codecs.html#codec-objects
  27      r
  28  �transport_stream�utf-8�InitVar[str]�encoding�strict�errorsF��initzcodecs.IncrementalDecoder�_decoder�str�return�NonecCst�|�}||d�|_dS)N)r)�codecs�getincrementaldecoderr)�selfrrZ
  29  decoder_class�r!�HC:\Users\shubh\Videos\agent\nova\Lib\site-packages\anyio/streams/text.py�
  30  __post_init__)s
  31  zTextReceiveStream.__post_init__c�s*�	|j��IdH}|j�|�}|r|Sq�N)r�receiver�decode)r �chunk�decodedr!r!r"r%-s��zTextReceiveStream.receivec�s �|j��IdH|j��dSr$)r�acloser�reset�r r!r!r"r)4s�zTextReceiveStream.aclose�Mapping[Any, Callable[[], Any]]cC�|jjSr$�r�extra_attributesr+r!r!r"r/8�z"TextReceiveStream.extra_attributesN�rrrrrr�rr�rr�rr,)�__name__�
  32  __module__�__qualname__�__doc__�__annotations__rrrrr#r%r)�propertyr/r!r!r!r"rs
  33  
  34  
  35  
  36  rc@speZdZUdZded<dZded<dZded	<ed
  37  d�Zded
  38  <ddd�Z	ddd�Z
  39  ddd�Zeddd��Z
  40  dS)�TextSendStreama
  41      Sends strings to the wrapped stream as bytes using the given encoding.
  42  
  43      :param AnyByteSendStream transport_stream: any bytes-based send stream
  44      :param str encoding: character encoding to use for encoding strings to bytes
  45          (defaults to ``utf-8``)
  46      :param str errors: handling scheme for encoding errors (defaults to ``strict``; see
  47          the `codecs module documentation`_ for a comprehensive list of options)
  48  
  49      .. _codecs module documentation:
  50          https://docs.python.org/3/library/codecs.html#codec-objects
  51      rrrrrrrrFrz Callable[..., tuple[bytes, int]]�_encoderrrcCst�|�|_dSr$)r�
  52  getencoderr<)r rr!r!r"r#QszTextSendStream.__post_init__�itemc�s*�|�||j�d}|j�|�IdHdS)Nr)r<rr�send)r r>�encodedr!r!r"r?Ts�zTextSendStream.sendc���|j��IdHdSr$)rr)r+r!r!r"r)X��zTextSendStream.acloser,cCr-r$r.r+r!r!r"r/[r0zTextSendStream.extra_attributesN)rrrr�r>rrrr3r4)r5r6r7r8r9rrrr<r#r?r)r:r/r!r!r!r"r;=s
  53  
  54  
  55  
  56  
  57  r;c@s�eZdZUdZded<dZded<dZded<ed	d
  58  �Zded<ed	d
  59  �Z	d
  60  ed<d!dd�Z
  61  d"dd�Zd#dd�Zd$dd�Z
  62  d$dd�Zed%dd��Zd S)&�
  63  TextStreama�
  64      A bidirectional stream that decodes bytes to strings on receive and encodes strings
  65      to bytes on send.
  66  
  67      Extra attributes will be provided from both streams, with the receive stream
  68      providing the values in case of a conflict.
  69  
  70      :param AnyByteStream transport_stream: any bytes-based stream
  71      :param str encoding: character encoding to use for encoding/decoding strings to/from
  72          bytes (defaults to ``utf-8``)
  73      :param str errors: handling scheme for encoding errors (defaults to ``strict``; see
  74          the `codecs module documentation`_ for a comprehensive list of options)
  75  
  76      .. _codecs module documentation:
  77          https://docs.python.org/3/library/codecs.html#codec-objects
  78      rrrrrrrFrr�_receive_streamr;�_send_streamrrrcCs(t|j||d�|_t|j||d�|_dS)N)rr)rrrEr;rF)r rrr!r!r"r#ys��zTextStream.__post_init__c�s�|j��IdHSr$)rEr%r+r!r!r"r%�s�zTextStream.receiver>c�s�|j�|�IdHdSr$)rFr?)r r>r!r!r"r?�s�zTextStream.sendc�rAr$)r�send_eofr+r!r!r"rG�rBzTextStream.send_eofc�s&�|j��IdH|j��IdHdSr$)rFr)rEr+r!r!r"r)�s�zTextStream.acloser,cCsi|jj�|jj�Sr$)rFr/rEr+r!r!r"r/�s
  79  ��zTextStream.extra_attributesNr1r2rCr3r4)r5r6r7r8r9rrrrErFr#r%r?rGr)r:r/r!r!r!r"rD`s
  80  
  81  
  82  
  83  
  84  
  85  rD)�
  86  __future__rr�collections.abcrr�dataclassesrrr�typingr�abcr
  87  rrr
  88  rrrrr;rDr!r!r!r"�<module>s 
  89  *"