‡Æ
ÂMö9c       s…   d  Z  d k Z d k Z d k Z d e i f d „  ƒ  YZ d f  d „  ƒ  YZ d f  d „  ƒ  YZ d k Z h  Z	 d „  Z
 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 '
' for single-line responses, '
.
'
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 '
', in
order to process the single-line greeting.  Just before issuing a
'LIST' command you'll set it to '
.
'.  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•   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   conns%   /mit/python/lib/python2.0/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   terms%   /mit/python/lib/python2.0/asynchat.pys   set_terminatorD s     c    s   |  i Sd  S(   N(   s   selfs
   terminator(   s   selfs%   /mit/python/lib/python2.0/asynchat.pys   get_terminatorH 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 |  _ nyt | ƒ t d ƒ j o{ | } | | j  o- |  i |  i ƒ d |  _ |  i | |  _ n8 |  i |  i |  ƒ |  i | |  _ d |  _ |  i ƒ  nå t	 | ƒ } 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   strings   finds   indexs   find_prefix_at_end(   s   selfs   datas   whys   lbs
   terminators   ns   terminator_lens   indexs%   /mit/python/lib/python2.0/asynchat.pys   handle_readP sL    
	 
			c    s   |  i ƒ  d  S(   N(   s   selfs   initiate_send(   s   selfs%   /mit/python/lib/python2.0/asynchat.pys   handle_write’ s    c    s   |  i ƒ  d  S(   N(   s   selfs   close(   s   selfs%   /mit/python/lib/python2.0/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   datas%   /mit/python/lib/python2.0/asynchat.pys   push˜ s    c    s   |  i i | ƒ |  i ƒ  d  S(   N(   s   selfs   producer_fifos   pushs   producers   initiate_send(   s   selfs   producers%   /mit/python/lib/python2.0/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   selfs%   /mit/python/lib/python2.0/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   selfs%   /mit/python/lib/python2.0/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   selfs%   /mit/python/lib/python2.0/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   _string_types   ps   datas%   /mit/python/lib/python2.0/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   obss   num_sents   whys%   /mit/python/lib/python2.0/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   selfs%   /mit/python/lib/python2.0/asynchat.pys   discard_buffersÞ s
    		 
(   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%   /mit/python/lib/python2.0/asynchat.pys
   async_chat5 s"    			B						
			s   simple_producerc      s   d d „ Z  d „  Z RS(   Nc    s   | |  _  | |  _ d  S(   N(   s   datas   selfs   buffer_size(   s   selfs   datas   buffer_sizes%   /mit/python/lib/python2.0/asynchat.pys   __init__è s    	i   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   results%   /mit/python/lib/python2.0/asynchat.pys   moreì s    		(   s   __init__s   more(    s%   /mit/python/lib/python2.0/asynchat.pys   simple_produceræ s    s   fifoc      s;   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   lists%   /mit/python/lib/python2.0/asynchat.pys   __init__÷ s    c    s   t  |  i ƒ Sd  S(   N(   s   lens   selfs   list(   s   selfs%   /mit/python/lib/python2.0/asynchat.pys   __len__ý s    c    s   |  i g  j Sd  S(   N(   s   selfs   list(   s   selfs%   /mit/python/lib/python2.0/asynchat.pys   is_empty s    c    s   |  i d Sd  S(   Ni    (   s   selfs   list(   s   selfs%   /mit/python/lib/python2.0/asynchat.pys   firsts    c    s   |  i i | ƒ d  S(   N(   s   selfs   lists   appends   data(   s   selfs   datas%   /mit/python/lib/python2.0/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   results%   /mit/python/lib/python2.0/asynchat.pys   pop	s
    

(   s   Nones   __init__s   __len__s   is_emptys   firsts   pushs   pop(    s%   /mit/python/lib/python2.0/asynchat.pys   fifoö s    				c    sŸ   t  i |  ƒ o t  |  Sn€ |  d } x8 t d t |  ƒ ƒ d r } d |  | d | f } q? Wt i | d ƒ } | t |  ƒ f t  |  <| t |  ƒ f Sd  S(   Ni   i    s	   %c\(%s\)?s   $(	   s   prefix_caches   has_keys   needles   regs   ranges   lens   is   regexs   compile(   s   needles   regs   is%   /mit/python/lib/python2.0/asynchat.pys   prefix_regex,s     c    s^   t  | ƒ \ } } t |  ƒ } | i |  t d | | ƒ ƒ } | d j o | | Sn d Sd  S(   Ni    (
   s   prefix_regexs   needles   regs   lengths   lens   haystacks   lhs   searchs   maxs   result(   s   haystacks   needles   regs   lengths   lhs   results%   /mit/python/lib/python2.0/asynchat.pys   find_prefix_at_end7s    (   s   __doc__s   sockets   asyncores   strings
   dispatchers
   async_chats   simple_producers   fifos   regexs   prefix_caches   prefix_regexs   find_prefix_at_end(    s%   /mit/python/lib/python2.0/asynchat.pys   ?/ s   			±2		