� �fc@s�dZddlZddlZddlZddlZddlZdZdejfd��YZdd#d d$d d ddddddddgZ x�e e e ��D]�Z e e Z ee �ed�kr�eje ej�Z nBgZx*e D]"Z ejeje ej��q�Wee�Z [e e e <[ q�W[ ddejdej�ejd�ejdej�gZejdejejB�Zd�ZegZd�Zd�Zd �Zed!ks�ejd"ekr�e�ndS(%s6mailerdaemon - classes to parse mailer-daemon messagesi����Nsmailerdaemon.Unparseablet ErrorMessagecBs#eZd�Zd�Zd�ZRS(cCs tjj||�d|_dS(Nt(trfc822tMessaget__init__tsub(tselftfp((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyR scCsU|jd�}|sdS|j�}|jd�r8dSd|krHdS||_dS(NtSubjectis waiting mailitwarning(t getheadertlowert startswithR(RR((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt is_warnings   cCsPxCtD];}|j�y||j|j�SWqtk rAqXqWt�dS(N(t EMPARSERSt rewindbodyRRt Unparseable(Rtp((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt get_errorss   (t__name__t __module__RR R(((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyR s  s.error: (?Punresolvable): (?P.+)s?----- The following addresses had permanent fatal errors ----- s(?P[^ ].*) ( .* )?s(remote execution.* .*rmail (?P.+)s8The following recipients did not receive your message: sK +(?P.*) (The following recipients did not receive your message: )?s?------- Failure Reasons -------- (?P.*) (?P.*)s ^<(?P.*)>: (?P.*)s=^(?PUser mailbox exceeds allowed size): (?P.+)s0^5\d{2} <(?P[^ >]+)>\.\.\. (?P.+)s)^Original-Recipient: rfc822;(?P.*)sR^did not reach the following recipient\(s\): (?P.*) on .* +(?P.*)s+^ <(?P[^ >]+)> \.\.\. (?P.*)s@^Report on your message to: (?P.*) Reason: (?P.*)s^^Your message was not delivered to +(?P.*) +for the following reason: +(?P.*)sO^ was not +(?P[^ ].*?) * .* .* .* because:.* +(?P[^ ].*?) * Rs^5\d{2} <>\.\.\. (?P.*)s<>\.\.\. (?P.*)s^<<< 5\d{2} (?P.*)s,===== stderr was ===== rmail: (?P.*)s ^Diagnostic-Code: (?P.*)s^From:c Cs|j�}tj|�}|dkr6t|�}n|jd�}g}g}d}x*tD]"}t|�td �kr|dj|d|�}|dk r�y|jd�}Wnt k r�nXxL|dj ||j d�|�}|dkr�Pn|j |jd��q�WPq�q^|j|d|�}|dk r^|j |jd��y|jd�}Wnt k r{nXPq^q^W|s�t �n|s�|}|d dkr�|d}nxtD] }t|�td�kr�x�tt|�ddd�D]�} || } tjtj| �j|jd ��tj�} | j|�}|dk r�|j d j| j�d |jd�j���|| =q�q�Wq�n|j|�}|dk r�|jd�}Pq�q�Wnx8|D]0} |j d j| j�d |j���q�W|S( Nitreasonitemailisreturned mail: Ri����s<>t s: ((treadtemparse_list_fromtsearchtNonetlentstarttemparse_list_listttypetgroupt IndexErrortmatchtendtappendRtemparse_list_reasontrangetretcompiletescapetjointsplitt MULTILINEtstrip( RRtdatatrest from_indexterrorstemailsRtregexptiRtexp((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt emparse_list\sj     "      # 0 3   .cCs@t|�}t|�}||kr(dS||kr8dSdSdS(Ni����ii(tint(tatb((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyt sort_numeric�s    cCs�tj|�tjd�}i}i}i}d}}}t|d�tjd��} | jt�x�| D]�} t| �} t | �} | j d�} d| | dfG| j �r�| j �dGH|d}|rntj | d | �qnqnny| j�}Wn-tk r4d GH|d}| j �qnnXt|�Gd GHx�|D]�}y7| jd �dd!\}}dtj||f}Wn d}nX|j|�s�d||�Rt.tFroms %s %-40s is warning onlyt,s** Not parseableR1tdateis%s %02ds??????s%s (%s)s--------------s files parsed,sfiles warning-only,sfiles unparseables %d %s - %s %si(tostchdirR'R(tfiltertlistdirtsortR:topenRtgetaddrR tclosetrenameRRRtgetdatetcalendart month_abbrthas_keytkeysR$(tdirtmodifyR<t errordictt errorfirstt errorlasttnoktnwarntnbadtfilesR;RtmtsenderR1tetmmtddRAtlisttnumtfirsttlast((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pytparsedir�sj                 ) cCs�d}ttj�dkrAtjddkrAd}tjd=nttj�dkr~x2tjdD]}t||�qdWn td|�dS(Niis-ds/ufs/jack/Mail/errorsinbox(RtsystargvRb(RQtfolder((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pytmain�s( t__main__i(s?----- The following addresses had permanent fatal errors ----- s(?P[^ ].*) ( .* )?(s8The following recipients did not receive your message: sK +(?P.*) (The following recipients did not receive your message: )?(t__doc__RRLR'RBRcRRRRR&RR4txRR(R,txlR$ttupleR%t IGNORECASERR6RR:RbRfRRd(((s2/usr/lib64/python2.7/Tools/scripts/mailerdaemon.pyts`     $        9   D