???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................ó
fc           @   sě  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d Z d e j f d     YZ d d# d	 d$ d d d d d d d d d d g Z	 xŁ e
 e e	   D] Z e	 e Z e e  e d  k rä e j e e j  Z nB g  Z x* e D]" Z e j e j e e j   qń We e  Z [ e e	 e <[ q¤ W[ d d e j d e j  e j d  e j d e j  g Z e j d e j e j B Z d   Z e g Z d   Z d   Z d    Z e d! k sŢe j d" e k rče   n  d S(%   s6   mailerdaemon - classes to parse mailer-daemon messagesi˙˙˙˙Ns   mailerdaemon.Unparseablet   ErrorMessagec           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   s    t  j j |  |  d |  _ d  S(   Nt    (   t   rfc822t   Messaget   __init__t   sub(   t   selft   fp(    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyR      s    c         C   sU   |  j  d  } | s d S| j   } | j d  r8 d Sd | k rH d S| |  _ d S(   Nt   Subjecti    s   waiting maili   t   warning(   t	   getheadert   lowert
   startswithR   (   R   R   (    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt
   is_warning   s      	c         C   sP   xC t  D]; } |  j   y | |  j |  j  SWq t k
 rA q Xq Wt  d  S(   N(   t	   EMPARSERSt
   rewindbodyR   R   t   Unparseable(   R   t   p(    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt
   get_errors   s    
(   t   __name__t
   __module__R   R   R   (    (    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyR       s   		
s.   error: (?P<reason>unresolvable): (?P<email>.+)s?   ----- The following addresses had permanent fatal errors -----
s   (?P<email>[^ 
].*)
( .*
)?s(   remote execution.*
.*rmail (?P<email>.+)s8   The following recipients did not receive your message:

sK    +(?P<email>.*)
(The following recipients did not receive your message:

)?s?   ------- Failure Reasons  --------

(?P<reason>.*)
(?P<email>.*)s    ^<(?P<email>.*)>:
(?P<reason>.*)s=   ^(?P<reason>User mailbox exceeds allowed size): (?P<email>.+)s0   ^5\d{2} <(?P<email>[^
>]+)>\.\.\. (?P<reason>.+)s)   ^Original-Recipient: rfc822;(?P<email>.*)sR   ^did not reach the following recipient\(s\):

(?P<email>.*) on .*
 +(?P<reason>.*)s+   ^ <(?P<email>[^
>]+)> \.\.\. (?P<reason>.*)s@   ^Report on your message to: (?P<email>.*)
Reason: (?P<reason>.*)s^   ^Your message was not delivered to +(?P<email>.*)
 +for the following reason:
 +(?P<reason>.*)sO   ^ was not +(?P<email>[^ 
].*?) *
.*
.*
.*
 because:.*
 +(?P<reason>[^ 
].*?) *
R   s   ^5\d{2} <>\.\.\. (?P<reason>.*)s   <>\.\.\. (?P<reason>.*)s   ^<<< 5\d{2} (?P<reason>.*)s,   ===== stderr was =====
rmail: (?P<reason>.*)s    ^Diagnostic-Code: (?P<reason>.*)s   ^From:c         C   s  |  j    } t j |  } | d  k r6 t |  } n | j d  } g  } g  } d  } x*t D]"} t |  t d  k r| d j | d |  } | d  k	 ry | j d  } Wn t	 k
 rÇ n XxL | d j
 | | j d  |  } | d  k rý Pn  | j | j d   qË WPqq^ | j | d |  } | d  k	 r^ | j | j d   y | j d  } Wn t	 k
 r{n XPq^ q^ W| st  n  | sŐ| } | d  d k rź| d } n  xt D]} t |  t d  k r xś t t |  d d d  D] }	 | |	 }
 t j t j |
  j | j d	   t j  } | j |  } | d  k	 rţ| j d
 j |
 j   d | j d  j     | |	 =qţqţWqĂn  | j |  } | d  k	 rĂ| j d  } PqĂqĂWn  x8 | D]0 }
 | j d
 j |
 j   d | j     qÜW| S(   Ni    t   reasoni   t   emaili   s   returned mail: R   i˙˙˙˙s   <>t    s   : (    (   t   readt   emparse_list_fromt   searcht   Nonet   lent   startt   emparse_list_listt   typet   groupt
   IndexErrort   matcht   endt   appendR   t   emparse_list_reasont   ranget   ret   compilet   escapet   joint   splitt	   MULTILINEt   strip(   R   R   t   datat   rest
   from_indext   errorst   emailsR   t   regexpt   iR   t   exp(    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt   emparse_list\   sj    "	#
03.c         C   s@   t  |   }  t  |  } |  | k  r( d S|  | k r8 d Sd Sd  S(   Ni˙˙˙˙i   i    (   t   int(   t   at   b(    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt   sort_numeric   s      c         C   sĚ  t  j |   t j d  } i  } i  } i  } d } } } t | d  t  j d   }	 |	 j t  x˝|	 D]ľ}
 t |
  } t	 |  } | j
 d  } d |
 | d f G| j   rő | j   d GH| d } | rn t  j |
 d	 |
  qn qn n  y | j   } Wn- t k
 r4d
 GH| d } | j   qn n Xt |  Gd GHxŤ | D]Ł } y7 | j d  d d !\ } } d t j | | f } Wn d } n X| j |  sČd | | <d |
 | f | | <n | | d | | <d |
 | f | | <qKW| j   | d } | rn t  j |
 d	 |
  qn qn Wd GH| Gd G| Gd G| Gd GHd GHg  } x9 | j   D]+ } | j | | | | | | | f  q]W| j   x/ | D]' \ } } } } d | | | | f GHqWd  S(   Ns   ^[0-9]*$i    c         S   s   | j  |   d  k	 S(   N(   R"   R   (   t   fnt   pat(    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt   <lambda>§   R   t   .t   Froms	   %s	%-40s	i   s   warning onlyt   ,s   ** Not parseableR1   t   datei   s   %s %02ds   ??????s   %s (%s)s   --------------s   files parsed,s   files warning-only,s   files unparseables   %d %s - %s	%si   (   t   ost   chdirR'   R(   t   filtert   listdirt   sortR:   t   openR    t   getaddrR   t   closet   renameR   R   R   t   getdatet   calendart
   month_abbrt   has_keyt   keysR$   (   t   dirt   modifyR<   t	   errordictt
   errorfirstt	   errorlastt   nokt   nwarnt   nbadt   filesR;   R   t   mt   senderR1   t   et   mmt   ddRA   t   listt   numt   firstt   last(    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt   parsedir   sj    







	)
c          C   s   d }  t  t j  d k rA t j d d k rA d }  t j d =n  t  t j  d k r~ x2 t j d D] } t | |   qd Wn t d |   d  S(   Ni    i   s   -ds   /ufs/jack/Mail/errorsinbox(   R   t   syst   argvRb   (   RQ   t   folder(    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt   mainâ   s    (t   __main__i    (   s?   ----- The following addresses had permanent fatal errors -----
s   (?P<email>[^ 
].*)
( .*
)?(   s8   The following recipients did not receive your message:

sK    +(?P<email>.*)
(The following recipients did not receive your message:

)?(   t   __doc__R   RL   R'   RB   Rc   R   R   R    R   R&   R   R4   t   xR   R(   R,   t   xlR$   t   tupleR%   t
   IGNORECASER   R6   R   R:   Rb   Rf   R   Rd   (    (    (    s2   /usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt   <module>   s`   $  	
 
	9			D	