Ñò §ÚêLc@s dZddkZddkZddklZddklZddklZl Z dei fd„ƒYZ dd d „ƒYZ d dd „ƒYZ d „ZdS(s¥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. iÿÿÿÿN(tdeque(t py3kwarning(tfilterwarningstcatch_warningst async_chatcBs¹eZdZdZdZddd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„ZRS(s‡This is an abstract class. You must derive from this class, and add the two methods collect_incoming_data() and found_terminator()icCs8d|_g|_tƒ|_tii|||ƒdS(Nt(t ac_in_buffertincomingRt producer_fifotasyncoret dispatchert__init__(tselftsocktmap((s /usr/lib64/python2.6/asynchat.pyR @s   cCstdƒ‚dS(Nsmust be implemented in subclass(tNotImplementedError(R tdata((s /usr/lib64/python2.6/asynchat.pytcollect_incoming_dataQscCs|ii|ƒdS(N(Rtappend(R R((s /usr/lib64/python2.6/asynchat.pyt_collect_incoming_dataTscCsdi|iƒ}|i2|S(NR(tjoinR(R td((s /usr/lib64/python2.6/asynchat.pyt _get_dataWscCstdƒ‚dS(Nsmust be implemented in subclass(R(R ((s /usr/lib64/python2.6/asynchat.pytfound_terminator\scCs ||_dS(sRSet the input delimiter. Can be a fixed string of any length, an integer, or NoneN(t terminator(R tterm((s /usr/lib64/python2.6/asynchat.pytset_terminator_scCs|iS(N(R(R ((s /usr/lib64/python2.6/asynchat.pytget_terminatorcscCsy|i|iƒ}Wn#tij o}|iƒdSX|i||_xÉ|io¾t|iƒ}|iƒ}|p|i|iƒd|_qOt |t ƒpt |t ƒo{|}||jo-|i|iƒd|_|i ||_ q|i|i| ƒ|i||_d|_ |i ƒqOt|ƒ}|ii|ƒ}|djoG|djo|i|i| ƒn|i|||_|i ƒqOt|i|ƒ}|o<||jo*|i|i| ƒ|i| |_nPqO|i|iƒd|_qOWdS(NRiiÿÿÿÿ(trecvtac_in_buffer_sizetsocketterrort handle_errorRtlenRRt isinstancetinttlongRRtfindtfind_prefix_at_end(R RtwhytlbRtntterminator_lentindex((s /usr/lib64/python2.6/asynchat.pyt handle_readksL            cCs|iƒdS(N(t initiate_send(R ((s /usr/lib64/python2.6/asynchat.pyt handle_write­scCs|iƒdS(N(tclose(R ((s /usr/lib64/python2.6/asynchat.pyt handle_close°scCs||i}t|ƒ|joBxOtdt|ƒ|ƒD]!}|ii||||!ƒq5Wn|ii|ƒ|iƒdS(Ni(tac_out_buffer_sizeR!txrangeRRR-(R Rtsabsti((s /usr/lib64/python2.6/asynchat.pytpush³s #cCs|ii|ƒ|iƒdS(N(RRR-(R tproducer((s /usr/lib64/python2.6/asynchat.pytpush_with_producer¼scCsdS(s4predicate for inclusion in the readable for select()i((R ((s /usr/lib64/python2.6/asynchat.pytreadableÀscCs|ip|i S(s4predicate for inclusion in the writable for select()(Rt connected(R ((s /usr/lib64/python2.6/asynchat.pytwritableÈscCs|iidƒdS(sAautomatically close this channel once the outgoing queue is emptyN(RRtNone(R ((s /usr/lib64/python2.6/asynchat.pytclose_when_doneÌsc Cs…x~|ios|ioi|id}|p*|id=|djo|iƒdSn|i}yLtƒiiƒz1tot ddt ƒnt |d|ƒ}WdQXWnGt j o;|i ƒ}|o|ii|ƒq|id=qnXy|i|ƒ}Wn!tij o|iƒdSX|oI|t|ƒjp|t|ƒjo|||id/s  Ç(