§
    (¶Õi2-  ã                   ó�   — d Z ddlZddlmZ ddlmZ dZ eeed¬¦  «          G d„ d	ej        ¦  «        Z	 G d
„ d¦  «        Z
d„ ZdS )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.
é    N)Údeque)Ú_deprecatedznThe {name} module is deprecated and will be removed in Python {remove}. The recommended replacement is asyncio)é   é   )Úremovec                   óŠ   — e Zd ZdZdZdZdZdZdd„Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )Ú
async_chatz‡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                 óŠ   — d| _         g | _        t          ¦   «         | _        t          j                             | ||¦  «         d S ©Nó    )Úac_in_bufferÚincomingr   Úproducer_fifoÚasyncoreÚ
dispatcherÚ__init__)ÚselfÚsockÚmaps      ú/usr/lib/python3.11/asynchat.pyr   zasync_chat.__init__J   sB   € àˆÔð
 ˆŒõ #™WœWˆÔÝÔ×$Ò$ T¨4°Ñ5Ô5Ð5Ð5Ð5r   c                 ó    — t          d¦  «        ‚©Nzmust be implemented in subclass©ÚNotImplementedError©r   Údatas     r   Úcollect_incoming_dataz async_chat.collect_incoming_dataX   ó   € Ý!Ð"CÑDÔDÐDr   c                 ó:   — | j                              |¦  «         d S ©N)r   Úappendr   s     r   Ú_collect_incoming_dataz!async_chat._collect_incoming_data[   s   € ØŒ×Ò˜TÑ"Ô"Ð"Ð"Ð"r   c                 óN   — d                      | j        ¦  «        }| j        d d …= |S r   )Újoinr   )r   Úds     r   Ú	_get_datazasync_chat._get_data^   s(   € Ø�HŠH�T”]Ñ#Ô#ˆØŒM˜!˜!˜!ÐØˆr   c                 ó    — t          d¦  «        ‚r   r   ©r   s    r   Úfound_terminatorzasync_chat.found_terminatorc   r   r   c                 óÌ   — t          |t          ¦  «        r| j        rt          || j        ¦  «        }n*t          |t
          ¦  «        r|dk     rt          d¦  «        ‚|| _        dS )zdSet 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_terminatorzasync_chat.set_terminatorf   sj   € õ
 �d�CÑ Ô ð 	N TÔ%6ð 	NÝ˜˜tœ}Ñ-Ô-ˆDˆDÝ˜�cÑ"Ô"ð 	N t¨a¢x xÝÐLÑMÔMÐMØˆŒˆˆr   c                 ó   — | j         S r    )r2   r(   s    r   Úget_terminatorzasync_chat.get_terminatorq   s
   € ØŒÐr   c                 ó   — 	 |                       | j        ¦  «        }n1# t          $ r Y d S t          $ r |                      ¦   «          Y d S w xY wt          |t          ¦  «        r!| j        rt          t          | j	        ¦  «        }| j
        |z   | _
        | j
        �rót          | j
        ¦  «        }|                      ¦   «         }|s#|                      | j
        ¦  «         d| _
        �nœt          |t          ¦  «        rŒ|}||k     r2|                      | j
        ¦  «         d| _
        | j        |z
  | _        �nM|                      | j
        d |…         ¦  «         | j
        |d …         | _
        d| _        |                      ¦   «          nût          |¦  «        }| j
                             |¦  «        }|dk    rT|dk    r"|                      | j
        d |…         ¦  «         | j
        ||z   d …         | _
        |                      ¦   «          nxt%          | j
        |¦  «        }|r@||k    r8|                      | j
        d | …         ¦  «         | j
        | d …         | _
        d S |                      | j
        ¦  «         d| _
        | j
        �°ñd S d S )Nr   r   éÿÿÿÿ)ÚrecvÚac_in_buffer_sizeÚBlockingIOErrorÚOSErrorÚhandle_errorr+   r,   r-   r.   r/   r   Úlenr6   r   r0   r2   r)   ÚfindÚfind_prefix_at_end)r   r   Úlbr2   ÚnÚterminator_lenÚindexs          r   Úhandle_readzasync_chat.handle_ready   sÎ  € ð	Ø—9’9˜TÔ3Ñ4Ô4ˆDˆDøÝð 	ð 	ð 	ØˆFˆFÝð 	ð 	ð 	Ø×ÒÑÔÐØˆFˆFð	øøøõ �d�CÑ Ô ð 	- TÔ%6ð 	-Ý�˜dœmÑ,Ô,ˆDØ Ô-°Ñ4ˆÔð Ôñ 3	0Ý�TÔ&Ñ'Ô'ˆBØ×,Ò,Ñ.Ô.ˆJØð 00à×*Ò*¨4Ô+<Ñ=Ô=Ð=Ø$'�Ô!Ñ!Ý˜J­Ñ,Ô,ð ,0à�Ø˜’6�6Ø×.Ò.¨tÔ/@ÑAÔAÐAØ(+�DÔ%Ø&*¤o¸Ñ&:�D”O‘Oà×.Ò.¨tÔ/@ÀÀ!ÀÔ/DÑEÔEÐEØ(,Ô(9¸!¸"¸"Ô(=�DÔ%Ø&'�D”OØ×)Ò)Ñ+Ô+Ð+Ð+õ "% Z¡¤�ØÔ)×.Ò.¨zÑ:Ô:�Ø˜B’;�;à˜q’y�yð ×2Ò2°4Ô3DÀVÀeÀVÔ3LÑMÔMÐMØ(,Ô(9¸%ÀÑ:NÐ:OÐ:OÔ(P�DÔ%ð ×)Ò)Ñ+Ô+Ð+Ð+õ /¨tÔ/@À*ÑMÔM�EØð 	0Ø  Bš;˜;à ×6Ò6°tÔ7HÈÈ5È&ÈÔ7QÑRÔRÐRØ04Ô0AÀ5À&À'À'Ô0J˜DÔ-Ø˜ð ×2Ò2°4Ô3DÑEÔEÐEØ,/˜Ô)ðg Ôñ 3	0ð 3	0ð 3	0ð 3	0ð 3	0s   ‚ �
