Qf?4 ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl Z ddl Z ddl m Z  ddlZgdZej"j%dZGddZGddeZGd d eZGd d eZGd deZGddeZGddeZGddeZGddej6j8ZGddeZGddeZGddeZGddeZ Gdd eZ!Gd!d"eZ"Gd#d$Z#Gd%d&e#Z$d7d'Z%d(Z&d)Z'd*Z(d+Z)d,Z*Gd-d.e+Z,Gd/d0e,Z-Gd1d2e,Z.Gd3d4e,Z/Gd5d6e,Z0y#e$rdZYAwxYw)8N) GenericAlias)MailboxMaildirmboxMHBabylMMDFMessageMaildirMessage mboxMessage MHMessage BabylMessage MMDFMessageErrorNoSuchMailboxError NotEmptyErrorExternalClashError FormatErrorasciiceZdZ d"dZdZdZdZdZdZd#dZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZd#dZdZd#dZdZdZdZdZdZ d Z!d$d!Z"e#e$Z%y)%rNc tjjtjj||_||_yN)ospathabspath expanduser_path_factoryselfrfactorycreates ./opt/alt/python312/lib64/python3.12/mailbox.py__init__zMailbox.__init__%s/,WW__RWW%7%7%=>  c tdNz&Method must be implemented by subclassNotImplementedErrorr messages r#addz Mailbox.add*s2!"JKKr%c tdr'r(r keys r#removezMailbox.remove.sK!"JKKr%c&|j|yr)r0r.s r# __delitem__zMailbox.__delitem__2s Cr%cH |j|y#t$rYywxYwr)r0KeyErrorr.s r#discardzMailbox.discard5s(5  KK    s  !!c tdr'r(r r/r+s r# __setitem__zMailbox.__setitem__<sL!"JKKr%cJ |j|S#t$r|cYSwxYwr) __getitem__r4)r r/defaults r#getz Mailbox.get@s/G ##C( ( N s  ""c |js|j|Stj|j |5}|j|cdddS#1swYyxYwr)r get_message contextlibclosingget_file)r r/files r#r:zMailbox.__getitem__GsSK}}##C( (##DMM#$674}}T* + +77s AA'c tdr'r(r.s r#r>zMailbox.get_messageOsB!"JKKr%ch tj|j|jSremailmessage_from_bytes get_bytes as_stringr.s r# get_stringzMailbox.get_stringSs, *''s(;<FFHHr%c tdr'r(r.s r#rHzMailbox.get_bytesZsF!"JKKr%c tdr'r(r.s r#rAzMailbox.get_file^sD!"JKKr%c tdr'r(r s r#iterkeyszMailbox.iterkeysbs+!"JKKr%c6 t|jSr)listrOrNs r#keysz Mailbox.keysfs$DMMO$$r%c#jK |jD] } ||}|y#t$rYwxYwwrrOr4r r/values r# itervalueszMailbox.itervaluesjsA3==?C S K #  s3$3 0303c"|jSr)rWrNs r#__iter__zMailbox.__iter__ss  r%c6 t|jSr)rQrWrNs r#valueszMailbox.valuesvs:DOO%&&r%c#nK |jD]} ||}||fy#t$rYwxYwwrrTrUs r# iteritemszMailbox.iteritemszsF<==?C S ,  #  s5& 5 2525c6 t|jSr)rQr]rNs r#itemsz Mailbox.itemssGDNN$%%r%c tdr'r(r.s r# __contains__zMailbox.__contains__sG!"JKKr%c tdr'r(rNs r#__len__zMailbox.__len__s8!"JKKr%cR |jD]}|j|yr)rRr5r.s r#clearz Mailbox.clears!"99;C LL r%cX ||}|j||S#t$r|cYSwxYwr)r4r5)r r/r;results r#popz Mailbox.pops<A #YF S  N s  ))cl |jD]}||j|fcStd)NzNo messages in mailbox)rOrhr4r.s r#popitemzMailbox.popitems6D==?C#' '#34 4r%c t|dr|j}nt|dr|j}n|}d}|D] \}} |||< |r tdy#t$rd}Y)wxYw)Nr]r_FTzNo message with key(s))hasattrr]r_r4)r argsourcebad_keyr/r+s r#updatezMailbox.updatesB 3 $]]_F S' "YY[FF"LC #S # 34 4   s A A,+A,c tdr'r(rNs r#flushz Mailbox.flushs4!"JKKr%c tdr'r(rNs r#lockz Mailbox.locks!"JKKr%c tdr'r(rNs r#unlockzMailbox.unlocks1!"JKKr%c tdr'r(rNs r#closez Mailbox.closes*!"JKKr%cV |jdS#t$r tdwxYw)Nrz?String input must be ASCII-only; use bytes or a Message instead)encode UnicodeError ValueErrorr*s r#_string_to_byteszMailbox._string_to_bytess7 2>>'* * 212 2 2s(Fc t|tjjrt j }tj j||d}|j||jd|j}|jdt}|j||jr,|jts|jtyyyt|t t"tj$frt|tj$r+t'j(dt*d|j-}t|t r|j/|}|r|jdd}|jdt}|j||jr,|jts|jtyyyt1|drt1|dr't'j(d t*d|j2}d} |j5}|jd r |dd dz}n|jd r|dd dz}|snE|r|j7drd|ddz}|jdt}|j||}|jr/|r,|jts|jtyyyyt9dt;|z)Nr 8Use of StringIO input is deprecated, use BytesIO insteads From s >From readbufferDUse of text mode files is deprecated, use a binary mode file instead  From s>From Invalid message type: %s) isinstancerFr+r ioBytesIO generatorBytesGeneratorflattenseekrreplacelinesepwrite_append_newlineendswithstrbytesStringIOwarningswarnDeprecationWarninggetvaluer}rlrreadline startswith TypeErrortype) r r+target mangle_from_rgendatalastlinelines r# _dump_messagezMailbox._dump_messagesw3 gu}}44 5ZZ\F//00qIC KK KKN;;=D<<w/D LL ##DMM',B W%-C##ubkk!: ;'2;;/ *+=qB!**,'3'//8!//*kBooeW5G LL !##G,<,rJrHrArOrRrWrYr[r]r_rarcrerhrjrprrrtrvrxr}rr classmethodr__class_getitem__r%r#rr"s4 LLL+LILLL%!'&LL 55"LLLL2O4Hl$L1r%rceZdZ dZddZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZy)r:Nc tj||||tjj |j dtjj |j dtjj |j dd|_tjj|j sm|rVtj|j d|j jD]}tj|dnt|j i|_ ddd|_ d|_ d|_y) Ntmpnewcur)rrrr)rrg?)rr$rrjoinr_pathsexistsmkdirr[r_toc _toc_mtimes _last_read _skewfactor)r dirnamer!r"rs r#r$zMaildir.__init__s,w877<< E277<< E277<< E2 ww~~djj)U+ KK..0DHHT5)1)44 #$Q/r%c |j} |j||t|t|tr?|j}|j|jz}||jk(rd}nd}d}tjj|j j|jd}tjj!|j"|||z}t|trWt j$|j tjj'|j |j)f t j*|j |t j |j |S#t$r1|jt j |j wxYw#t,t.f$r$t j0|j |Y|SwxYw#t2$rP}t j |j |j4t4j6k(rt9d|zd}~wwxYw)Nrrz$Name clash with existing message: %s) _create_tmpr BaseExceptionrxrr0name _sync_closerr get_subdircolonget_inforbasenamesplitrrutimegetatimeget_datelinkAttributeErrorPermissionErrorrenameOSErrorerrnoEEXISTr)r r+tmp_filesubdirsuffixuniqdestes r#r,z Maildir.add$s2##%    w 1 H g~ .'')FZZ'"2"2"44F#FFww .44TZZ@Cww||DJJv > g~ . HHX]]gg&&x}}5w7G7G7IJ L  ) t, (--( G  NN  IIhmm $  0#O4 / (--.  /  IIhmm $ww%,,&()O+/*011  sBF  G?H :G/H HHH I,A I''I,c tjtjj|j|j |yr)rr0rrr_lookupr.s r#r0zMaildir.removeNs-K "'',,tzz4<<+<=>r%cT |j|y#ttf$rYywxYwr)r0r4FileNotFoundErrorr.s r#r5zMaildir.discardRs.5  KK +,   s ''c |j|}|j|}|j|}t|tr|}n|}tj j |}|j|vr,|j|j|jdz}nd}|j|tj j|j|} tj j|j|||z} t|trCt j| tj j| |jft j| | y)Nrr)rr,rr rrrrrr5rrrrrr) r r/r+ old_subpathtemp_key temp_subpathdominant_subpathrrtmp_pathnew_paths r#r8zMaildir.__setitem__ZsLll3' 88G$||H- g~ .+  + !12 ::) )ZZ"2"8"8"DR"HHFF S77<< L977<< FC&LA g~ . HHXgg&&x0'2B2B2DE G (H%r%c |j|}ttjj |j |d5}|j r|j |}n t|}dddtjj|\}}j||j|vr-|j|j|jd|jtjjtjj |j ||S#1swYxYw)Nrbr)ropenrrrrrr r set_subdirrset_infoset_dategetmtime)r r/subpathfmsgrrs r#r>zMaildir.get_messageusB,,s# "'',,tzz73T :a}}mmA&$Q' ; ww}}W-  v ::  LLDJJ/3 4 RWW%%bggll4::w&GHI ; :s *D??Ec ttjj|j|j |d5}|j jtdcdddS#1swYyxYw)Nrr) rrrrrrrrrr r/rs r#rHzMaildir.get_bytessT@ "'',,tzz4<<+<=t D668##GU3 4 4 D Ds $A33A<c ttjj|j|j |d}t |S)Nr)rrrrrr _ProxyFilers r#rAzMaildir.get_files7D djj$,,s*; r%c~ tj}tjtjj |j dD]h}tjj |j d|}|tjj |z dkDsTtj|jy)Nri@)timerrrrrrr0)r nowrrs r#cleanz Maildir.cleansx(iikZZ TZZ ?@E77<< E59DRWW%%d++f4 $Ar%rc d tj}tj}d|vr|jdd}d|vr|jdd}t |dt |dzdzdt j d tjd | }t jj|jd |} t j|t!d |z#t$r9txjdz c_ t|cYS#t$rYnwxYwYOwxYw) N/z\057rz\072z.Mrg.APQrrz&Name clash prevented file creation: %s)rsocket gethostnamerintrgetpidr_countrrrstatr_create_carefullyFileExistsErrorr)r rhostnamerrs r#rzMaildir._create_tmpsKiik%%' (?''W5H (?''W5H$'Hc#'C-.@"))+$+NNH>ww||DJJt4  GGDM!!I!%"&' '!  NNa N (.."    s6 C--"D/ DD/ D)&D/(D))D/.D/c tj|jz d|jzkDred}|jD]Q}tj j |j|}||j|kDrd}||j|<S|syi|_|jD]}|j|}t j|D]}tj j||}tj j|rC|j|jd}tj j|||j|<tj|_y)NFTr)rrrrrrrrrrrrrr)r refreshrmtimerrprs r#rzMaildir._refreshs,/ 99; (1t/?/?+? ?G**((V)<=4++F33"G+0  ( +  &&F;;v&DD)GGLLu-77==#{{4::.q1"$'',,vu"= $ *'))+r%cd tjjtjj|j|j |r|j |S |j |j |S#t $rY+wxYw#t $rt d|zdwxYwNNo message with key: %s)rrrrrrr4rr.s r#rzMaildir._lookup&sK ww~~bggll4::tyy~FGyy~%H  F99S> !      F4s:; E FsA"B8B BBB/c t|ds|j|_ |t|jS#t$rYyt $rY/wxYw)N _onetime_keys)rlrOr7next StopIterationr4rNs r#r8z Maildir.next4sX>t_-!%D  D!3!3455    s= AAAr)rrrrr$r,r0r5r8r>rHrArOrarcrrrtrvrxrr rrr r)rrrr8rr%r#rr s( E((T?&6 4     % & F'0"&H F r%rcreZdZ ddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZddZdZy)_singlefileMailboxNc tj|||| t|jd}||_ d|_ d|_ d|_ d|_d|_d|_y#t$r}|j t j k(r.|rt|jd}nYt|j|j t jt jfvrt|jd}nYd}~d}~wwxYw)Nrb+zwb+rrF)rr$rrrrENOENTrEACCESEROFS_filer _next_key_pending _pending_sync_locked _file_length)r rr!r"rrs r#r$z_singlefileMailbox.__init__Ds/tWf5 TZZ'A   "  ! ww%,,&TZZ/A,TZZ88U\\5;;77T* sA## D,BDDc |j|j||j|j<|xjdz c_d|_|jdz S)NrT)r_append_messagerrBrDr*s r#r,z_singlefileMailbox.add[sR2 $($8$8$A $..! !"~~!!r%cP |j||j|=d|_yr)rrrCr.s r#r0z_singlefileMailbox.removees#K S IIcN r%cr |j||j||j|<d|_yr)rrHrrCr7s r#r8z_singlefileMailbox.__setitem__ks0L S--g6 # r%c#vK |j|jjEd{y7wr)rrrRrNs r#rOz_singlefileMailbox.iterkeysqs&+ 99>>###s /979c@ |j||jvSr)rrr.s r#raz_singlefileMailbox.__contains__vsG diir%cN |jt|jSr)rrrrNs r#rcz_singlefileMailbox.__len__{s8 499~r%cX |jst|jd|_yyr)rE _lock_filerArNs r#rtz_singlefileMailbox.locks$|| tzz "DLr%cX |jrt|jd|_yyNF)rE _unlock_filerArNs r#rvz_singlefileMailbox.unlocks$1 <<  $ DL r%c  |js)|jrt|jd|_y|jj dd|jj }||j k7rtd|j |fzt|j} i}|j|t|jjD]}|j|\}}|jj ||j||j } |jjt!d||jj z }|sn|j#|U||j f||<|j%||j |_t/||jj't)j0|j} t)j2|j,| j4 t)j6|j,| j8| j: t)j@|j,|jtE|jd|_||_ d|_d|_|jFrtI|jdyy#|j't)j*|j,xYw#t<t>f$rYwxYw#tB$rLt)j*|jt)j@|j,|jYwxYw)NFrr/z4Size of mailbox file changed (expected %i, found %i)r=)dotlock)%rCrD _sync_flushrArtellrFr_create_temporaryr_pre_mailbox_hooksortedrrR_pre_message_hookrminr_post_message_hookrxrr0rrr*chmodst_modechownst_uidst_gidrrrr,rrErO) r cur_lennew_filenew_tocr/startstop new_startrinfos r#rrz_singlefileMailbox.flushs0}}!!DJJ'%*"  1**//# d'' '$&?&*&7&7%A&BC C%TZZ0 G  " "8 ,diinn./"iin t &&&x0$MMO !ZZ__S15 8I1I.KLF!NN6*  !*8==?; ''10!) D  H wwtzz"  -  HHX]]DKK = 1 IIhmmTZZ 0$**e,   " << tzz5 1 /  NN  IIhmm $ (    1 IIdjj ! IIhmmTZZ 0 1s2,DK*55L+*L4*2LL10L14AN N c yrrr rs r#rYz$_singlefileMailbox._pre_mailbox_hook:r%c yrrrks r#r[z$_singlefileMailbox._pre_message_hooks;r%c yrrrks r#r]z%_singlefileMailbox._post_message_hookrlr%c |j |jr|j|jj y#|jj wxYw# |jr|j|jj w#|jj wxYwxYwr)rrrErvrArxrNs r#rxz_singlefileMailbox.closes* # JJL #<<KKM   "   "  #<<KKM   "   "s.A*A A'*C,B#C#B??Cc |j|j| |j|Sy#t$rtd|zdwxYwr4)r _generate_tocr4r.s r#rz_singlefileMailbox._lookups_5 99     ? Jyy~%  J83>?TI Js 1A cF |jjdd|jj}t|jdk(r'|j s|j |j |j|j|j|}|j|j|jj|jj|_ |S#t$r|jj|wxYw)Nrr/)rArrWrrrCrYr[_install_messager]rtruncaterrrF)r r+beforeoffsetss r#rHz"_singlefileMailbox._append_messagesI 1" tyy>Q t}}  " "4:: .   " "4:: .++G4G  # #DJJ /  JJOO-   JJ   '  s 8AC::&D rr)rrrr$r,r0r8rOrarcrtrvrrrYr[r]rxrrHrr%r#r;r;AsX !."  $    ! B2H #Jr%r;c6eZdZ dZdZddZddZddZdZy) _mboxMMDFTc |j|\}}|jj||jjj t dj d}|jj||jjz }|j|j t d}|j||j|dd|S)Nr%rrr) rrArrrrdecoderrW_message_factory set_unixfromset_from)r r/rfrg from_linestringrs r#r>z_mboxMMDF.get_message sBll3' t JJ'')11'3?FFwO  (9!9:##FNN7E$BC # Yqr]# r%cn tj|j||j|S)N)unixfromrE)r r/from_s r#rJz_mboxMMDF.get_strings3A'' NN3 &((1 5 (A Br%c2 |j|\}}|jj||s|jj|jj ||jj z }|j tdSNr)rrArrrrWrr)r r/rrfrgrs r#rHz_mboxMMDF.get_bytessmAll3' t  JJ   ! (9!9:~~gu--r%c |j|\}}|jj||s|jjt |j|jj |Sr)rrArr _PartialFilerW)r r/rrfrgs r#rAz_mboxMMDF.get_file&sXDll3' t  JJ   !DJJ (94@@r%cL d}t|tr|j|}t|tr:|j dr)|j d}|dk7r|d|}||dzd}n|}d}n|t|t r%|jjd}d|z}nGt|tjjr#|j}||jd}|8dtjtjjz}|j j#}|j j%|t&z|j)||j |j*|j j#}||fS)Nrrrrr%rsFrom MAILER-DAEMON )rrr}rrfind_mboxMMDFMessageget_fromrzrFr+r get_unixfromrasctimegmtimerArWrrr _mangle_from_)r r+r~newlineauthorrfrgs r#rsz_mboxMMDF._install_message.sa? gs #++G4G gu %'*<*rJrHrArsrr%r#rxrxs%"M B .Ar%rxc*eZdZ dZdZddZdZdZy)rTNcL t|_tj||||yr)r r{rxr$rs r#r$z mbox.__init__T!) +4w7r%c0 |jtyrrrrks r#r]zmbox._post_message_hookYs: r%c gg}}d}|jjd |jj}|jj}|j dr`t |t |kr5|r"|j |t tz n|j ||j |d}nF|s6|r"|j |t tz n|j |n|tk(rd}nd}ttt|||_ t |j|_ |jj|_ y)NFrTr)rArrWrrrrrdict enumerateziprrBrF)r startsstopslast_was_emptyline_posrs r#rqzmbox._generate_toc]s>B zz(H::&&(Dx(u:F +% XG %<=  X. h'!&!LLCL!89LL*!%!&/03vu#567 TYY JJOO-r%r)rrrrrr$r]rqrr%r#rrKs !MO8 .r%rc(eZdZ ddZdZdZdZy)r NcL t|_tj||||yr)rr{rxr$rs r#r$z MMDF.__init__rr%c6 |jdtzyNrrks r#r[zMMDF._pre_message_hooks; #g-.r%cD |jtdztzyrrrks r#r]zMMDF._post_message_hooks: --78r%c gg}}|jjdd} |}|jj}|jj}|j dt zr|j | |}|jj}|jj}|dt zk(r"|j |tt z n|s|j |ny|snttt|||_ t|j|_ |jjdd|jj|_ y)Nrrr/)rArrrWrrrrrrrrrBrF)r rrnext_posrrs r#rqzMMDF._generate_tocs->B H::&&(Dzz(H2W<= h''H::..0D#zz0H2W<< XG %<=! X.#$3vu#567 TYY 1 JJOO-r%r)rrrr$r[r]rqrr%r#r r s8 /9.r%r ceZdZ ddZdZdZdZdZdZdZ d Z d Z d Z d Z d ZdZdZdZdZdZdZdZdZdZdZy)rNc tj||||tjj |j s|rtj |j dtjtjtjj|j dtjtjztjzdd|_yt|j d|_y)Nr .mh_sequencesiF)rr$rrrrrrxrrrO_EXCLrrrErs r#r$z MH.__init__s(tWf5ww~~djj)U+djj/!J!#bii!7"++!EuNO )44 r%c |j}t|dk(rd}nt|dz}tjj |j t|}t|}d} |jr t| |j||t!|t"r|j%|||jr t| |s t||S#t$r;|jr t|t|d}tj|wxYw#|jr t|wwxYw#|s t|wwxYw)NrrFT)rRrmaxrrrrrr+rErOrrrRrr0rr _dump_sequences)r r+rRnew_keyrrcloseds r#r,zMH.adds 2yy{ t9>G$i!mG77<< CL9 h ' ||1  $ &&w2gy1((':<< OA!%||$QN!FIIh'<< O As72E C&"D-?E &AD**D--EE EcJ tjj|jt |} t |d}|j tj|y#t$r1}|jtjk(rtd|zd}~wwxYwNr=r5) rrrrrrrxr0rrr>r4)r r/rrrs r#r0z MH.removes~Kww||DJJC1 T5!A GGI IIdO ww%,,&83>??  s A(( B"1,BB"c tjj|jt |} t |d} |jr t| tjtj |tjtjz|j||t!|t"r|j%|||jr t'| t)|y#t $r1}|jtjk(rtd|zd}~wwxYw#|jr t'|wwxYw#t)|wxYwr)rrrrrrrrr>r4rErOrxrO_TRUNCrrr rrRr)r r/r+rrrs r#r8zMH.__setitem__sLww||DJJC1 T5!A ||1  $r{{RZZ'?@A""7A.gy1((#6<< O N# ww%,,&83>??  << O  Ns< C;EAttjj |j t |d}n=ttjj |j t |d}|5|jr t| t|}|jr t| ddd|jjD]\}}||vs j!|S#t$r1}|jtjk(rtd|zd}~wwxYw#|jr t|wwxYw#1swYxYw)Nr=rr5)rErrrrrrrrr>r4rOr rR get_sequencesr_ add_sequence)r r/rrrrkey_lists r#r>zMH.get_messagesB ||djj#c(;UCdjj#c(;TB ||1  $l<< O#00288:ND(h  &; ! ww%,,&83>??  << O Qs<BD E(% E 0E( E,EE E%%E((E1c |jr>ttjj |j t |d}n=ttjj |j t |d}|5|jr t| |jjtd|jr t|cdddS#t$r1}|jtjk(rtd|zd}~wwxYw#|jr t|wwxYw#1swYyxYw)Nr=rr5r)rErrrrrrrrr>r4rOrrrrRr r/rrs r#rHz MH.get_bytess@ ||djj#c(;UCdjj#c(;TB ||1  $vvx''7<< O $ $  ww%,,&83>??  << O Qs<BC) E%#D&E) D#2,DD#&EEE c ttjj|jt |d}t|S#t $r1}|jtjk(rtd|zd}~wwxYw)Nrr5) rrrrrrrrr>r4rrs r#rAz MH.get_file1soD RWW\\$**c#h7>A !}  ww%,,&83>??  s=A B,BBct ttdtj|jDS)Nc3RK|]}|jr t|!ywr)isdigitr').0rs r# zMH.iterkeys..>s%:3I%).u:3Is%')iterrZrrrrNs r#rOz MH.iterkeys<s2+F:2::djj3I::; ;r%c tjjtjj|jt |Sr)rrrrrrr.s r#razMH.__contains__As/Gww~~bggll4::s3x@AAr%cH tt|jSr)rrQrOrNs r#rcz MH.__len__Es84 ())r%c |jsVttjj |j dd|_t|j d|_yy)Nrr=T)rErrrrrrArOrNs r#rtzMH.lockIsE||bggll4::GODJ tzz "DLr%c |jr4t|jt|j|`d|_yyrQ)rErRrArrNs r#rvz MH.unlockPs51 <<  $  #  DL r%c yrrrNs r#rrzMH.flushXs4r%c@ |jr|jyyr)rErvrNs r#rxzMH.close\s* << KKM r%c g}tj|jD][}tjj tjj |j|sK|j |]|Sr)rrrrrrrrs r#rzMH.list_foldersasW,ZZ +Eww}}RWW\\$**e<= e$, r%c ttjj|j||j dS)NFr rrrrrrr s r#r z MH.get_folderis09"'',,tzz62--7 7r%c ttjj|j||j S)Nrrr s r#rz MH.add_folderns.H"'',,tzz62--) )r%c^ tjj|j|}tj|}|dgk(r4tj tjj|dn|gk(rnt d|jztj|y)NrzFolder not empty: %s)rrrrrr0rr)r r rentriess r#rzMH.remove_folderss{;ww||DJJ/**T" ' ' IIbggll49 : ]  6 CD D r%c  i}ttjj|jddd5}t |j }|D]} |jd\}}t }|jD]f}|jr|jt|.d|jdD\} } |jt| | dzht|D cgc]} | |vr|  c} ||<t||d k(r||= ddd|Scc} w#t$rt!d |j#zwxYw#1swY|SxYw) NrrASCIIencodingrc32K|]}t|ywr)r')rxs r#rz#MH.get_sequences..s*K?a3q6?s-rrz"Invalid sequence specification: %s)rrrrrsetrRrrr,r'rprangerZrr|rrstrip) r resultsrall_keysrrcontentsrRspecrfrgr/s r#rzMH.get_sequencessNK "'',,tzz?;S7 SWX499;'H5%)ZZ_ND(5D ( 0<<> HHSY/*K4::c?*KKE4 KKeTAX(>? !1 5;4L%=LS,/8O&)L%=GDM74=)Q.#DMT&%="5%&J&*kkm'4555!T&s6E B$D7> D2 D7%E 2D77&EE  E*c ttjj|jddd} tj tj|j tjtjz|jD]\}}t|dk(r|j|dzd}d}tt|D]Q}|dz |k(r|sCd }|jd n/|rd}|j|d |n|jd |z|}S|r|jt|d z|jd  t|y#t|wxYw)Nrzr+rrrrFrTr z %s )rrrrrrxrrrr_rrrZrrr)r sequencesrrrRprev completingr/s r# set_sequenceszMH.set_sequencess%H djj/:D7 S  HHRWWQVVR[[2::%=> ?'oo/ dt9>s #" !#d),CQw$))-JGGCL#%* 4 56 ,D-GGCI,-GGDM)0, NKNs D*E00 E=c   |j}d}g}|jD]}|dz |k7r|j||dzf tjtj j |jt|tj j |jt|dztjtj j |jt||dz }|dz|_ t|dk(ry|jD](\}}|D]\}}||vs |||j!|< *|j#|y#ttf$r~tjtj j |jt|tj j |jt|dzYwxYw)Nrr)rrOrrrrrrrunlinkrrrrBrr_indexr) r rrchangesr/rroldrs r#packzMH.packsM&&( ==?CQw$TAX/BGGBGGLLSX>GGLLS]CE IIbggll4::s3x@A AID# w<1  'oo/ND(#S(?47HX^^C01$0 9%'8GIIbggll4::s3x@ ggll4::s4!8}EGGsA;E66B HHc |j}|j}|jD]2\}}||vr|j|||vs!||j|=4|D] }||vs|g||<|j |yr)rr_rrr)r r+r/pending_sequences all_sequencesrrsequences r#rzMH._dump_sequencessI#113**, +113ND((($X^^C01 4 *H},+.% h'* =)r%r)rrrr$r,r0r8r>rHrArOrarcrtrvrrrxrr rrrrrrrr%r#rrsu  D 02$* ; B* ! 7 ) 0:&4 *r%rcreZdZ ehdZddZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZy)r>filededitedresentunseendeletedanswered forwardedNcD tj||||i|_yr)r;r$_labelsrs r#r$zBabyl.__init__s )##D$@ r%c tj||}t|tr|j |j |<|Sr)r;r,rr get_labelsr)r r+r/s r#r,z Babyl.adds=2 $$T73 g| , ' 2 2 4DLL  r%cj tj||||jvr|j|=yyr)r;r0rr.s r#r0z Babyl.removes2K!!$, $,,  S! r%c tj|||t|tr|j |j |<yyr)r;r8rrrrr7s r#r8zBabyl.__setitem__s=L&&tS': g| , ' 2 2 4DLL  -r%c |j|\}}|jj||jjt j } |jj}|dt zk(s|sn&|j|jt dOt j } |jj}|t k(s|sn&|j|jt dL||jjz }|jj|}|jt d}t|j|z} | j|j||jvr| j|j|| SN *** EOOH ***r)rrArrrrrrrrWrrr set_visibler set_labels) r r/rfrgoriginal_headersrvisible_headersnbodyrs r#r>zBabyl.get_messagesaBll3' t  ::<::&&(D00  " "4<<#? @  **,::&&(Dwd  ! !$,,w"> ?  4::??$ $zzq!||GU++446=> 0023 $,,  NN4<<, - r%ct |j|\}}|jj||jjt j } |jj}|dt zk(s|sn&|j|jt dO |jj}|t k(s|sn'|j}||jjz }|jj|}|jt d}||zSr) rrArrrrrrrrrWr) r r/rfrgrrheadersrrs r#rHzBabyl.get_bytessAll3' t  ::<::&&(D00  " "4<<#? @  ::&&(Dwd#++- 4::??$ $zzq!||GU+~r%ct tj|j|jdtSr)rrrHrrr.s r#rAzBabyl.get_file-s*Dzz$..-55eWEFFr%c |jt}|jjD]}|j ||j |j t|Sr)rrrr[rpdifference_update_special_labelsrQ)r labels label_lists r#rzBabyl.get_labels1sVB ,,--/J MM* %0  !5!56F|r%cB gg}}|jjdd}g} |}|jj}|jj}|dtzk(rt |t |kr!|j |t tz |j ||jjddjdDcgc]"}|jr|j$}}|j |nn|dk(s |dtzk(r9t |t |krF|j |t tz n$|s"|j |t tz ndttt|||_ tt||_ t |j|_|jjdd|jj|_ycc}w)Nrs r,r/)rArrrWrrrrstriprrrrrrBrF) r rrr label_listsrrlabelr s r#rqzBabyl._generate_toc:s>B  H::&&(Dzz(H{W,,u:F +LLCL!89 h'+/::+>+>+@+D+J+J4+P:+P-2+0;;= ++-+P:""6*DGg,=$=u:F +LLCL!89 XG 45#$3vu#567 Ik23 TYY 1 JJOO-:s'Hc dtz}|dtzz }|j}d|D}|ddj|ztzz }|dz }|j|y)NsBABYL OPTIONS:s Version: 5c3<K|]}|jywr)rz)rrs r#rz*Babyl._pre_mailbox_hook..]s5fU%,,.fssLabels:r r )rrrr)r rbabylr s r#rYzBabyl._pre_mailbox_hookXsf:!G+ (("5f5 dii//'99  r%c6 |jdtzy)N rrks r#r[zBabyl._pre_message_hookbs; '!"r%c6 |jtdzy)Nr rrks r#r]zBabyl._post_message_hookfs: '!"r%c |jj}t|tr g}g}|j D]3}||j vr|j |#|j |5|jjd|D].}|jjd|jz0|jjd|D]1}|jjd|jzdz3|jjtn"|jjdtzt|tjjrtj}tjj!|dd}|j#||j%d |j'}|jj|j)d t|d k(s|snH|jjd tzt|trtj} tjj!| dd} | j#|j+ | j'}|jj|j)d t|d k(s|sn[H|j%d |j'}|jj|j)d t|d k(s|snH |j-d } | sn|jj| j)d tEt|t.t0tj2frt|tj2r+t5j6d t8d|j;}t|t0r|j=|}|j?ddz} | dz dk7r|jj|d| j)d t|jjd tz|jj|d| j)d t|jj|| dj)d tn|jjd tztz|jj|j)d tntA|drtA|dr't5j6dt8d|jB}|j} d } |j'}|jEdr |ddd z}n|jEdr|ddd z}|jj|j)d t|d k(s|s9|r6d}|jjd tz|j%| nn |j'}|sn|jEdr |ddtz}n;|jEdr |ddtz}n|jEd r |ddtz}|jj|tGdtI|z|jj}||fS)N1s, s,, r s1,,FrTrrrTrrs r/rrrrrrrr)%rArWrrrrrrrzrrFr+r rrrrrrrr get_visiblerrrrrrrrr}rrlrrrr)r r+rfspecial_labelsr r orig_bufferorig_generatorr vis_buffer vis_generatorr body_start original_pos first_passrgs r#rszBabyl._install_messagejs> ! g| ,NF ++-D000"))%0MM%( . JJ  T "'   !78( JJ  U #    !6!=> JJ  W % JJ  Vg- . gu}}44 5**,K"__;;KPQRN  " "7 +   Q "++-   eW!=>5=  JJ  _w6 7'<0ZZ\ % > >z5RS T %%g&9&9&;<%..0DJJ$$T\\%%ABu}D    #&//1DJJ$$T\\%%ABu}D  $))$/   w!?@  %bkk!: ;'2;;/ *+=qB!**,'3'//8 g.2JA~#   *!5!=!=eW!MN   7!:;   *!5!=!=eW!MN   !5!=!=eW!MN   7!:W!DE   !@A Wj )w) 56H!M!.."<<>LJ'')==)9u,D]]5)9u,D   eW!=>5=!%*  ((7)BC \2'')==)9w.D]]5)9w.D]]5)9w.D   &6gFG Gzz t}r%r)rrr frozensetrr$r,r0r8r>rHrArrqrYr[r]rsrr%r#rrsY'!BCO " 5 8,G.<##ir%rc"eZdZ ddZdZdZy)r Nc t|tjjrG|j t j |t|tr|j|yyt|tr%|j tj|yt|tr%|j tj|yt|tjr%|j tj|yt|dr%|j tj |y|*tjjj#|yt%dt'|z)Nrr)rrFr+r _become_messagecopydeepcopy _explain_torrGrmessage_from_stringr TextIOWrappermessage_from_filerlmessage_from_binary_filer$rrr*s r#r$zMessage.__init__s, gu}}44 5  w!7 8'7+##D),  '  !9!9'!B C  %  !:!:7!C D !1!1 2  !8!8!A B Wf %  !?!?!H I _ MM ! ! * *4 06gFG Gr%c t|dg}|jD]#}||vs|j||j|<%y)N_type_specific_attributes)getattr__dict__)r r+ type_specificrs r#r&zMessage._become_messagesE>)DbI $$D=(&-&6&6t&< d#%r%c< t|trytd)Nz Cannot convert to specified type)rr rr*s r#r)zMessage._explain_tosH gw ' >? ?r%r)rrrr$r&r)rr%r#r r s:H&=@r%r c`eZdZ gdZddZdZdZdZdZdZ d Z d Z d Z d Z d ZdZy)r )_subdir_info_dateNc d|_d|_tj|_tj ||y)Nrr)r5r6rr7r r$r*s r#r$zMaildirMessage.__init__s03  YY[ w'r%c |jSr)r5rNs r#rzMaildirMessage.get_subdirs$||r%cD |dk(s|dk(r||_ytd|z)Nrrz!subdir must be 'new' or 'cur': %s)r5r|)r rs r#rzMaildirMessage.set_subdir s*+ U?fo!DL@6IJ Jr%cZ |jjdr|jddSy)N2,r/r)r6rrNs r# get_flagszMaildirMessage.get_flagss*8 ::  &::ab> !r%cJ ddjt|z|_y)Nr<r)rrZr6)r flagss r# set_flagszMaildirMessage.set_flagss7BGGF5M22 r%c |jdjt|jt|zyNrr@rrr=r flags r#add_flagzMaildirMessage.add_flag/< rwws4>>#34s4y@ABr%c |jrD|jdjt|jt|z yyrB)r=r@rrrDs r# remove_flagzMaildirMessage.remove_flag!s>E >>  NN2773t~~'7#83t9#DE F r%c |jSr)r7rNs r#rzMaildirMessage.get_date&sJzzr%c` t||_y#t$rtd|zdwxYw)Nzcan't convert to float: %s)floatr7r|r)r dates r#rzMaildirMessage.set_date*s:G KtDJ K84?@d J Ks-c |jSr)r6rNs r#rzMaildirMessage.get_info1s3zzr%cb t|tr||_ytdt |z)Nzinfo must be a string: %s)rrr6rr)r ris r#rzMaildirMessage.set_info5s+. dC DJ7$t*DE Er%c t|tr^|j|j|j |j |j |jyt|trt|j}d|vr|jd|j dk(r|jdd|vr|jdd|vr|jdd|vr|jd|jd tj|jyt|trZt|j}d|vr|jd d|vr|jd d|vr|jd yyt|t rot|j}d|vr|j#d d|vr|j#d d|vr|j#dd|vr|j#dyyt|t$ryt'dt)|z)NSRrOTDFA MAILER-DAEMONrrepliedflaggedrrr#r$Cannot convert to specified type: %s)rr r@r=rrrrrrrFr}rrr rr add_labelr rr)r r+r?s r#r)zMaildirMessage._explain_to<sI g~ .   dnn. /   t0 1   T]]_ - !1 2()Ee|  % E)  %e|  %e|  %e|  %   _dkk$--/.J K  +()E%$$X.e|$$Y/e|$$Y/  .()E%!!(+e|!!),e|!!*-e|!!+.  ) B M*+ +r%r)rrrr/r$rrr=r@rFrIrrrrr)rr%r#r r sL3 =(K3CG KF)+r%r cHeZdZ dgZd dZdZd dZdZdZdZ d Z d Z y) r_fromNc  |jddt|tjjr7|j }|%|j dr|j|ddtj||y)NrXTzFrom r)r}rrFr+r rrr$)r r+rs r#r$z_mboxMMDFMessage.__init__msj5 ot, gu}}44 5++-H#(;(;G(D hqrl+w'r%c |jSr)r^rNs r#rz_mboxMMDFMessage.get_fromvs.zzr%c~ |3|durtj}|dtj|zz }||_y)NTr)rrrr^)r rtime_s r#r}z_mboxMMDFMessage.set_fromzs<L  }  S4<<.. .E r%cN |jdd|jddzS)NStatusrX-Status)r<rNs r#r=z_mboxMMDFMessage.get_flagss&8xx"%R(@@@r%c t|}d\}}dD]}||vs||z }|j|dD]}||vs||z }|j||djt|z } |j d| |j d|y#t $r|j d|Y1wxYw#t $r|j d|YywxYw)N)rr)rRrS)rUrVrWrrdre)rr0rrZreplace_headerr4 add_header)r r? status_flags xstatus_flagsrEs r#r@z_mboxMMDFMessage.set_flagss7E &,# mDu}$  T"$Du}%  T"$ //  4   , 7 7    M : 4 OOHl 3 4 7 OOJ 6 7s$4BB;B87B8;CCc |jdjt|jt|zyrBrCrDs r#rFz_mboxMMDFMessage.add_flagrGr%c d|vsd|vrD|jdjt|jt|z yy)NrdrerrCrDs r#rIz_mboxMMDFMessage.remove_flagsCE t zT1 NN2773t~~'7#83t9#DE F 2r%c t|trt|j}d|vr|j dd|vr|j dd|vr|j dd|vr|j dd|vr|j d|d =|d =d j |jjd d} |jtjtj|d yt|t r?|j#|j|j%|jyt|t&r_t|j}d|vr|j)dd|vr|j)dd|vr|j)d|d =|d =yt|t*r_t|j}d|vr|j-dd|vr|j-dd|vr|j-d|d =|d =yt|t.ryt1dt3|z#ttf$rYywxYw)NrSrrVrWrRrQrUrTstatuszx-statusrz%a %b %d %H:%M:%S %YrrYrZrrr[)rr rr=rrFrrrrcalendartimegmrstrptimer| OverflowErrorrr@r}r rrr\r rr)r r+r? maybe_dates r#r)z_mboxMMDFMessage._explain_tos<O g~ .()Ee|""5)e|  %e|  %e|  %e|  %! #$--/"7"7"9"#">?J   z6L2N"OP!1 2   dnn. /   T]]_ -  +()E%$$X.e|$$Y/e|$$Y/! #  .()E%!!(+e|!!),e|!!*-! #  ) B M*+ +9 .  s 8II+*I+r) rrrr/r$rr}r=r@rFrIr)rr%r#rrhs89!( (A7,CG 1+r%rc eZdZy)r Nrrrrr%r#r r 0r%r c:eZdZ dgZd dZdZdZdZdZdZ y) r _sequencesNc@ g|_tj||yr)ryr r$r*s r#r$zMHMessage.__init__s/w'r%c" |jddSr)ryrNs r#rzMHMessage.get_sequencessBq!!r%c& t||_yr)rQry)r rs r#rzMHMessage.set_sequencessAy/r%c t|tr+||jvr|jj|yyt dt |z)Nzsequence type must be str: %s)rrryrrrr rs r#rzMHMessage.add_sequencesIF h $t.&&x0/;d8nLM Mr%c\ |jj|y#t$rYywxYwr)ryr0r|r~s r#remove_sequencezMHMessage.remove_sequences.O  OO " "8 ,     ++c~ t|tr}t|j}d|vr|j dn"|j d|j dd|vr|j dd|vr|j dyyt|t rlt|j}d|vr|j dn|j d d|vr|j dd|vr|j d yyt|tr'|jD]}|j|yt|trEt|j}d|vr|jdd|vr|jd yyt|trytd t|z) NrrrQrZrVrYrRROrSrWrr[)rr rrrrFrr rrr\r rr)r r+rrs r#r)zMHMessage._explain_tosD g~ .D..01I9$""5)""5)  %I%  %I%  %& !1 2D..01Iy(  &  %I%  %I%  %&  + ..0$$X.1  .D..01I9$!!(+I%!!*-&  ) B M*+ +r%r) rrrr/r$rrrrr)rr%r#r r s,.!-( "*N$+r%r cNeZdZ ddgZd dZdZdZdZdZd Z d Z d Z d Z y)rr_visibleNc^ g|_t|_tj||yr)rr rr$r*s r#r$zBabylMessage.__init__*s%1   w'r%c" |jddSr)rrNs r#rzBabylMessage.get_labels0s5||Ar%c& t||_yr)rQr)r r s r#rzBabylMessage.set_labels4s4F| r%c t|tr+||jvr|jj|yyt dt |z)Nzlabel must be a string: %s)rrrrrrr rs r#r\zBabylMessage.add_label8sI9 eS !DLL( ##E*)84;FG Gr%c\ |jj|y#t$rYywxYwr)rr0r|rs r# remove_labelzBabylMessage.remove_label@s.B  LL   &   rc. t|jSrr rrNs r#rzBabylMessage.get_visibleGsAt}}%%r%c& t||_yrr)r visibles r#rzBabylMessage.set_visibleKs@( r%c |jjD]3}||vr |jj|||'|j|=5dD](}||vs||jvs|||j|<*y)N)DateFromzReply-ToToCCSubject)rrRrg)r headers r#update_visiblezBabylMessage.update_visibleOsyGmm((*F~ ,,VT&\BMM&) + JF~& "=(,V  f%Jr%c t|trt|j}d|vr|j dn"|j d|j dd|vsd|vr|j dd|vr|j dd |vr|j d yyt|t rlt|j}d|vr|j d n|j d d |vr|j d d|vr|j dyyt|trEt|j}d|vr|jdd|vr|jdyyt|trF|j|j|jD]}|j|yt|trytdt|z)NrrrQrrr#rrRrrTrrSrUrWrYr[)rr rrrrFrr rrrrr\r rr)r r+r rs r#r)zBabylMessage._explain_toZsG g~ .*+F6!""5)""5)  %f$F(:  %V#  %F"  %# !1 2*+Fv%  &  %F"  %V#  %$  +*+F6!$$X.V#$$Y/$  .    0 0 2 3*!!%(+  ) B M*+ +r%r) rrrr/r$rrr\rrrrr)rr%r#rr%s>1!*J 7( $H&) 5'+r%rc eZdZy)rNrvrr%r#rrrwr%rceZdZ ddZddZddZddZddZdZdZ dd Z d Z d Z d Z d ZdZdZdZdZedZeeZy)rNcR ||_||j|_y||_yr)rArW_pos)r rposs r#r$z_ProxyFile.__init__s%& ;DIDIr%cP |j||jjSr)_readrArr sizes r#rz_ProxyFile.readszz$ 00r%cP |j||jjSr)rrAread1rs r#rz_ProxyFile.read1s zz$ 0 011r%cP |j||jjSr)rrArrs r#rz_ProxyFile.readlines zz$ 3 344r%cn g}|D],}|j|||t|z}|dks+|S|S)Nr)rr)r sizehintrgrs r# readlinesz_ProxyFile.readlinessJ"D MM$ #CI%q=   r%c#bK |jx}r||jx}ryywr)r)r rs r#rYz_ProxyFile.__iter__s2!mmo%d%Jmmo%d%s*//c |jSr)rrNs r#rWz_ProxyFile.tells"yyr%c |dk(r%|jj|j|jj|||jj|_y)NrrArrrWr offsetwhences r#rz_ProxyFile.seeksD Q; JJOODII & 'JJOO% r%c t|dr4 t|jdr|jj|`yy#|`wxYw)NrArx)rlrArxrNs r#rxz_ProxyFile.closesE 4 ! 4::w/JJ$$&J " Js 0AAc |d}|jj|j||}|jj|_|S)Nrr)r r read_methodrgs r#rz_ProxyFile._readsD0 <D  "T"JJOO%  r%c |SrrrNs r# __enter__z_ProxyFile.__enter__s 2 r%c$|jyr)rx)r excs r#__exit__z_ProxyFile.__exit__s  r%c6|jjSr)rAreadablerNs r#rz_ProxyFile.readablezz""$$r%c6|jjSr)rAwritablerNs r#rz_ProxyFile.writablerr%c6|jjSr)rAseekablerNs r#rz_ProxyFile.seekablerr%c6|jjSr)rArrrNs r#rrz_ProxyFile.flushszz!!r%cvt|dsyt|jdsy|jjS)NrATrF)rlrArrNs r#rz_ProxyFile.closeds0tW%tzz8,zz   r%rr)rrrr$rrrrrYrWrrxrrrrrrrrpropertyrrrrrr%r#rrsv(125  &%%%"!!$L1r%rc0eZdZ ddZdZddZdZdZy) rNcP tj|||||_||_yr)rr$_start_stop)r rrfrgs r#r$z_PartialFile.__init__s%(D!U+  r%cH tj||jz Sr)rrWrrNs r#rWz_PartialFile.tells8t$t{{22r%c |dk(r|j|_d}n|dk(r|j|_d}tj |||y)Nrrr/)rrrrrrs r#rz_PartialFile.seeksCF Q; DIF q[ DIFff-r%c |j|jz }|dkry| |dks||kDr|}tj|||S)Nrr%)rrrr)r rr remainings r#rz_PartialFile._readsMIJJ* > <4!8ti'7DdK88r%c"t|dr|`yy)NrA)rlrArNs r#rxz_PartialFile.close s 4 !  "r%)NNr)rrrr$rWrrrxrr%r#rrs0 3.9r%rc d} tr6 tj|tjtjz|r{ t|jdz}|j tj|j|jdzd}tj|jyyy#t$rY}|j t j t jt jfvrtd|jzd}~wwxYw#t$r7}|j t jt jfvrYd}~yd}~wwxYw#t t"f$r2tj$|j|jdzd}YwxYw#t&$r8tj(|jtd|jzwxYw#tr$tj|tj*|r"tj(|jdzxYw)NFzlockf: lock unavailable: %s.lockTzdot lock unavailable: %s)fcntllockfLOCK_EXLOCK_NBrrEAGAINr?r@rrrXrxrrrrrrr,r0LOCK_UN)rrU dotlock_donerpre_locks r#rOrOs2L%   Au}}u}}<=  ,QVVg-=> 1-GGHMM166G+;<#'L IIhmm,!   77u||U\\5;;GG,-J-.VV.455   77u||U[[99  '8(IIhmmQVVg-=>#'L( # 1 (--(()C)**011 1  KK5== )  IIaffw& ' sG/5B?G/(D$./E'F+? D!ADD!!G/$ E$-,EG/EE$$G/'>F(%F+'F((F++AG,,G//AIc tr$tj|tjtjj |j dzr#tj|j dzyy)Nr)rrrrrrrr0rs r#rRrR;sM4  Au}}% ww~~affw&' !&&7"#(r%c  tj|tjtjztjzd} t|dtj |S#tj |wxYw)Nrr=)rrrrO_RDWRrx)rfds r#r+r+BsSM rzzBII- 95 ABD%    s A++Bc  t|dttjdtjdt j S)Nr)r+r'rr%r&rr()rs r#rXrXJs;L dC 4D.4.@.@.B.0iik; <rsJ     A **  G $f2f2Rsgsl CCN@"@F1.91.h*.9*.Zn*n*b v vr"@emm##"@Jj+Wj+Zn+wn+b1"1E+E+P\+7\+~1"1_2_2D$:$N(T$<   -I-EEIEI444%4aB EsE44E?>E?