;ō
Ē)?Bc           @   st   d  Z  d k Z d k l Z d   Z e i d e i  Z e i d e i  Z e i d  Z	 d   Z
 d   Z d S(	   sT  Parse bounce messages generated by Postfix.

This also matches something called `Keftamail' which looks just like Postfix
bounces with the word Postfix scratched out and the word `Keftamail' written
in in crayon.

It also matches something claiming to be `The BNS Postfix program', and
`SMTP_Gateway'.  Everybody's gotta be different, huh?
N(   s   StringIOc         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/Postfix.pys   flatten    s
     s5   [ \t]*the\s*(bns)?\s*(postfix|keftamail|smtp_gateway)s   failure reason:$s   <(?P<addr>[^>]*)>:c         C   sŲ   g  } t |  i    } d } x° n oĻ | i   } | o Pn | i   } | d j o t	 i
 |  p t i
 |  o
 d } q! | d j o | o4 t i |  } | o | i | i d   qĖ q! q( W| Sd  S(   Ni    i   s   addr(   s   addrss   StringIOs   msgs   get_payloads   bodys   states   readlines   lines   rstrips   pcres   matchs   rcres   acres   searchs   mos   appends   group(   s   msgs   bodys   mos   states   addrss   line(    (    s(   /var/mailman/Mailman/Bouncers/Postfix.pys   findaddr0   s      -
#c         C   s   |  i   d j o t Sn g  } t |  |  xN | D]F } | i   d j o | i d d  i   d j o t |  Sq5 q5 Wt Sd  S(   Ns   multipart/mixeds
   text/plains   content-descriptions    s   notification(	   s   msgs   get_types   Nones   leavess   flattens   subparts   gets   lowers   findaddr(   s   msgs   subparts   leaves(    (    s(   /var/mailman/Mailman/Bouncers/Postfix.pys   processI   s     2(   s   __doc__s   res	   cStringIOs   StringIOs   flattens   compiles
   IGNORECASEs   pcres   rcres   acres   findaddrs   process(   s   pcres   findaddrs   rcres   StringIOs   processs   res   flattens   acre(    (    s(   /var/mailman/Mailman/Bouncers/Postfix.pys   ?   s   				