AªAÁ
Ac                 ó.   — |                       ¦   «          d S r    )Úinitiate_sendr(   s    r   Úhandle_writezasync_chat.handle_writeÁ   s   € Ø×ÒÑÔÐÐÐr   c                 ó.   — |                       ¦   «          d S r    )Úcloser(   s    r   Úhandle_closezasync_chat.handle_closeÄ   s   € Ø�
Š
‰Œˆˆˆr   c                 ó¢  — t          |t          t          t          f¦  «        st	          dt          |¦  «        ¦  «        ‚| j        }t          |¦  «        |k    rGt          dt          |¦  «        |¦  «        D ]'}| j	         
                    ||||z   …         ¦  «         Œ(n| j	         
                    |¦  «         |                      ¦   «          d S )Nz#data argument must be byte-ish (%r)r   )r+   r.   Ú	bytearrayÚ
memoryviewÚ	TypeErrorÚtypeÚac_out_buffer_sizer>   Úranger   r!   rG   )r   r   ÚsabsÚis       r   Úpushzasync_chat.pushÇ   sÏ   € Ý˜$¥­	µ:Ð >Ñ?Ô?ð 	(ÝÐAÝ  ™JœJñ(ô (ð (àÔ&ˆÝˆt‰9Œ9�tÒÐÝ˜1�c $™iœi¨Ñ.Ô.ð :ð :�ØÔ"×)Ò)¨$¨q°°4±¨x¬.Ñ9Ô9Ð9Ð9ð:ð Ô×%Ò% dÑ+Ô+Ð+Ø×ÒÑÔÐÐÐr   c                 ób   — | j                              |¦  «         |                      ¦   «          d S r    )r   r!   rG   )r   Úproducers     r   Úpush_with_producerzasync_chat.push_with_producerÓ   s1   € ØÔ×!Ò! (Ñ+Ô+Ð+Ø×ÒÑÔÐÐÐr   c                 ó   — dS )z4predicate for inclusion in the readable for select()é   © r(   s    r   Úreadablezasync_chat.readable×   s	   € ð ˆqr   c                 ó    — | j         p| j         S )z4predicate for inclusion in the writable for select())r   Ú	connectedr(   s    r   Úwritablezasync_chat.writableß   s   € àÔ!Ð9¨$¬.Ð&8Ð9r   c                 ó:   — | j                              d¦  «         dS )zAautomatically close this channel once the outgoing queue is emptyN)r   r!   r(   s    r   Úclose_when_donezasync_chat.close_when_doneã   s   € àÔ×!Ò! $Ñ'Ô'Ð'Ð'Ð'r   c                 ó¤  — | j         �rE| j        �r?| j         d         }|s | j         d= |€|                      ¦   «          d S | j        }	 |d |…         }nI# t          $ r< |                     ¦   «         }|r| j                              |¦  «         n| j         d= Y Œ—w xY wt          |t          ¦  «        r| j	        rt          || j        ¦  «        }	 |                      |¦  «        }n%# t          $ r |                      ¦   «          Y d S w xY w|rA|t          |¦  «        k     s|t          |¦  «        k     r||d …         | j         d<   n| j         d= d S d S d S )Nr   )r   r^   rK   rQ   rO   ÚmoreÚ
appendleftr+   r,   r-   r.   r/   Úsendr<   r=   r>   )r   ÚfirstÚobsr   Únum_sents        r   rG   zasync_chat.initiate_sendç   s¬  € ØÔ ñ %	 T¤^ñ %	ØÔ& qÔ)ˆEàð ØÔ& qÐ)Ø�=Ø×%Ò%Ñ'Ô'Ð'Ø�Fð Ô)ˆCðØ˜T˜c˜T”{��øÝð ð ð Ø—z’z‘|”|�Øð .ØÔ&×1Ò1°$Ñ7Ô7Ð7Ð7àÔ*¨1Ð-Ø�ðøøøõ ˜$¥Ñ$Ô$ð 2¨Ô):ð 2Ý˜T 4¤=Ñ1Ô1�ðØŸ9š9 T™?œ?��øÝð ð ð Ø×!Ò!Ñ#Ô#Ð#Ø��ðøøøð ð .Ø�c $™iœiÒ'Ð'¨3µ°U±´Ò+;Ð+;Ø,1°(°)°)Ô,<�DÔ& qÑ)Ð)àÔ*¨1Ð-àˆFðK%	ð %	ð %	ð %	s%   Á
A ÁABÂBÃC$ Ã$DÄDc                 óZ   — d| _         | j        d d …= | j                             ¦   «          d S r   )r   r   r   Úclearr(   s    r   Údiscard_bufferszasync_chat.discard_buffers  s3   € àˆÔØŒM˜!˜!˜!ÐØÔ× Ò Ñ"Ô"Ð"Ð"Ð"r   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r:   rQ   r-   r/   r   r   r"   r&   r)   r4   r6   rE   rH   rK   rU   rX   r\   r_   ra   rG   rk   r[   r   r   r	   r	   ;   sI  € € € € € ðFð Fð
 ÐØÐð
 €LØ€Hð6ð 6ð 6ð 6ðEð Eð Eð#ð #ð #ðð ð ð
Eð Eð Eð	ð 	ð 	ðð ð ðF0ð F0ð F0ðPð ð ðð ð ð
ð 
ð 
ðð ð ðð ð ð:ð :ð :ð(ð (ð (ð&ð &ð &ðP#ð #ð #ð #ð #r   r	   c                   ó   — e Zd Zdd„Zd„ ZdS )Úsimple_produceré   c                 ó"   — || _         || _        d S r    )r   Úbuffer_size)r   r   rt   s      r   r   zsimple_producer.__init__  s   € ØˆŒ	Ø&ˆÔÐÐr   c                 óº   — t          | j        ¦  «        | j        k    r/| j        d | j        …         }| j        | j        d …         | _        |S | j        }d| _        |S r   )r>   r   rt   )r   Úresults     r   rc   zsimple_producer.more  s\   € ÝˆtŒy‰>Œ>˜DÔ,Ò,Ð,Ø”YÐ0 Ô 0Ð0Ô1ˆFØœ	 $Ô"2Ð"3Ð"3Ô4ˆDŒIØˆMà”YˆFØˆDŒIØˆMr   N)rr   )rl   rm   rn   r   rc   r[   r   r   rq   rq     s7   € € € € € ð'ð 'ð 'ð 'ðð ð ð ð r   rq   c                 ó°   — t          |¦  «        dz
  }|rA|                      |d |…         ¦  «        s$|dz  }|r|                      |d |…         ¦  «        ¯$|S )NrZ   )r>   Úendswith)ÚhaystackÚneedleÚls      r   r@   r@   6  sk   € ÝˆF‰Œ�a‰€AØ
ð �H×%Ò% f¨R¨a¨R¤jÑ1Ô1ð Ø	ˆQ‰ˆð ð �H×%Ò% f¨R¨a¨R¤jÑ1Ô1ð à€Hr   )ro   r   Úcollectionsr   Úwarningsr   Ú_DEPRECATION_MSGrl   r   r	   rq   r@   r[   r   r   ú<module>r      s×   ðð8ð ð( €€€Ø Ð Ð Ð Ð Ð à  Ð  Ð  Ð  Ð  Ð  ðNÐ à €ˆHÐ&¨wÐ 7Ñ 7Ô 7Ð 7ðX#ð X#ð X#ð X#ð X#�Ô$ñ X#ô X#ð X#ðvð ð ð ð ñ ô ð ð@ð ð ð ð r   