;ò
¢)?Bc           @   s\   d  Z  d k Z d k l Z e i d e i ƒ Z e i d e i ƒ Z d „  Z d „  Z	 d S(   sd  Netscape Messaging Server bounce formats.

I've seen at least one NMS server version 3.6 (envy.gmp.usyd.edu.au) bounce
messages of this format.  Bounces come in DSN MIME format, but don't include
any -Recipient: headers.  Gotta just parse the text :(

NMS 4.1 (dfw-smtpin1.email.verio.net) seems even worse, but we'll try to
decipher the format here too.

N(   s   StringIOs;   This Message was undeliverable due to the following reason:s.   (?P<reply>please reply to)?.*<(?P<addr>[^>]*)>c         C   sF   |  i ƒ  o( x2 |  i ƒ  D] } t | | ƒ q Wn | i |  ƒ d  S(   N(   s   msgs   is_multiparts   get_payloads   parts   flattens   leavess   append(   s   msgs   leavess   part(    (    s)   /var/mailman/Mailman/Bouncers/Netscape.pys   flatten)   s
     c   	      C   sX  |  i ƒ  o t Sn t } g  } t |  | ƒ xK t t t | ƒ d ƒ | ƒ D]* \ } } | i ƒ  d j o | } PqO qO W| o t Sn t | i ƒ  ƒ } g  } x¨ n o  | i ƒ  } | o Pn t i | ƒ } | om xj n o^ | i ƒ  } | o Pn t i | ƒ } | o | i d ƒ o | i | i d ƒ ƒ qá qè Wq¨ q¯ W| Sd  S(   Ni   s
   text/plains   replys   addr(   s   msgs   is_multiparts   Nones   plainmsgs   leavess   flattens   zips   ranges   lens   is   subparts   get_types   StringIOs   get_payloads   bodys   addrss   readlines   lines   pcres   searchs   mos   acres   groups   append(	   s   msgs   bodys   subparts   is   leavess   plainmsgs   lines   mos   addrs(    (    s)   /var/mailman/Mailman/Bouncers/Netscape.pys   process3   s<      	  ((
   s   __doc__s   res	   cStringIOs   StringIOs   compiles
   IGNORECASEs   pcres   acres   flattens   process(   s   pcres   StringIOs   processs   res   flattens   acre(    (    s)   /var/mailman/Mailman/Bouncers/Netscape.pys   ?   s   				
