-
<c       s|     d  Z  / 1 d k Z 2 d k Z 4 d e i f d     YZ  d f  d     YZ  d f  d     YZ d   Z d S(	   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.
Ns
   async_chatc      s   4 t  Z d  Z 6 : d Z ; d Z = e d  Z C d   Z G d   Z O d   Z	  d   Z
  d   Z  d   Z  d	   Z  d
   Z  d   Z  d   Z  d   Z  d   Z  d   Z RS(   s   This is an abstract class.  You must derive from this class, and add
    the two methods collect_incoming_data() and found_terminator()i   c    sD   = > d |  _ ? d |  _ @ t   |  _ A t i i |  |  d  S(   Ns    (	   s   selfs   ac_in_buffers   ac_out_buffers   fifos   producer_fifos   asyncores
   dispatchers   __init__s   conn(   s   selfs   conn(    (    s   /usr/lib/python2.2/asynchat.pys   __init__= s   c    s   C D E | |  _ d S(   sR   Set the input delimiter.  Can be a fixed string of any length, an integer, or NoneN(   s   terms   selfs
   terminator(   s   selfs   term(    (    s   /usr/lib/python2.2/asynchat.pys   set_terminatorC s   c    s   G H |  i Sd  S(   N(   s   selfs
   terminator(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   get_terminatorG s   c    s  O Q y R |  i |  i  } Wn/ S t i j
 o } T |  i   U d  Sn XW |  i | |  _ ^ x%^ |  i o_ t	 |  i  } ` |  i   } a | t j o# c |  i |  i  d d |  _ ne t |  t d  j o g | } h | | j  o6 i |  i |  i  j d |  _ k |  i | |  _ nD m |  i |  i |   n |  i | |  _ o d |  _ p |  i   ny t	 |  } z |  i i |  } { | d j oS } | d j o  |  i |  i |   n  |  i | | |  _  |  i   n  t |  i |  }  | oH  | | j o0  |  i |  i |    |  i | |  _ n  Pn   |  i |  i   d |  _ qj Wd  S(   Ns    i    i(   s   selfs   recvs   ac_in_buffer_sizes   datas   sockets   errors   whys   handle_errors   ac_in_buffers   lens   lbs   get_terminators
   terminators   Nones   collect_incoming_datas   types   ns   found_terminators   terminator_lens   finds   indexs   find_prefix_at_end(   s   selfs   indexs   lbs   datas   ns   terminator_lens
   terminators   why(    (    s   /usr/lib/python2.2/asynchat.pys   handle_readO sL    		
c    s     |  i   d  S(   N(   s   selfs   initiate_send(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   handle_write s   c    s     |  i   d  S(   N(   s   selfs   close(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   handle_close s   c    s-     |  i i t |    |  i   d  S(   N(   s   selfs   producer_fifos   pushs   simple_producers   datas   initiate_send(   s   selfs   data(    (    s   /usr/lib/python2.2/asynchat.pys   push s   c    s'     |  i i |   |  i   d  S(   N(   s   selfs   producer_fifos   pushs   producers   initiate_send(   s   selfs   producer(    (    s   /usr/lib/python2.2/asynchat.pys   push_with_producer s   c    s#      t  |  i  |  i j Sd S(   s4   predicate for inclusion in the readable for select()N(   s   lens   selfs   ac_in_buffers   ac_in_buffer_size(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   readable s   c    s5      |  i d j o |  i i   o |  i Sd S(   s4   predicate for inclusion in the writable for select()s    N(   s   selfs   ac_out_buffers   producer_fifos   is_emptys	   connected(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   writable s   c    s      |  i i t  d S(   sA   automatically close this channel once the outgoing queue is emptyN(   s   selfs   producer_fifos   pushs   None(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   close_when_done s   c    s0    t  d  }  x d o	 t |  i  o  |  i i   }  | t j o:  |  i o!  |  i i	    |  i
   n  d  SnE  t  |  | j o.  |  i i	    |  i | |  _  d  Sn  | i   }  | o  |  i | |  _  d  Sn  |  i i	   n  d  Sq Wd  S(   Ns    i   (   s   types   _string_types   lens   selfs   producer_fifos   firsts   ps   Nones   ac_out_buffers   pops   closes   mores   data(   s   selfs   ps   datas   _string_type(    (    s   /usr/lib/python2.2/asynchat.pys   refill_buffer s(    

c    s     |  i }  t |  i  | j  o  |  i   n  |  i o |  i ow  y>  |  i |  i |   }  | o  |  i | |  _ n Wn/  t	 i
 j
 o }  |  i    d  Sn Xn d  S(   N(   s   selfs   ac_out_buffer_sizes   obss   lens   ac_out_buffers   refill_buffers	   connecteds   sends   num_sents   sockets   errors   whys   handle_error(   s   selfs   num_sents   whys   obs(    (    s   /usr/lib/python2.2/asynchat.pys   initiate_send s   
c    sG     d |  _  d |  _  x"  |  i o  |  i i   q! Wd  S(   Ns    (   s   selfs   ac_in_buffers   ac_out_buffers   producer_fifos   pop(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   discard_buffers s
    (   s   __name__s
   __module__s   __doc__s   ac_in_buffer_sizes   ac_out_buffer_sizes   Nones   __init__s   set_terminators   get_terminators   handle_reads   handle_writes   handle_closes   pushs   push_with_producers   readables   writables   close_when_dones   refill_buffers   initiate_sends   discard_buffers(    (    (    s   /usr/lib/python2.2/asynchat.pys
   async_chat4 s"   		B
s   simple_producerc      s&    t  Z  d d  Z  d   Z RS(   Ni   c    s     | |  _   | |  _ d  S(   N(   s   datas   selfs   buffer_size(   s   selfs   datas   buffer_size(    (    s   /usr/lib/python2.2/asynchat.pys   __init__ s   c    sv     t  |  i  |  i j o4  |  i |  i  }  |  i |  i |  _  | Sn   |  i }  d |  _  | Sd  S(   Ns    (   s   lens   selfs   datas   buffer_sizes   result(   s   selfs   result(    (    s   /usr/lib/python2.2/asynchat.pys   more s   (   s   __name__s
   __module__s   __init__s   more(    (    (    s   /usr/lib/python2.2/asynchat.pys   simple_producer s   	s   fifoc      sV    t  Z  e d  Z  d   Z  d   Z d   Z d   Z d   Z RS(   Nc    s.     | o  g  |  _  n  | |  _  d  S(   N(   s   lists   self(   s   selfs   list(    (    s   /usr/lib/python2.2/asynchat.pys   __init__ s   c    s     t  |  i  Sd  S(   N(   s   lens   selfs   list(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   __len__ s   c    s     |  i g  j Sd  S(   N(   s   selfs   list(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   is_empty s   c    s   |  i d Sd  S(   Ni    (   s   selfs   list(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   firsts   c    s   |  i i |  d  S(   N(   s   selfs   lists   appends   data(   s   selfs   data(    (    s   /usr/lib/python2.2/asynchat.pys   pushs   c    sO   	|  i o. 
|  i d } |  i d =d | f Sn d t f Sd  S(   Ni    i   (   s   selfs   lists   results   None(   s   selfs   result(    (    s   /usr/lib/python2.2/asynchat.pys   pops
   (	   s   __name__s
   __module__s   Nones   __init__s   __len__s   is_emptys   firsts   pushs   pop(    (    (    s   /usr/lib/python2.2/asynchat.pys   fifo s   	c    s|   t  |  }  d } !xP t d |  D!]< } "|  | | | | |  j o #| | } $Pn q. W%| Sd  S(   Ni    i   (   s   lens   needles   nls   results   ranges   is   haystack(   s   haystacks   needles   nls   results   i(    (    s   /usr/lib/python2.2/asynchat.pys   find_prefix_at_ends   	 	!(   s   __doc__s   sockets   asyncores
   dispatchers
   async_chats   simple_producers   fifos   find_prefix_at_end(   s   asyncores   sockets   find_prefix_at_ends   simple_producers   fifos
   async_chat(    (    s   /usr/lib/python2.2/asynchat.pys   ?/ s   )