XjlddlmZdZddlZddlZddlmZmZddlm Z m Z m Z ddl m Z ddlmZmZmZmZmZmZmZmZej.d k\rdd l mZndd lmZe d Gd deeZe d GddeeZe d GddeeZGddeeZy)) annotations)TextConnectableTextReceiveStreamTextSendStream TextStreamN)CallableMapping)InitVar dataclassfield)Any)AnyByteReceiveStreamAnyByteSendStream AnyByteStreamAnyByteStreamConnectableObjectReceiveStreamObjectSendStream ObjectStreamObjectStreamConnectable) )overrideF)eqc~eZdZUdZded<dZded<dZded<ed Zd ed <dd Z ddZ ddZ e ddZ y)ra 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 rtransport_streamutf-8 InitVar[str]encodingstricterrorsFinitzcodecs.IncrementalDecoder_decodercJtj|}|||_y)N)r!)codecsgetincrementaldecoderr$)selfrr! decoder_classs f/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/anyio/streams/text.py __post_init__zTextReceiveStream.__post_init__8s44X> %V4 cK |jjd{}|jj|}|r|SB7$wN)rreceiver$decode)r(chunkdecodeds r*r/zTextReceiveStream.receive<sD//7799Emm**51G 9sAA%AcK|jjd{|jjy7wr.)racloser$resetr(s r*r4zTextReceiveStream.acloseCs3##**,,,  -sAA Ac.|jjSr.rextra_attributesr6s r*r9z"TextReceiveStream.extra_attributesG$$555r,Nrstrr!r<returnNoner=r<r=r>r=zMapping[Any, Callable[[], Any]])__name__ __module__ __qualname____doc____annotations__rr!r r$r+r/r4propertyr9r,r*rr!sV +*$Hl$#FL#*/U*;H';566r,rc~eZdZUdZded<dZded<dZded <ed Zd ed <ddZ ddZ ddZ e ddZ y)ra 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 rrrrrr r<r!Fr"z Callable[..., tuple[bytes, int]]_encoderc8tj||_yr.)r& getencoderrJ)r(rs r*r+zTextSendStream.__post_init__`s))(3 r,cK|j||jd}|jj|d{y7w)Nr)rJr!rsend)r(itemencodeds r*rNzTextSendStream.sendcs9--dkk215##((111s>AAAcTK|jjd{y7wr.)rr4r6s r*r4zTextSendStream.aclosegs##**,,, (&(c.|jjSr.r8r6s r*r9zTextSendStream.extra_attributesjr:r,N)rr<r=r>rOr<r=r>r@rA)rBrCrDrErFrr!r rJr+rNr4rGr9rHr,r*rrLsV ('$Hl$FC16E1BH.B42-66r,rceZdZUdZded<dZded<dZded<ed Zd ed <ed Z d ed<ddZ ddZ ddZ ddZ ddZeddZy)ra 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 rrrrrr r!Fr"r_receive_streamr _send_streamcxt|j|||_t|j|||_y)N)rr!)rrrVrrW)r(rr!s r*r+zTextStream.__post_init__s80  ! !HV +  ! !HV r,cRK|jjd{S7wr.)rVr/r6s r*r/zTextStream.receives!))113333s '%'cVK|jj|d{y7wr.)rWrN)r(rOs r*rNzTextStream.sends $$T***s )')cTK|jjd{y7wr.)rsend_eofr6s r*r\zTextStream.send_eofs##,,...rRcK|jjd{|jjd{y7'7wr.)rWr4rVr6s r*r4zTextStream.acloses?&&(((""))+++ )+s!A A!A A A  A c^i|jj|jjSr.)rWr9rVr6s r*r9zTextStream.extra_attributess4 00 ""33  r,Nr;r?rTr@rA)rBrCrDrErFrr!r rVrWr+r/rNr\r4rGr9rHr,r*rroso"$#$Hl$#FL#).E):O&:#(e#4L.4 4+/,  r,rc&eZdZddZeddZy)rc||_y)zF :param connectable: the bytestream endpoint to wrap N) connectable)r(ras r*__init__zTextConnectable.__init__s 'r,chK|jjd{}t|S7wr.)raconnectr)r(streams r*rdzTextConnectable.connects-''//11&!!2s 202N)rar)r=r)rBrCrDrbrrdrHr,r*rrs'""r,r) __future__r__all__r&syscollections.abcrr dataclassesr r r typingr abcrrrrrrrr version_infortyping_extensionsr<rrrrrHr,r*ros"  -11   w* e'6+C0'6'6T e6%c*66D e2 c"2 2 j "-c2 "r,