-í
æ¶<c       sd   d  Z  d k Z d k Z 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›   t  Z d  Z d Z d Z e 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 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    s5   d |  _ d |  _ t ƒ  |  _ 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   | |  _ 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   |  i Sd  S(   N(   s   selfs
   terminator(   s   self(    (    s   /usr/lib/python2.2/asynchat.pys   get_terminatorG s    c    s  y |  i |  i ƒ } Wn& t i j
 o } |  i ƒ  d  Sn X|  i | |  _ xÈ|  i o½t	 |  i ƒ } |  i ƒ  } | t j o |  i |  i ƒ d |  _ nut | ƒ t d ƒ j o{ | } | | j  o- |  i |  i ƒ d |  _ |  i | |  _ n8 |  i |  i |  ƒ |  i | |  _ d |  _ |  i ƒ  ná t	 | ƒ } |  i i | ƒ } | d j oG | d j o |  i |  i |  ƒ n |  i | | |  _ |  i ƒ  no t |  i | ƒ } | o< | | j o* |  i |  i |  ƒ |  i | |  _ n Pn |  i |  i ƒ d |  _ qR 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    s,   |  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    sñ   t  d ƒ } xÞ d oÖ t |  i ƒ o¾ |  i i ƒ  } | t j o. |  i o |  i i	 ƒ  |  i
 ƒ  n d  Sn9 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 ob y5 |  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    s5   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    s^   t  |  i ƒ |  i j o+ |  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      sA   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    s=   |  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    sa   t  | ƒ } d } xD t d | ƒ D]3 } |  | | | | |  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   		±)