python (3.12.0)

(root)/
lib/
python3.12/
test/
support/
__pycache__/
asynchat.cpython-312.opt-1.pyc

ϑeR-ddZddlmZddlmZGddej
ZGddZdZy	)
aA 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)asyncoreceZdZdZdZdZdZdZddZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZy)
async_chatzThis is an abstract class.  You must derive from this class, and add
    the two methods collect_incoming_data() and found_terminator()irzlatin-1Ncd|_g|_t|_tj
j
|||yN)ac_in_bufferincomingr
producer_fifor
dispatcher__init__)selfsockmaps   I/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/support/asynchat.pyrzasync_chat.__init__Js7

#W$$T45r	ctdNzmust be implemented in subclassNotImplementedErrorrdatas  rcollect_incoming_dataz async_chat.collect_incoming_dataX!"CDDr	c:|jj|yN)rappendrs  r_collect_incoming_dataz!async_chat._collect_incoming_data[s

T"r	cZdj|j}|jdd=|Sr)joinr)rds  r	_get_datazasync_chat._get_data^s%HHT]]#MM!r	ctdrrrs rfound_terminatorzasync_chat.found_terminatorcrr	ct|tr*|jrt||j}||_yt|t
r|dkrt
d||_y)zdSet the input delimiter.

        Can be a fixed string of any length, an integer, or None.
        rz-the number of received bytes must be positiveN)
isinstancestruse_encodingbytesencodingint
ValueError
terminator)rterms  rset_terminatorzasync_chat.set_terminatorfsT
dC T%6%6t}}-Dc
"taxLMMr	c|jSr)r.r$s rget_terminatorzasync_chat.get_terminatorqsr	c	|j|j}t|tr&|jrtt|j}|j|z|_
|jrt|j}|j}|s$|j|jd|_
nt|tr|}||kr8|j|jd|_
|j|z
|_n4|j|jd||j|d|_
d|_|j!nt|}|jj#|}|dk7rK|dkDr|j|jd||j||zd|_
|j!ntt%|j|}|r:||k7r4|j|jd||j|d|_
y|j|jd|_
|jryy#t$rYyt$r|j	YywxYw)Nr	r)recvac_in_buffer_sizeBlockingIOErrorOSErrorhandle_errorr'r(r)r*r+r
lenr2rr,r.r%findfind_prefix_at_end)rrlbr.nterminator_lenindexs       rhandle_readzasync_chat.handle_readys>	99T334DdC T%6%6dmm,D --4T&&'B,,.J**4+<+<=$'!J,6..t/@/@A(+D%&*oo&:DO..t/@/@!/DE(,(9(9!"(=D%&'DO))+"%Z))..z:B;qy2243D3DVe3LM(,(9(9%:N:O(PD%))+/t/@/@*ME B; 66t7H7H5&7QR040A0A5&'0JD-2243D3DE,/)g			sI	I8I87I8c$|jyr)
initiate_sendr$s rhandle_writezasync_chat.handle_writesr	c$|jyr)closer$s rhandle_closezasync_chat.handle_closes

r	cht|tttfst	dt||j}t||kDr=tdt||D]#}|jj||||z%n|jj||jy)Nz#data argument must be byte-ish (%r)r)r'r*	bytearray
memoryview	TypeErrortypeac_out_buffer_sizer:rangerrrC)rrsabsis    rpushzasync_chat.pushs$	: >?A J(
(&&t9t1c$i.
:""))$q4.9
:
%%d+r	cZ|jj||jyr)rrrC)rproducers  rpush_with_producerzasync_chat.push_with_producers"!!(+r	cy)z4predicate for inclusion in the readable for select()r$s rreadablezasync_chat.readablesr	c8|jxs
|jS)z4predicate for inclusion in the writable for select())r	connectedr$s rwritablezasync_chat.writables!!9$..&89r	c:|jjdy)zAautomatically close this channel once the outgoing queue is emptyN)rrr$s rclose_when_donezasync_chat.close_when_dones!!$'r	c|jr|jr|jd}|s |jd=||jy|j}	|d|}t|tr"|jrt||j}	|j|}|r<|t|ks|t|kr||d|jd<y|jd=yyy#t$r?|j}|r|jj
|n
|jd=Y'wxYw#t$r|jYywxYw)Nr)rrZrGrMrKmore
appendleftr'r(r)r*r+sendr8r9r:)rfirstobsrnum_sents     rrCzasync_chat.initiate_sendsP  T^^&&q)E&&q)=%%'))C
Tc{$$):):T4==1
99T?
c$i'3U+;,1(),<D&&q)
**1-K&4 
zz|&&11$7**1-


!!#
s%C!D,!AD)(D),EEcdd|_|jdd=|jjyr)r
rrclearr$s rdiscard_bufferszasync_chat.discard_bufferss(MM!  "r	)NN)__name__
__module____qualname____doc__r6rMr)r+rrrr"r%r0r2rArDrGrQrTrXr[r]rCrgrWr	rrr;s|F

LH6E#
E	F0P
:(&P#r	rceZdZddZdZy)simple_producerc ||_||_yr)rbuffer_size)rrros   rrzsimple_producer.__init__s	&r	ct|j|jkDr9|jd|j}|j|jd|_|S|j}d|_|Sr)r:rro)rresults  rr_zsimple_producer.moresbtyy>D,,,YY0 0 01F		$"2"2"34DIMYYFDIMr	N)i)rhrirjrr_rWr	rrmrms'r	rmct|dz
}|r0|j|d|s|dz}|r|j|d|s|S)NrV)r:endswith)haystackneedlels   rr<r<6sKFaA
H%%fRaj1	QH%%fRaj1Hr	N)	rkcollectionsrtest.supportrr
rrmr<rWr	r<module>rys8B*!X#$$X#v@
r