U e5dE3ã@sNddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl Z ddl Z z ddl Z Wne k r„dZ YnXdddddddd d d d d dddddgZej d¡ZGdd„dƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„dejjƒZGdd „d eƒZGd d!„d!eƒZGd"d „d eƒZGd#d „d eƒZGd$d „d eƒZGd%d „d eƒZ Gd&d'„d'ƒZ!Gd(d)„d)e!ƒZ"d„Z d?Z!dFd@dA„Z"dS)GrNTcCs tj tj |¡¡|_||_dS©N)ÚosÚpathÚabspathÚ expanduserÚ_pathÚ_factory©ÚselfrÚfactoryÚcreate©rú/usr/lib64/python3.8/mailbox.pyÚ__init__$szMailbox.__init__cCs tdƒ‚dS©Nz&Method must be implemented by subclass©ÚNotImplementedError©rÚmessagerrr Úadd)sz Mailbox.addcCs tdƒ‚dSr"r#©rÚkeyrrr Úremove-szMailbox.removecCs| |¡dSr)r*r(rrr Ú __delitem__1szMailbox.__delitem__cCs(z| |¡Wntk r"YnXdSr)r*ÚKeyErrorr(rrr Údiscard4szMailbox.discardcCs tdƒ‚dSr"r#©rr)r&rrr Ú __setitem__;szMailbox.__setitem__cCs*z | |¡WStk r$|YSXdSr)Ú __getitem__r,)rr)Údefaultrrr Úget?s z Mailbox.getc CsB|js| |¡St | |¡¡}| |¡W5QR£SQRXdSr)rÚ get_messageÚ contextlibÚclosingÚget_file)rr)Úfilerrr r0Fs zMailbox.__getitem__cCs tdƒ‚dSr"r#r(rrr r3NszMailbox.get_messagecCst | |¡¡ ¡Sr©ÚemailÚmessage_from_bytesÚ get_bytesZ as_stringr(rrr Ú get_stringRszMailbox.get_stringcCs tdƒ‚dSr"r#r(rrr r;YszMailbox.get_bytescCs tdƒ‚dSr"r#r(rrr r6]szMailbox.get_filecCs tdƒ‚dSr"r#©rrrr ÚiterkeysaszMailbox.iterkeyscCs t| ¡ƒSr)Úlistr>r=rrr Úkeysesz Mailbox.keysc cs>| ¡D]0}z ||}Wntk r0YqYnX|VqdSr©r>r,©rr)Úvaluerrr Ú itervaluesis    zMailbox.itervaluescCs| ¡Sr)rDr=rrr Ú__iter__rszMailbox.__iter__cCs t| ¡ƒSr)r?rDr=rrr ÚvaluesuszMailbox.valuesc csB| ¡D]4}z ||}Wntk r0YqYnX||fVqdSrrArBrrr Ú iteritemsys    zMailbox.iteritemscCs t| ¡ƒSr)r?rGr=rrr Úitems‚sz Mailbox.itemscCs tdƒ‚dSr"r#r(rrr Ú __contains__†szMailbox.__contains__cCs tdƒ‚dSr"r#r=rrr Ú__len__ŠszMailbox.__len__cCs| ¡D]}| |¡qdSr)r@r-r(rrr ÚclearŽs z Mailbox.clearcCs4z ||}Wntk r$|YSX| |¡|Sr)r,r-)rr)r1Úresultrrr Úpop“s    z Mailbox.popcCs*| ¡D]}|| |¡fStdƒ‚dS)NzNo messages in mailbox)r>rMr,r(rrr Úpopitemœs zMailbox.popitemc Cstt|dƒr| ¡}nt|dƒr(| ¡}n|}d}|D].\}}z |||<Wq4tk r`d}Yq4Xq4|rptdƒ‚dS)NrGrHFTzNo message with key(s))ÚhasattrrGrHr,)rÚargÚsourceZbad_keyr)r&rrr Úupdate£s       zMailbox.updatecCs tdƒ‚dSr"r#r=rrr Úflush´sz Mailbox.flushcCs tdƒ‚dSr"r#r=rrr Úlock¸sz Mailbox.lockcCs tdƒ‚dSr"r#r=rrr Úunlock¼szMailbox.unlockcCs tdƒ‚dSr"r#r=rrr ÚcloseÀsz Mailbox.closecCs.z | d¡WStk r(tdƒ‚YnXdS)Nrz?String input must be ASCII-only; use bytes or a Message instead)ÚencodeÚ UnicodeErrorÚ ValueErrorr%rrr Ú_string_to_bytesÄs zMailbox._string_to_bytesFc Csüt|tjjƒrvt ¡}tj ||d¡}| |¡|  d¡|  ¡}|  dt ¡}|  |¡|jrr| t ¡sr|  t ¡n‚t|tttjfƒrt|tjƒr¬t dtd¡| ¡}t|tƒrÀ| |¡}|rÐ|  dd¡}|  dt ¡}|  |¡|jrø| t ¡sø|  t ¡nòt|dƒrèt|dƒr2t d td¡|j}d}| ¡}| d ¡r\|dd …d}n| d ¡rx|dd …d}|s‚qÂ|r¤| d¡r¤d|dd…}|  dt ¡}|  |¡|}q6|jrø|rø| t ¡sø|  t ¡ntdt|ƒƒ‚dS)Nró ú8Use of StringIO input is deprecated, use BytesIO insteadés From s >From ÚreadÚbufferúDUse of text mode files is deprecated, use a binary mode file insteadó éþÿÿÿó éÿÿÿÿóFrom s>From éúInvalid message type: %s)Ú isinstancer9r&rÚioÚBytesIOÚ generatorÚBytesGeneratorÚflattenÚseekr^ÚreplaceÚlinesepÚwriteÚ_append_newlineÚendswithÚstrÚbytesÚStringIOÚwarningsÚwarnÚDeprecationWarningÚgetvaluerZrOr_ÚreadlineÚ startswithÚ TypeErrorÚtype) rr&ÚtargetZ mangle_from_r_ÚgenÚdataZlastlineÚlinerrr Ú _dump_messageÑs`     ÿ        ÿ     zMailbox._dump_message)NT)N)N)N)F)#Ú__name__Ú __module__Ú __qualname__r!r'r*r+r-r/r2r0r3r<r;r6r>r@rDrErFrGrHrIrJrKrMrNrRrSrTrUrVrZrrrƒrrrr r!s@       c@sÖeZdZdZd5dd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,Zd-d.„Zd/d0„Zd1d2„Zd3d4„ZdS)6rú:NTcCs¬t ||||¡tj |jd¡tj |jd¡tj |jd¡dœ|_tj |j¡sŠ|r€t |jd¡|j  ¡D]}t |d¡qln t |jƒ‚i|_ dddœ|_ d|_ d|_dS) NÚtmpÚnewÚcur)rˆr‰rŠéÀr)rŠr‰gš™™™™™¹?)rr!rrÚjoinrÚ_pathsÚexistsÚmkdirrFrÚ_tocÚ _toc_mtimesÚ _last_readÚ _skewfactor)rÚdirnamerrrrrr r! sý  zMaildir.__init__c Cs~| ¡}z| ||¡Wn*tk rB| ¡t |j¡‚YnXt|ƒt|t ƒr||  ¡}|j |  ¡}||j kr„d}nd}d}tj  |j¡ |j ¡d}tj  |j|||¡}t|t ƒrÞt |jtj  |j¡| ¡f¡zLzt |j|¡Wn(ttfk rt |j|¡YnXt |j¡WnNtk rx}z.t |j¡|jtjkrftd|ƒ‚n‚W5d}~XYnX|S)NÚr‰rz$Name clash with existing message: %s)Ú _create_tmprƒÚ BaseExceptionrVrr*ÚnameÚ _sync_closerhr Ú get_subdirÚcolonÚget_inforÚbasenameÚsplitrŒrÚutimeÚgetatimeÚget_dateÚlinkÚAttributeErrorÚPermissionErrorÚrenameÚOSErrorÚerrnoZEEXISTr)rr&Ztmp_fileÚsubdirÚsuffixÚuniqÚdestÚerrr r'!sF    ÿ ÿz Maildir.addcCs t tj |j| |¡¡¡dSr)rr*rrŒrÚ_lookupr(rrr r*KszMaildir.removec Cs,z| |¡Wnttfk r&YnXdSr)r*r,ÚFileNotFoundErrorr(rrr r-OszMaildir.discardc CsÊ| |¡}| |¡}| |¡}t|tƒr.|}n|}tj |¡}|j|kr`|j| |j¡d}nd}|  |¡tj  |j |¡} tj  |j |||¡} t|tƒrºt  | tj  | ¡| ¡f¡t | | ¡dS)Nrdr•)r­r'rhr rrr”r›ržr-rŒrrŸr r¡r¥) rr)r&Z old_subpathZtemp_keyZ temp_subpathZdominant_subpathr¨r©Ztmp_pathÚnew_pathrrr r/Ws$        ÿzMaildir.__setitem__c Cs¢| |¡}ttj |j|¡dƒ }|jr4| |¡}nt|ƒ}W5QRXtj |¡\}}|  |¡|j |kr€|  | |j ¡d¡|  tj  tj |j|¡¡¡|S)NÚrbrd)r­ÚopenrrrŒrrr ržÚ set_subdirr›Úset_infoÚset_dateÚgetmtime)rr)ZsubpathÚfÚmsgr¨r˜rrr r3rs    zMaildir.get_messagec CsDttj |j| |¡¡dƒ}| ¡ td¡W5QR£SQRXdS)Nr°r[) r±rrrŒrr­r^rorp©rr)r¶rrr r;szMaildir.get_bytescCs$ttj |j| |¡¡dƒ}t|ƒS)Nr°)r±rrrŒrr­Ú _ProxyFiler¸rrr r6†szMaildir.get_filec csF| ¡|jD]2}z| |¡Wntk r8YqYnX|VqdSr)Ú_refreshrr­r,r(rrr r>‹s  zMaildir.iterkeyscCs| ¡||jkSr)rºrr(rrr rI•szMaildir.__contains__cCs| ¡t|jƒSr)rºÚlenrr=rrr rJšszMaildir.__len__cCsdSrrr=rrr rSŸsz Maildir.flushcCsdSrrr=rrr rT¥sz Maildir.lockcCsdSrrr=rrr rU©szMaildir.unlockcCsdSrrr=rrr rV­sz Maildir.closecCs\g}t |j¡D]F}t|ƒdkr|ddkrtj tj |j|¡¡r| |dd…¡q|S)NérÚ.)rÚlistdirrr»rÚisdirrŒÚappend©rrLÚentryrrr Ú list_folders±sÿzMaildir.list_folderscCs ttj |jd|¡|jddS)Nr½F©rr)rrrrŒrr©rÚfolderrrr Ú get_folderºsþzMaildir.get_foldercCs\tj |jd|¡}t||jd}tj |d¡}tj |¡sXt t |tj tj Bd¡¡|S)Nr½©rZ maildirfolderé¶) rrrŒrrrrŽrVr±ÚO_CREATÚO_WRONLY)rrÆrrLZmaildirfolder_pathrrr Ú add_folderÀs ÿzMaildir.add_foldercCstj |jd|¡}t tj |d¡¡t tj |d¡¡D](}t|ƒdksX|ddkrråÚnextÚ StopIterationr,r=rrr ræ1s  z Maildir.next)NT)r„r…r†r›r!r'r*r-r/r3r;r6r>rIrJrSrTrUrVrÃrÇrÌrÓrÖrÜr–rºr­rærrrr rs4 *   $c@seZdZd#dd„Zdd„Zdd„Zd d „Zd d „Zd d„Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zd$dd „Zd!d"„ZdS)%Ú_singlefileMailboxNTc Cs¾t ||||¡zt|jdƒ}Wnntk rŽ}zP|jtjkr\|rPt|jdƒ}q~t|jƒ‚n"|jtjtj fkr|t|jdƒ}n‚W5d}~XYnX||_ d|_ d|_ d|_ d|_d|_d|_dS)Núrb+zwb+r°rF)rr!r±rr¦r§ÚENOENTrÚEACCESÚEROFSÚ_filerÚ _next_keyÚ_pendingÚ _pending_syncÚ_lockedÚ _file_length)rrrrr¶r¬rrr r!As$  z_singlefileMailbox.__init__cCs8| ¡| |¡|j|j<|jd7_d|_|jdS)Nr¼T)r­Ú_append_messagerrîrðr%rrr r'Xs z_singlefileMailbox.addcCs| |¡|j|=d|_dS©NT)r­rrïr(rrr r*bs z_singlefileMailbox.removecCs$| |¡| |¡|j|<d|_dSrô)r­rórrïr.rrr r/hs z_singlefileMailbox.__setitem__ccs| ¡|j ¡EdHdSr)r­rr@r=rrr r>nsz_singlefileMailbox.iterkeyscCs| ¡||jkSr)r­rr(rrr rIssz_singlefileMailbox.__contains__cCs| ¡t|jƒSr)r­r»rr=rrr rJxsz_singlefileMailbox.__len__cCs|jst|jƒd|_dSrô)rñÚ _lock_filerír=rrr rT}s z_singlefileMailbox.lockcCs|jrt|jƒd|_dS©NF)rñÚ _unlock_filerír=rrr rUƒs z_singlefileMailbox.unlockc CsÖ|js |jrt|jƒd|_dS|j dd¡|j ¡}||jkrTtd|j|fƒ‚t|j ƒ}z¤i}|  |¡t |j   ¡ƒD]x}|j |\}}|j |¡| |¡| ¡}|j td||j ¡ƒ¡}|sÎqÚ| |¡q¬|| ¡f||<| |¡q|| ¡|_Wn"| ¡t |j¡‚YnXt|ƒ|j ¡t |j ¡j} t |j| ¡zt |j|j ¡Wn2tk ršt |j ¡t |j|j ¡YnXt|j dƒ|_||_ d|_d|_|jrÒt|jdddS)NFrràz4Size of mailbox file changed (expected %i, found %i)éré)Údotlock) rïrðÚ _sync_flushrírnÚtellròrÚ_create_temporaryrÚ_pre_mailbox_hookÚsortedrr@Ú_pre_message_hookr^ÚminrqÚ_post_message_hookrVrr*r˜r™rÝÚst_modeÚchmodr¥rßr±rñrõ) rZcur_lenZnew_fileZnew_tocr)ÚstartÚstopZ new_startr_Úmoderrr rS‰s`    þ      ÿ     z_singlefileMailbox.flushcCsdSrr©rr¶rrr rýÉsz$_singlefileMailbox._pre_mailbox_hookcCsdSrrrrrr rÿÍsz$_singlefileMailbox._pre_message_hookcCsdSrrrrrr rÑsz%_singlefileMailbox._post_message_hookcCs4z | ¡W5z|jr| ¡W5|j ¡XXdSr)rírVrñrUrSr=rrr rVÕs   z_singlefileMailbox.closecCsN|jdkr| ¡|dk rJz |j|WStk rHtd|ƒd‚YnXdSrã)rÚ _generate_tocr,r(rrr r­às  z_singlefileMailbox._lookupcCsœ|j dd¡|j ¡}t|jƒdkr8|js8| |j¡z&| |j¡| |¡}|  |j¡Wn"t k r€|j  |¡‚YnX|j  ¡|j ¡|_ |S)Nrrà)rírnrûr»rrïrýrÿÚ_install_messagerr—ÚtruncaterSrò)rr&ZbeforeZoffsetsrrr róês       z"_singlefileMailbox._append_message)NT)N)r„r…r†r!r'r*r/r>rIrJrTrUrSrýrÿrrVr­rórrrr rè>s   @ rèc@s>eZdZdZdd„Zddd„Zddd„Zdd d „Zd d „Zd S)Ú _mboxMMDFTcCsp| |¡\}}|j |¡|j ¡ td¡}|j ||j ¡¡}| | td¡¡}|  |dd…  d¡¡|S)Nór[rfr) r­rírnr{rorpr^rûÚ_message_factoryÚset_fromÚdecode)rr)rrÚ from_lineÚstringr·rrr r3s z_mboxMMDF.get_messageFcCst | ||¡¡j|dS)N)Úunixfromr8)rr)Úfrom_rrr r<s  ÿÿz_mboxMMDF.get_stringcCsJ| |¡\}}|j |¡|s(|j ¡|j ||j ¡¡}| td¡S©Nr[)r­rírnr{r^rûrorp)rr)rrrrrrr r;s   z_mboxMMDF.get_bytescCs<| |¡\}}|j |¡|s(|j ¡t|j|j ¡|ƒSr)r­rírnr{Ú _PartialFilerû)rr)rrrrrr r6s   z_mboxMMDF.get_filecCs d}t|tƒr| |¡}t|tƒrf| d¡rf| d¡}|dkr\|d|…}||dd…}q°|}d}nJt|tƒrˆ| ¡ d¡}d|}n(t|t j j ƒr°|  ¡}|dk r°| d¡}|dkrÎdt  t  ¡¡ ¡}|j ¡}|j |t¡| ||j|j¡|j ¡}||fS)Nrer[rdr¼r rsFrom MAILER-DAEMON )rhrtrZrur|ÚfindÚ_mboxMMDFMessageÚget_fromrWr9r&rÚ get_unixfromrÔÚasctimeÚgmtimerírûrqrprƒÚ _mangle_from_)rr&rÚnewlineZauthorrrrrr r &s0         z_mboxMMDF._install_messageN)F)F)F) r„r…r†rr3r<r;r6r rrrr r s   r c@s.eZdZdZdZd dd„Zdd„Zdd„ZdS) rTNcCst|_t ||||¡dSr)r r r r!rrrr r!Lsz mbox.__init__cCs| t¡dSr©rqrprrrr rQszmbox._post_message_hookcCsègg}}d}|j d¡|j ¡}|j ¡}| d¡rzt|ƒt|ƒkrj|r`| |ttƒ¡n | |¡| |¡d}q|s¤|r–| |ttƒ¡q¸| |¡q¸q|tkr²d}qd}qtt t ||ƒƒƒ|_ t|j ƒ|_ |j ¡|_ dS)NFrreT)rírnrûr{r|r»rÀrpÚdictÚ enumerateÚziprrîrò)rÚstartsÚstopsZlast_was_emptyÚline_posr‚rrr rUs.         zmbox._generate_toc)NT)r„r…r†rrrr!rrrrrr rCs  c@s.eZdZd dd„Zdd„Zdd„Zd d „ZdS) rNTcCst|_t ||||¡dSr)r r r r!rrrr r!zsz MMDF.__init__cCs| dt¡dS©Nórrrrr rÿszMMDF._pre_message_hookcCs| tdt¡dSr%rrrrr rƒszMMDF._post_message_hookcCsÞgg}}|j d¡d}|}|j ¡}|j ¡}| dt¡r˜| |¡|}|j ¡}|j ¡}|dtkr„| |ttƒ¡qžqJ|sJ| |¡qžqJq|sq qtt t ||ƒƒƒ|_ t|j ƒ|_ |j dd¡|j ¡|_ dS)Nrr&rà)rírnr{rûr|rprÀr»rr r!rrîrò)rr"r#Únext_posr$r‚rrr r‡s.          zMMDF._generate_toc)NT)r„r…r†r!rÿrrrrrr rws c@s¾eZdZd/dd„Zdd„Zdd„Zd d „Zd d „Zd d„Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„ZdS)0rNTcCstt ||||¡tj |j¡sj|r`t |jd¡t t tj  |jd¡tj tj Btj Bd¡¡n t |jƒ‚d|_dS)Nr‹ú .mh_sequencesi€F)rr!rrrŽrrrVr±rŒrÊÚO_EXCLrËrrñrrrr r!§sÿ z MH.__init__cCsä| ¡}t|ƒdkrd}n t|ƒd}tj |jt|ƒ¡}t|ƒ}d}zŠ|j rVt |ƒzfz|  ||¡Wn:tk r¢|j r†t |ƒt |ƒd}t |¡‚YnXt|tƒrº| ||¡W5|j rÌt |ƒXW5|sÞt |ƒX|S)Nrr¼FT)r@r»ÚmaxrrrŒrrtrÞr™rñrõr÷rƒr—r*rhr Ú_dump_sequences)rr&r@Znew_keyr¯r¶Úclosedrrr r'³s6     zMH.addc Csxtj |jt|ƒ¡}zt|dƒ}Wn>tk r`}z |jtjkrNt d|ƒ‚n‚W5d}~XYnX|  ¡t  |¡dS©Nrérä) rrrŒrrtr±r¦r§rêr,rVr*)rr)rr¶r¬rrr r*Õs z MH.removec CsÖtj |jt|ƒ¡}zt|dƒ}Wn>tk r`}z |jtjkrNt d|ƒ‚n‚W5d}~XYnXzd|j rrt |ƒz@t t |tjtjB¡¡| ||¡t|tƒr°| ||¡W5|j rÂt |ƒXW5t |ƒXdSr-)rrrŒrrtr±r¦r§rêr,r™rñrõr÷rVrËÚO_TRUNCrƒrhr r+)rr)r&rr¶r¬rrr r/ãs$   zMH.__setitem__c Csèz@|jr$ttj |jt|ƒ¡dƒ}nttj |jt|ƒ¡dƒ}Wn>tk r~}z |jtj krlt d|ƒ‚n‚W5d}~XYnX|2|jr”t |ƒz t |ƒ}W5|jr°t |ƒXW5QRX| ¡ ¡D]\}}||krÈ| |¡qÈ|S)Nrér°rä)rñr±rrrŒrrtr¦r§rêr,rõr÷r Ú get_sequencesrHÚ add_sequence)rr)r¶r¬r·r˜Úkey_listrrr r3ûs&   zMH.get_messagec CsÔz@|jr$ttj |jt|ƒ¡dƒ}nttj |jt|ƒ¡dƒ}Wn>tk r~}z |jtj krlt d|ƒ‚n‚W5d}~XYnX|F|jr”t |ƒz |  ¡ td¡W¢W5QR£S|jrÄt |ƒXW5QRXdS)Nrér°rär[)rñr±rrrŒrrtr¦r§rêr,rõr÷r^rorp©rr)r¶r¬rrr r;s  z MH.get_bytesc Csfzttj |jt|ƒ¡dƒ}Wn>tk r\}z |jtjkrJt d|ƒ‚n‚W5d}~XYnXt |ƒS)Nr°rä) r±rrrŒrrtr¦r§rêr,r¹r2rrr r6)s z MH.get_filecCsttdd„t |j¡DƒƒƒS)Ncss|]}| ¡rt|ƒVqdSr)ÚisdigitrÚ)Ú.0rÂrrr Ú 6sÿzMH.iterkeys..)Úiterrþrr¾rr=rrr r>4sz MH.iterkeyscCstj tj |jt|ƒ¡¡Sr)rrrŽrŒrrtr(rrr rI9szMH.__contains__cCstt| ¡ƒƒSr)r»r?r>r=rrr rJ=sz MH.__len__cCs2|js.ttj |jd¡dƒ|_t|jƒd|_dS)Nr(réT)rñr±rrrŒrrírõr=rrr rTAs zMH.lockcCs(|jr$t|jƒt|jƒ|`d|_dSrö)rñr÷rír™r=rrr rUHs   z MH.unlockcCsdSrrr=rrr rSPszMH.flushcCs|jr| ¡dSr)rñrUr=rrr rVTszMH.closecCs<g}t |j¡D]&}tj tj |j|¡¡r| |¡q|Sr)rr¾rrr¿rŒrÀrÁrrr rÃYs  zMH.list_folderscCsttj |j|¡|jddS)NFrÄ©rrrrŒrrrÅrrr rÇasÿz MH.get_foldercCsttj |j|¡|jdS)NrÈr7rÅrrr rÌfsÿz MH.add_foldercCs`tj |j|¡}t |¡}|dgkr:t tj |d¡¡n|gkrDntd|jƒ‚t |¡dS)Nr(zFolder not empty: %s)rrrŒrr¾r*rrÏ)rrÆrÚentriesrrr rÓks  zMH.remove_folderc si}ttj |jd¡dddÜ}t| ¡ƒ‰|D]Ä}zš| d¡\}}tƒ}| ¡D]H}| ¡rn|  t |ƒ¡qRdd„| d¡Dƒ\}} |  t || d ƒ¡qR‡fd d „t |ƒDƒ||<t||ƒd krÌ||=Wq0tk ròtd | ¡ƒ‚Yq0Xq0W5QRX|S)Nr(ÚrÚASCII©Úencodingr‡css|]}t|ƒVqdSr)rÚ)r4Úxrrr r5„sz#MH.get_sequences..ú-r¼csg|]}|ˆkr|‘qSrr)r4r)©Zall_keysrr Ú †sÿz$MH.get_sequences..rz"Invalid sequence specification: %s)r±rrrŒrÚsetr@ržr3r'rÚrRÚrangerþr»rYrÚrstrip) rZresultsr¶r‚r˜Úcontentsr@Úspecrrrr?r r/ws(   ÿzMH.get_sequencescCsttj |jd¡ddd}zØt t |jtjtj B¡¡|  ¡D]®\}}t |ƒdkrVq@|  |d¡d}d}t t|ƒƒD]R}|d|krœ|sÆd }|  d ¡n*|r¸d}|  d ||f¡n|  d |¡|}qx|rä|  t|ƒd ¡q@|  d ¡q@W5t|ƒXdS)Nr(zr+r:r;rr‡Fr¼Tr>z%s %sz %sÚ )r±rrrŒrr™rVr˜rËr.rHr»rqrþrArt)rÚ sequencesr¶r˜r@ÚprevZ completingr)rrr Ú set_sequencess.   zMH.set_sequencesc Cs>| ¡}d}g}| ¡D]Â}|d|krÒ| ||df¡z4t tj |jt|ƒ¡tj |jt|dƒ¡¡WnHt t fk r¶t  tj |jt|ƒ¡tj |jt|dƒ¡¡YnXt  tj |jt|ƒ¡¡|d7}q|d|_ t|ƒdkrödS| ¡D]0\}}|D]"\}}||kr ||| |¡<q qþ| |¡dS)Nrr¼)r/r>rÀrr¢rrŒrrtr£r¤r¥Úunlinkrîr»rHÚindexrI) rrGrHZchangesr)r˜r1Úoldr‰rrr Úpack¬s0  ÿÿ      zMH.packcCst| ¡}| ¡}| ¡D]0\}}||kr4| |¡q||kr|| |¡=q|D]}||krN|g||<qN| |¡dSr)r/rHrÀrKrI)rr&r)Zpending_sequencesZ all_sequencesr˜r1Úsequencerrr r+Æs  zMH._dump_sequences)NT)r„r…r†r!r'r*r/r3r;r6r>rIrJrTrUrSrVrÃrÇrÌrÓr/rIrMr+rrrr r¤s, "  c@sŒeZdZedddddddhƒZd$d d „Zd d „Zdd„Zdd„Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„Zd d!„Zd"d#„ZdS)%rÚunseenÚdeletedZfiledÚansweredÚ forwardedZeditedÚresentNTcCst ||||¡i|_dSr)rèr!Ú_labelsrrrr r!ÛszBabyl.__init__cCs(t ||¡}t|tƒr$| ¡|j|<|Sr)rèr'rhr Ú get_labelsrT)rr&r)rrr r'às  z Babyl.addcCs"t ||¡||jkr|j|=dSr)rèr*rTr(rrr r*çs  z Babyl.removecCs*t |||¡t|tƒr&| ¡|j|<dSr)rèr/rhr rUrTr.rrr r/ís zBabyl.__setitem__c Csò| |¡\}}|j |¡|j ¡t ¡}|j ¡}|dtks\|sHq\| | td¡¡q,t ¡}|j ¡}|tks|s|q| | td¡¡qd||j  ¡}|j  |¡}| td¡}t |  ¡|ƒ} |   |  ¡¡||jkrî|  |j|¡| S©Nó *** EOOH ***r[)r­rírnr{rirjrprqrorûr^r rzÚ set_visiblerTÚ set_labels) rr)rrÚoriginal_headersr‚Zvisible_headersÚnZbodyr·rrr r3ós*        zBabyl.get_messagec Cs¬| |¡\}}|j |¡|j ¡t ¡}|j ¡}|dtks\|sHq\| | td¡¡q,|j ¡}|tksv|s\qvq\|  ¡}||j  ¡}|j  |¡}| td¡}||SrV) r­rírnr{rirjrprqrorzrûr^) rr)rrrZr‚Zheadersr[rrrr r;s        zBabyl.get_bytescCst | |¡ dt¡¡Sr)rirjr;rorpr(rrr r6%szBabyl.get_filecCs<| ¡tƒ}|j ¡D]}| |¡q| |j¡t|ƒSr)r­rArTrFrRÚdifference_updateÚ_special_labelsr?)rÚlabelsZ label_listrrr rU)s   zBabyl.get_labelscCs:gg}}|j d¡d}g}|}|j ¡}|j ¡}|dtkrœt|ƒt|ƒkrd| |ttƒ¡| |¡dd„|j ¡dd… d¡Dƒ}| |¡q|dks°|dtkrÔt|ƒt|ƒkrì| |ttƒ¡q|s| |ttƒ¡qîqtt t ||ƒƒƒ|_ tt |ƒƒ|_ t|j ƒ|_ |j dd¡|j ¡|_dS) Nrs cSsg|]}| ¡r| ¡‘qSr)Ústrip©r4Úlabelrrr r@@sþz'Babyl._generate_toc..r¼ó,órà)rírnr{rûrpr»rÀržrr r!rrTrîrò)rr"r#r'Z label_listsr$r‚r^rrr r2s4      ÿ  zBabyl._generate_toccCsVdt}|dt7}| ¡}dd„|Dƒ}|dd |¡t7}|d7}| |¡dS)NsBABYL OPTIONS:s Version: 5css|]}| ¡VqdSr)rWr`rrr r5Usz*Babyl._pre_mailbox_hook..sLabels:rbrc)rprUrŒrq)rr¶Zbabylr^rrr rýPs zBabyl._pre_mailbox_hookcCs| dt¡dS)Nó rrrrr rÿZszBabyl._pre_message_hookcCs| td¡dS)Nrcrrrrr r^szBabyl._post_message_hookcCsx|j ¡}t|tƒr°g}g}| ¡D]$}||jkr>| |¡q$| |¡q$|j d¡|D]}|j d| ¡¡qZ|j d¡|D]}|j d| ¡d¡q„|j t ¡n|j dt ¡t|t j j ƒrt  ¡}t j |dd¡}| |¡| d¡| ¡}|j | d t ¡¡|d ks,|süq,qü|j d t ¡t|tƒr¤t  ¡} t j | dd¡} |  | ¡¡|  ¡}|j | d t ¡¡|d ks¢|snqâqnn>| d¡| ¡}|j | d t ¡¡|d ksâ|s®qâq®| d ¡} | söqf|j |  d t ¡¡qânTt|ttt jfƒrt|t jƒrJt d td ¡| ¡}t|tƒr`| |¡}| d¡d} | ddkrâ|j |d| … d t ¡¡|j d t ¡|j |d| … d t ¡¡|j || d… d t ¡¡n(|j d t t ¡|j | d t ¡¡nXt |dƒrVt |dƒr:t dtd ¡|j!}| ¡} d}| ¡}| "d¡rl|dd…d }n| "d¡rˆ|dd…d }|j | d t ¡¡|d ks¬|sF|rÚd}|j d t ¡| | ¡nqÚqF| ¡}|sìqf| "d¡r |dd…t }n:| "d¡r(|dd…t }n| "d ¡rD|dd…t }|j |¡qÚnt#dt$|ƒƒ‚|j ¡}||fS)Nó1s, s,,ó rbs1,,Frr[rWrør\r]s ràrdr{r_r`Trarbrcrg)%rírûrhr rUr]rÀrqrWrpr9r&rrirjrkrlrmrnr{roÚ get_visibler^rurtrvrwrxryrzrZrrOr_rsr}r~)rr&rZspecial_labelsr^raZ orig_bufferZorig_generatorr‚Z vis_bufferZ vis_generatorr_Z body_startZ original_posZ first_passrrrr r bs¼              ÿ    ÿ       zBabyl._install_message)NT)r„r…r†Ú frozensetr]r!r'r*r/r3r;r6rUrrýrÿrr rrrr rÕs$ ÿ   c@s&eZdZddd„Zdd„Zdd„ZdS) rNcCsÒt|tjjƒr4| t |¡¡t|tƒrÎ| |¡nšt|tƒrP| t  |¡¡n~t|t ƒrl| t  |¡¡nbt|t j ƒrŠ| t |¡¡nDt|dƒr¦| t |¡¡n(|dkr¾tjj |¡ntdt|ƒƒ‚dS)Nr^rg)rhr9r&rÚ_become_messageÚcopyZdeepcopyÚ _explain_torur:rtZmessage_from_stringriÚ TextIOWrapperZmessage_from_filerOZmessage_from_binary_filer!r}r~r%rrr r!Ñs      zMessage.__init__cCs4t|dgƒ}|jD]}||kr|j||j|<qdS)NÚ_type_specific_attributes)ÚgetattrÚ__dict__)rr&Z type_specificr˜rrr riäs  zMessage._become_messagecCst|tƒrdStdƒ‚dS)Nz Cannot convert to specified type)rhrr}r%rrr rkës zMessage._explain_to)N)r„r…r†r!rirkrrrr rÎs c@sxeZdZdddgZddd„Zdd„Zd d „Zd d „Zd d„Zdd„Z dd„Z dd„Z dd„Z dd„Z dd„Zdd„ZdS)r Ú_subdirÚ_infoÚ_dateNcCs&d|_d|_t ¡|_t ||¡dS)Nr‰r•)rprqrÔrrrr!r%rrr r!øs zMaildirMessage.__init__cCs|jSr)rpr=rrr ršÿszMaildirMessage.get_subdircCs(|dks|dkr||_n td|ƒ‚dS)Nr‰rŠz!subdir must be 'new' or 'cur': %s)rprY)rr¨rrr r²szMaildirMessage.set_subdircCs"|j d¡r|jdd…SdSdS)Nú2,ràr•)rqr|r=rrr Ú get_flags s zMaildirMessage.get_flagscCsdd t|ƒ¡|_dS)Nrsr•)rŒrþrq)rÚflagsrrr Ú set_flagsszMaildirMessage.set_flagscCs$| d t| ¡ƒt|ƒB¡¡dS©Nr•©rvrŒrArt©rÚflagrrr Úadd_flagszMaildirMessage.add_flagcCs,| ¡r(| d t| ¡ƒt|ƒ¡¡dSrw)rtrvrŒrAryrrr Ú remove_flagszMaildirMessage.remove_flagcCs|jSr)rrr=rrr r¡szMaildirMessage.get_datecCs6zt|ƒ|_Wn"tk r0td|ƒd‚YnXdS)Nzcan't convert to float: %s)ÚfloatrrrYr})rÚdaterrr r´"szMaildirMessage.set_datecCs|jSr)rqr=rrr rœ)szMaildirMessage.get_infocCs&t|tƒr||_ntdt|ƒƒ‚dS)Nzinfo must be a string: %s)rhrtrqr}r~)rÚinforrr r³-s zMaildirMessage.set_infocCs¤t|tƒr8| | ¡¡| | ¡¡| | ¡¡nht|tƒrÄt | ¡ƒ}d|kr`|  d¡| ¡dkrv|  d¡d|krˆ|  d¡d|krš|  d¡d|kr¬|  d¡|  d t   | ¡¡¡nÜt|tƒrt | ¡ƒ}d|krî| d ¡d|kr| d ¡d|kr | d ¡nˆt|tƒr‚t | ¡ƒ}d|krD| d ¡d|krX| d ¡d|krl| d¡d|kr | d¡nt|tƒrntdt|ƒƒ‚dS)NÚSÚRrŠÚOÚTÚDÚFÚAú MAILER-DAEMONrOÚrepliedÚflaggedrPrQÚPrRú$Cannot convert to specified type: %s)rhr rvrtr²ršr´r¡rrAr{rrÔrr r0r Ú add_labelrr}r~)rr&rurrr rk4sP                           ÿzMaildirMessage._explain_to)N)r„r…r†rmr!ršr²rtrvr{r|r¡r´rœr³rkrrrr r ós  c@sVeZdZdgZddd„Zdd„Zddd„Zd d „Zd d „Zd d„Z dd„Z dd„Z dS)rÚ_fromNcCsV| dd¡t|tjjƒrF| ¡}|dk rF| d¡rF| |dd…¡t ||¡dS)Nr‡TzFrom rf)rrhr9r&rrr|r!)rr&rrrr r!es  z_mboxMMDFMessage.__init__cCs|jSr)rr=rrr rnsz_mboxMMDFMessage.get_fromcCs4|dk r*|dkrt ¡}|dt |¡7}||_dS)NTú )rÔrrr)rrZtime_rrr rrs z_mboxMMDFMessage.set_fromcCs| dd¡| dd¡S)NÚStatusr•úX-Status)r2r=rrr rtzsz_mboxMMDFMessage.get_flagscCsÒt|ƒ}d\}}dD]}||kr||7}| |¡qdD]}||kr8||7}| |¡q8|d t|ƒ¡7}z| d|¡Wn tk rš| d|¡YnXz| d|¡Wn tk rÌ| d|¡YnXdS)N)r•r•)rr‚)r„r…r†r•rr)rAr*rŒrþÚreplace_headerr,Z add_header)rruZ status_flagsZ xstatus_flagsrzrrr rv~s&  z_mboxMMDFMessage.set_flagscCs$| d t| ¡ƒt|ƒB¡¡dSrwrxryrrr r{”sz_mboxMMDFMessage.add_flagcCs4d|ksd|kr0| d t| ¡ƒt|ƒ¡¡dS)Nrrr•rxryrrr r|˜sz_mboxMMDFMessage.remove_flagc CsÞt|tƒrÐt| ¡ƒ}d|kr(| d¡d|kr:| d¡d|krL| d¡d|kr^| d¡d|krp| d¡|d =|d =d  | ¡ ¡d d…¡}z|  t   t   |d ¡¡¡Wnttfk rÊYnXn t|tƒrø| | ¡¡| | ¡¡nât|tƒrZt| ¡ƒ}d|kr$| d¡d|kr8| d¡d|krL| d¡|d =|d =n€t|tƒr¼t| ¡ƒ}d|kr†| d¡d|krš| d¡d|kr®| d¡|d =|d =nt|tƒrÊntdt|ƒƒ‚dS)Nr‚rŠr…r†rr€r„rƒZstatuszx-statusrŽéûÿÿÿz%a %b %d %H:%M:%S %YrOrˆr‰rPrQr‹)rhr rArtr²r{rŒrržr´ÚcalendarZtimegmrÔÚstrptimerYÚ OverflowErrorrrvrr r0r rŒrr}r~)rr&ruZ maybe_daterrr rksb       ÿ                    ÿz_mboxMMDFMessage._explain_to)N)N) r„r…r†rmr!rrrtrvr{r|rkrrrr r`s  rc@s eZdZdS)r N©r„r…r†rrrr r Ñsc@sDeZdZdgZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Z dS)r Ú _sequencesNcCsg|_t ||¡dSr)r—rr!r%rrr r!ÚszMHMessage.__init__cCs|jdd…Sr)r—r=rrr r/ßszMHMessage.get_sequencescCst|ƒ|_dSr)r?r—)rrGrrr rIãszMHMessage.set_sequencescCs6t|tƒr"||jkr2|j |¡ntdt|ƒƒ‚dS)Nzsequence type must be str: %s)rhrtr—rÀr}r~©rrNrrr r0çs  zMHMessage.add_sequencecCs*z|j |¡Wntk r$YnXdSr)r—r*rYr˜rrr Úremove_sequenceïszMHMessage.remove_sequencecCsFt|tƒrdt| ¡ƒ}d|kr*| d¡n| d¡| d¡d|krP| d¡d|krb| d¡nÞt|tƒr¾t| ¡ƒ}d|krŽ| d¡n | d ¡d|krª| d¡d|kr¼| d ¡n„t|tƒrâ| ¡D]}| |¡qÐn`t|t ƒr$t| ¡ƒ}d|kr|  d¡d|krB|  d ¡nt|t ƒr2nt d t |ƒƒ‚dS) NrOrŠr€r‰r…rˆrÚROr‚r†rQr‹)rhr rAr/r²r{rr r0r rŒrr}r~)rr&rGrNrrr rkösB                      ÿzMHMessage._explain_to)N) r„r…r†rmr!r/rIr0r™rkrrrr r Õs c@s^eZdZddgZddd„Zdd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z dS)r rTÚ_visibleNcCsg|_tƒ|_t ||¡dSr)rTrr›r!r%rrr r!"szBabylMessage.__init__cCs|jdd…Sr)rTr=rrr rU(szBabylMessage.get_labelscCst|ƒ|_dSr)r?rT)rr^rrr rY,szBabylMessage.set_labelscCs6t|tƒr"||jkr2|j |¡ntdt|ƒƒ‚dS)Nzlabel must be a string: %s)rhrtrTrÀr}r~©rrarrr rŒ0s  zBabylMessage.add_labelcCs*z|j |¡Wntk r$YnXdSr)rTr*rYrœrrr Ú remove_label8szBabylMessage.remove_labelcCs t|jƒSr©rr›r=rrr rg?szBabylMessage.get_visiblecCst|ƒ|_dSrrž)rZvisiblerrr rXCszBabylMessage.set_visiblecCsb|j ¡D](}||kr*|j |||¡q |j|=q dD]$}||kr8||jkr8|||j|<q8dS)N)ZDateZFromzReply-ToZToZCCZSubject)r›r@r‘)rÚheaderrrr Úupdate_visibleGs zBabylMessage.update_visiblecCsrt|tƒr~t| ¡ƒ}d|kr*| d¡n| d¡| d¡d|ksNd|krX| d¡d|krj| d¡d |kr|| d ¡nðt|tƒrØt| ¡ƒ}d|kr¨| d ¡n | d ¡d |krÄ| d ¡d|krÖ| d¡n–t|tƒrt| ¡ƒ}d|kr| d¡d|krn| d¡nTt|t ƒrP|  |  ¡¡| ¡D]}|  |¡q s€   ý h8DB4-3z%mqH_c' *