ó
    F\hR-  ã                   ód   • S r SSKJr  SSKJr   " S S\R
                  5      r " S S5      rS rg	)
a¥  A class supporting chat-style (command/response) protocols.

This class adds support for 'chat' style protocols - where one side
sends a 'command', and the other sends a response (examples would be
the common internet protocols - smtp, nntp, ftp, etc..).

The handle_read() method looks at the input stream for the current
'terminator' (usually '\r\n' for single-line responses, '\r\n.\r\n'
for multi-line output), calling self.found_terminator() on its
receipt.

for example:
Say you build an async nntp client using this class.  At the start
of the connection, you'll have self.terminator set to '\r\n', in
order to process the single-line greeting.  Just before issuing a
'LIST' command you'll set it to '\r\n.\r\n'.  The output of the LIST
command will be accumulated (using your own 'collect_incoming_data'
method) up to the terminator, and then control will be returned to
you - by calling your self.found_terminator() method.
é    )Údeque)Úasyncorec                   ó’   • \ rS rSrSrSrSrSrSrSS jr	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)Ú
async_chaté;   zƒThis is an abstract class.  You must derive from this class, and add
the two methods collect_incoming_data() and found_terminator()i   r   zlatin-1Nc                 ó~   • SU l         / U l        [        5       U l        [        R
                  R                  XU5        g ©Nó    )Úac_in_bufferÚincomingr   Úproducer_fifor   Ú
dispatcherÚ__init__)ÚselfÚsockÚmaps      Ú,/usr/lib/python3.13/test/support/asynchat.pyr   Úasync_chat.__init__J   s5   € àˆÔð
 ˆŒô #›WˆÔÜ×Ñ×$Ñ$ T°Õ5r
   c                 ó   • [        S5      e©Nzmust be implemented in subclass©ÚNotImplementedError©r   Údatas     r   Úcollect_incoming_dataÚ async_chat.collect_incoming_dataX   ó   € Ü!Ð"CÓDÐDr
   c                 ó:   • U R                   R                  U5        g ©N)r   Úappendr   s     r   Ú_collect_incoming_dataÚ!async_chat._collect_incoming_data[   s   € Ø�‰×Ñ˜TÕ"r
   c                 óZ   • SR                  U R                  5      nU R                  S S 2	 U$ r	   )Újoinr   )r   Úds     r   Ú	_get_dataÚasync_chat._get_data^   s%   € Ø�H‰H�T—]‘]Ó#ˆØ�M‰Mš!ÐØˆr
   c                 ó   • [        S5      er   r   ©r   s    r   Úfound_terminatorÚasync_chat.found_terminatorc   r   r
   c                 óÔ   • [        U[        5      (       a'  U R                  (       a  [        XR                  5      nO&[        U[
        5      (       a  US:  a  [        S5      eXl        g)zTSet the input delimiter.

Can be a fixed string of any length, an integer, or None.
r   z-the number of received bytes must be positiveN)Ú
isinstanceÚstrÚuse_encodingÚbytesÚencodingÚintÚ
ValueErrorÚ
terminator)r   Úterms     r   Úset_terminatorÚasync_chat.set_terminatorf   sK   € ô
 �dœC× Ñ  T×%6×%6Ü˜Ÿ}™}Ó-‰DÜ˜œc×"Ñ" t¨a£xÜÐLÓMÐMØ�r
   c                 ó   • U R                   $ r   )r4   r)   s    r   Úget_terminatorÚasync_chat.get_terminatorq   s   € Ø�‰Ðr
   c                 óD  •  U R                  U R                  5      n[        U[        5      (       a+  U R                  (       a  [        [        U R                  5      nU R                  U-   U l
        U R                  (       Gaó  [        U R                  5      nU R                  5       nU(       d$  U R                  U R                  5        SU l
        GOŽ[        U[        5      (       a‰  UnX$:  a8  U R                  U R                  5        SU l
        U R                  U-
  U l        GO:U R                  U R                  S U 5        U R                  US  U l
        SU l        U R!                  5         Oð[        U5      nU R                  R#                  U5      nUS:w  aK  US:”  a  U R                  U R                  S U 5        U R                  Xe-   S  U l
        U R!                  5         Oy[%        U R                  U5      nU(       a:  Xb:w  a4  U R                  U R                  S U*  5        U R                  U* S  U l
        g U R                  U R                  5        SU l
        U R                  (       a  GMò  g g ! [         a     g [         a    U R	                  5          g f = f)Nr
   r   éÿÿÿÿ)ÚrecvÚac_in_buffer_sizeÚBlockingIOErrorÚOSErrorÚhandle_errorr-   r.   r/   r0   r1   r   Úlenr9   r   r2   r4   r*   ÚfindÚfind_prefix_at_end)r   r   Úlbr4   ÚnÚterminator_lenÚindexs          r   Úhandle_readÚasync_chat.handle_ready   sD  € ð	Ø—9‘9˜T×3Ñ3Ó4ˆDô �dœC× Ñ  T×%6×%6Üœ˜dŸm™mÓ,ˆDØ ×-Ñ-°Ñ4ˆÔð ××ÐÜ�T×&Ñ&Ó'ˆBØ×,Ñ,Ó.ˆJÞà×*Ñ*¨4×+<Ñ+<Ô=Ø$'�Ö!Ü˜J¬×,Ñ,à�Ø“6Ø×.Ñ.¨t×/@Ñ/@ÔAØ(+�DÔ%Ø&*§o¡o¸Ñ&:�D–Oà×.Ñ.¨t×/@Ñ/@ÀÀ!Ð/DÔEØ(,×(9Ñ(9¸!¸"Ð(=�DÔ%Ø&'�D”OØ×)Ñ)Õ+ô "% Z£�Ø×)Ñ)×.Ñ.¨zÓ:�Ø˜B“;à˜q“yð ×2Ñ2°4×3DÑ3DÀVÀeÐ3LÔMØ(,×(9Ñ(9¸%Ñ:NÐ:OÐ(P�DÔ%ð ×)Ñ)Õ+ô /¨t×/@Ñ/@À*ÓM�EÞØ ›;à ×6Ñ6°t×7HÑ7HÈÈ5È&Ð7QÔRØ04×0AÑ0AÀ5À&À'Ð0J˜DÔ-Øð ×2Ñ2°4×3DÑ3DÔEØ,/˜Ô)ðg ××Ôøô ó 	ÙÜó 	Ø×ÑÔÙð	ús   ‚I7 É7
JÊJÊJc                 ó$   • U R                  5         g r   )Úinitiate_sendr)   s    r   Úhandle_writeÚasync_chat.handle_writeÁ   s   € Ø×ÑÕr
   c                 ó$   • U R                  5         g r   )Úcloser)   s    r   Úhandle_closeÚasync_chat.handle_closeÄ   s   € Ø�
‰
�r
   c                 ót  • [        U[        [        [        45      (       d  [	        S[        U5      5      eU R                  n[        U5      U:”  a=  [        S[        U5      U5       H"  nU R                  R                  XX2-    5        M$     OU R                  R                  U5        U R                  5         g )Nz#data argument must be byte-ish (%r)r   )r-   r0   Ú	bytearrayÚ
memoryviewÚ	TypeErrorÚtypeÚac_out_buffer_sizerB   Úranger   r    rL   )r   r   ÚsabsÚis       r   ÚpushÚasync_chat.pushÇ   s—   € Ü˜$¤¬	´:Ð >×?Ñ?ÜÐAÜ  ›Jó(ð (à×&Ñ&ˆÜˆt‹9�tÓÜ˜1œc $›i¨Ö.�Ø×"Ñ"×)Ñ)¨$°±¨.Ö9ò /ð ×Ñ×%Ñ% dÔ+Ø×ÑÕr
   c                 óZ   • U R                   R                  U5        U R                  5         g r   )r   r    rL   )r   Úproducers     r   Úpush_with_producerÚasync_chat.push_with_producerÓ   s"   € Ø×Ñ×!Ñ! (Ô+Ø×ÑÕr
   c                 ó   • g)z4predicate for inclusion in the readable for select()é   © r)   s    r   ÚreadableÚasync_chat.readable×   s   € ð r
   c                 óJ   • U R                   =(       d    U R                  (       + $ )z4predicate for inclusion in the writable for select())r   Ú	connectedr)   s    r   ÚwritableÚasync_chat.writableß   s   € à×!Ñ!×9¨$¯.©.Ô&8Ð9r
   c                 ó:   • U R                   R                  S5        g)zAautomatically close this channel once the outgoing queue is emptyN)r   r    r)   s    r   Úclose_when_doneÚasync_chat.close_when_doneã   s   € à×Ñ×!Ñ! $Õ'r
   c                 óä  • U R                   (       aí  U R                  (       aÛ  U R                   S   nU(       d!  U R                   S	 Uc  U R                  5         g U R                  n US U n[        U[        5      (       a&  U R                  (       a  [        X0R                  5      n U R                  U5      nU(       a=  U[        U5      :  d  U[        U5      :  a  XS  U R                   S'   g U R                   S	 g g g ! [         aE    UR                  5       nU(       a  U R                   R                  U5        OU R                   S	  GMM  f = f! [         a    U R                  5          g f = f)Nr   )r   rh   rQ   rX   rV   ÚmoreÚ
appendleftr-   r.   r/   r0   r1   Úsendr@   rA   rB   )r   ÚfirstÚobsr   Únum_sents        r   rL   Úasync_chat.initiate_sendç   sO  € Ø× ×  T§^§^Ø×&Ñ& qÑ)ˆEæØ×&Ñ& qÐ)Ø‘=Ø×%Ñ%Ô'Øð ×)Ñ)ˆCðØ˜T˜c�{�ô ˜$¤×$Ñ$¨×):×):Ü˜T§=¡=Ó1�ðØŸ9™9 T›?�ö
 Øœc $›iÓ'¨3´°U³Ó+;Ø,1°)Ð,<�D×&Ñ& qÑ)ð ð ×*Ñ*¨1Ð-àðK &4Ð øô ó Ø—z‘z“|�ÞØ×&Ñ&×1Ñ1°$Õ7à×*Ñ*¨1Ð-Ûðûô ó Ø×!Ñ!Ô#Ùðús%   Á'D  Â(E Ä A
EÅEÅE/Å.E/c                 ód   • SU l         U R                  S S 2	 U R                  R                  5         g r	   )r   r   r   Úclearr)   s    r   Údiscard_buffersÚasync_chat.discard_buffers  s(   € àˆÔØ�M‰Mš!ÐØ×Ñ× Ñ Õ"r
   )r   r   r   r4   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r>   rX   r/   r1   r   r   r!   r&   r*   r6   r9   rI   rM   rQ   r\   r`   re   ri   rl   rL   rx   Ú__static_attributes__rd   r
   r   r   r   ;   s|   † ñFð
 ÐØÐð
 €LØ€Hô6òEò#òò
Eò	òòF0òPòò
òòò:ò(ò&õP#r
   r   c                   ó$   • \ rS rSrSS jrS rSrg)Úsimple_produceri  c                 ó   • Xl         X l        g r   )r   Úbuffer_size)r   r   rƒ   s      r   r   Úsimple_producer.__init__  s   € ØŒ	Ø&Õr
   c                 óä   • [        U R                  5      U R                  :”  a9  U R                  S U R                   nU R                  U R                  S  U l        U$ U R                  nSU l        U$ r	   )rB   r   rƒ   )r   Úresults     r   ro   Úsimple_producer.more  sb   € Üˆt�y‰y‹>˜D×,Ñ,Ó,Ø—Y‘YÐ0 × 0Ñ 0Ð1ˆFØŸ	™	 $×"2Ñ"2Ð"3Ð4ˆDŒIØˆMà—Y‘YˆFØˆDŒIØˆMr
   )rƒ   r   N)i   )rz   r{   r|   r}   r   ro   r   rd   r
   r   r�   r�     s   † ô'õr
   r�   c                 ó°   • [        U5      S-
  nU(       a@  U R                  US U 5      (       d'  US-  nU(       a  U R                  US U 5      (       d  M'  U$ )Nrc   )rB   Úendswith)ÚhaystackÚneedleÚls      r   rD   rD   6  sQ   € ÜˆF‹�a‰€AÞ
�H×%Ñ% f¨R¨a j×1Ñ1Ø	ˆQ‰ˆö �H×%Ñ% f¨R¨a j×1Ó1à€Hr
   N)	r~   Úcollectionsr   Útest.supportr   r   r   r�   rD   rd   r
   r   Ú<module>r�      s8   ðñBõ* å !ôX#�×$Ñ$ô X#÷vñ ó@r
   