usr/lib64/python2.7/mailbox.pyo000064400000225576147204505110012251 0ustar00 zfc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl Zddl Z y(ej dkre nddlZWne k reZnXddlZej0ejrejddenddlZWdQXdddd d d d d dddddddddgZdfdYZdefdYZdefdYZdefdYZdefdYZd efdYZd efdYZd efd YZd ejj fd!YZ d e fd"YZ!d#e fd$YZ"de"fd%YZ#de fd&YZ$de fd'YZ%de"fd(YZ&d)fd*YZ'd+e'fd,YZ(e)d-Z*d.Z+d/Z,d0Z-d1Z.d2Z/d3fd4YZ0de0fd5YZ1de1fd6YZ2de0fd7YZ3dfd8YZ4de0fd9YZ5d:e6fd;YZ7d<e7fd=YZ8d>e7fd?YZ9d@e7fdAYZ:dBe7fdCYZ;dS(DsDRead/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.iNtos2emxtignores.*rfc822 has been removedtMailboxtMaildirtmboxtMHtBabyltMMDFtMessagetMaildirMessaget mboxMessaget MHMessaget BabylMessaget MMDFMessaget UnixMailboxtPortableUnixMailboxt MmdfMailboxt MHMailboxt BabylMailboxcBs4eZdZdedZdZdZdZdZ dZ ddZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZddZdZddZdZdZdZ dZ!e"Z#e"dZ$RS( s*A group of messages in a particular place.cCs.tjjtjj||_||_dS(sInitialize a Mailbox instance.N(tostpathtabspatht expandusert_patht_factory(tselfRtfactorytcreate((s/usr/lib64/python2.7/mailbox.pyt__init__+s!cCstddS(s$Add message and return assigned key.s&Method must be implemented by subclassN(tNotImplementedError(Rtmessage((s/usr/lib64/python2.7/mailbox.pytadd0scCstddS(s=Remove the keyed message; raise KeyError if it doesn't exist.s&Method must be implemented by subclassN(R(Rtkey((s/usr/lib64/python2.7/mailbox.pytremove4scCs|j|dS(N(R!(RR ((s/usr/lib64/python2.7/mailbox.pyt __delitem__8scCs)y|j|Wntk r$nXdS(s'If the keyed message exists, remove it.N(R!tKeyError(RR ((s/usr/lib64/python2.7/mailbox.pytdiscard;s cCstddS(s>Replace the keyed message; raise KeyError if it doesn't exist.s&Method must be implemented by subclassN(R(RR R((s/usr/lib64/python2.7/mailbox.pyt __setitem__BscCs*y|j|SWntk r%|SXdS(s9Return the keyed message, or default if it doesn't exist.N(t __getitem__R#(RR tdefault((s/usr/lib64/python2.7/mailbox.pytgetFs cCs0|js|j|S|j|j|SdS(s=Return the keyed message; raise KeyError if it doesn't exist.N(Rt get_messagetget_file(RR ((s/usr/lib64/python2.7/mailbox.pyR&Ms  cCstddS(s4Return a Message representation or raise a KeyError.s&Method must be implemented by subclassN(R(RR ((s/usr/lib64/python2.7/mailbox.pyR)TscCstddS(s3Return a string representation or raise a KeyError.s&Method must be implemented by subclassN(R(RR ((s/usr/lib64/python2.7/mailbox.pyt get_stringXscCstddS(s6Return a file-like representation or raise a KeyError.s&Method must be implemented by subclassN(R(RR ((s/usr/lib64/python2.7/mailbox.pyR*\scCstddS(sReturn an iterator over keys.s&Method must be implemented by subclassN(R(R((s/usr/lib64/python2.7/mailbox.pytiterkeys`scCst|jS(sReturn a list of keys.(tlistR,(R((s/usr/lib64/python2.7/mailbox.pytkeysdsccsEx>|jD]0}y||}Wntk r7q nX|Vq WdS(s%Return an iterator over all messages.N(R,R#(RR tvalue((s/usr/lib64/python2.7/mailbox.pyt itervalueshs  cCs |jS(N(R0(R((s/usr/lib64/python2.7/mailbox.pyt__iter__qscCst|jS(s,Return a list of messages. Memory intensive.(R-R0(R((s/usr/lib64/python2.7/mailbox.pytvaluestsccsKxD|jD]6}y||}Wntk r7q nX||fVq WdS(s.Return an iterator over (key, message) tuples.N(R,R#(RR R/((s/usr/lib64/python2.7/mailbox.pyt iteritemsxs  cCst|jS(s9Return a list of (key, message) tuples. Memory intensive.(R-R3(R((s/usr/lib64/python2.7/mailbox.pytitemsscCstddS(s9Return True if the keyed message exists, False otherwise.s&Method must be implemented by subclassN(R(RR ((s/usr/lib64/python2.7/mailbox.pythas_keyscCs |j|S(N(R5(RR ((s/usr/lib64/python2.7/mailbox.pyt __contains__scCstddS(s*Return a count of messages in the mailbox.s&Method must be implemented by subclassN(R(R((s/usr/lib64/python2.7/mailbox.pyt__len__scCs(x!|jD]}|j|q WdS(sDelete all messages.N(R,R$(RR ((s/usr/lib64/python2.7/mailbox.pytclearscCs4y||}Wntk r"|SX|j||S(s3Delete the keyed message and return it, or default.(R#R$(RR R'tresult((s/usr/lib64/python2.7/mailbox.pytpops   cCs7x0|jD]}||j|fSWtddS(s6Delete an arbitrary (key, message) pair and return it.sNo messages in mailboxN(R,R:R#(RR ((s/usr/lib64/python2.7/mailbox.pytpopitemscCst|dr|j}n$t|dr<|j}n|}t}x<|D]4\}}y|||From treadtsFrom s>From isInvalid message type: %sN(t isinstancetemailRRtStringIOt generatort GeneratortflattentseekRGtreplaceRtlineseptwritet_append_newlinetendswithtstrR<tNoneR>treadlinet startswitht TypeErrorttype( RRttargett mangle_from_tbuffertgentdatatlastlinetline((s/usr/lib64/python2.7/mailbox.pyt _dump_messages<          "N(%t__name__t __module__t__doc__RVR>RRR!R"R$R%R(R&R)R+R*R,R.R0R1R2R3R4R5R6R7R8R:R;RBRCRDRERFR=RSRb(((s/usr/lib64/python2.7/mailbox.pyR(s@                         cBseZdZdZejedZdZdZ dZ dZ dZ dZ d Zd Zd Zd Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZRS(sA qmail-style Maildir mailbox.t:cCs tj||||itjj|jdd6tjj|jdd6tjj|jdd6|_tjj|js|rtj|jdx9|jj D]}tj|dqWqt |jni|_ idd6dd6|_ d|_ d|_dS(sInitialize a Maildir instance.ttmptnewtcuriig?N(RRRRtjoinRt_pathstexiststmkdirR2tNoSuchMailboxErrort_toct _toc_mtimest _last_readt _skewfactor(RtdirnameRRR((s/usr/lib64/python2.7/mailbox.pyRs  cCs|j}y|j||Wn.tk rP|jtj|jnXt|t|t r|j }|j |j }||j krd}qn d}d}tj j|jj|j d}tj j|j|||}t|t r4tj|jtj j|j|jfnyLttdrltj|j|tj|jntj|j|WnKtk r}tj|j|jtjkrtd|qnX|S(s$Add message and return assigned key.RHRhitlinks$Name clash with existing message: %s(t _create_tmpRbt BaseExceptionRFRR!tnamet _sync_closeRIR t get_subdirtcolontget_infoRtbasenametsplitRjRtutimetgetatimetget_dateR<RttrenametOSErrorterrnotEEXISTtExternalClashError(RRttmp_filetsubdirtsuffixtuniqtdestte((s/usr/lib64/python2.7/mailbox.pyR s@      % % cCs,tjtjj|j|j|dS(s=Remove the keyed message; raise KeyError if it doesn't exist.N(RR!RRjRt_lookup(RR ((s/usr/lib64/python2.7/mailbox.pyR!4scCsSy|j|Wn;tk r$n+tk rN}|jtjkrOqOnXdS(s'If the keyed message exists, remove it.N(R!R#RRtENOENT(RR R((s/usr/lib64/python2.7/mailbox.pyR$8s c Cs$|j|}|j|}|j|}t|trE|}n|}tjj|}|j|kr|j|j|jd}nd}|j |tjj |j |} tjj |j |||} t|trtj | tjj | |jfntj| | dS(s>Replace the keyed message; raise KeyError if it doesn't exist.iRHN(RRRIR RRRsRzR}R$RjRR~RRR( RR Rt old_subpathttemp_keyt temp_subpathtdominant_subpathRRttmp_pathtnew_path((s/usr/lib64/python2.7/mailbox.pyR%Cs"    "cCs|j|}ttjj|j|d}z+|jrN|j|}n t|}Wd|jXtjj |\}}|j ||j |kr|j |j |j dn|j tjjtjj|j||S(s4Return a Message representation or raise a KeyError.trNi(RtopenRRRjRRR RFR}t set_subdirRztset_infotset_datetgetmtime(RR tsubpathtftmsgRRw((s/usr/lib64/python2.7/mailbox.pyR)^s!    +cCsJttjj|j|j|d}z|jSWd|jXdS(s3Return a string representation or raise a KeyError.RN(RRRRjRRRGRF(RR R((s/usr/lib64/python2.7/mailbox.pyR+ps*cCs4ttjj|j|j|d}t|S(s6Return a file-like representation or raise a KeyError.trb(RRRRjRRt _ProxyFile(RR R((s/usr/lib64/python2.7/mailbox.pyR*xs*ccsO|jx>|jD]3}y|j|Wntk rAqnX|VqWdS(sReturn an iterator over keys.N(t_refreshRoRR#(RR ((s/usr/lib64/python2.7/mailbox.pyR,}s  cCs|j||jkS(s9Return True if the keyed message exists, False otherwise.(RRo(RR ((s/usr/lib64/python2.7/mailbox.pyR5s cCs|jt|jS(s*Return a count of messages in the mailbox.(RtlenRo(R((s/usr/lib64/python2.7/mailbox.pyR7s cCsdS(s"Write any pending changes to disk.N((R((s/usr/lib64/python2.7/mailbox.pyRCscCsdS(sLock the mailbox.N((R((s/usr/lib64/python2.7/mailbox.pyRDscCsdS(s#Unlock the mailbox if it is locked.N((R((s/usr/lib64/python2.7/mailbox.pyREscCsdS(sFlush and close the mailbox.N((R((s/usr/lib64/python2.7/mailbox.pyRFscCsg}xttj|jD]`}t|dkr|ddkrtjjtjj|j|r|j|dqqW|S(sReturn a list of folder names.iit.(RtlistdirRRRtisdirRjtappend(RR9tentry((s/usr/lib64/python2.7/mailbox.pyt list_folderss "$cCs/ttjj|jd|d|jdtS(s/Return a Maildir instance for the named folder.RRR(RRRRjRRR=(Rtfolder((s/usr/lib64/python2.7/mailbox.pyt get_folders cCstjj|jd|}t|d|j}tjj|d}tjj|stjtj|tj tj Bdn|S(s>Create a folder and return a Maildir instance representing it.RRt maildirfolderi( RRRjRRRRlRFRtO_CREATtO_WRONLY(RRRR9tmaildirfolder_path((s/usr/lib64/python2.7/mailbox.pyt add_folders cCstjj|jd|}xwtjtjj|dtjtjj|dD];}t|dks|ddkrWtd|qWqWWxutj|D]d}|dkr|dkr|dkrtjjtjj||rtd||fqqWxtj|d t D]i\}}}x*|D]"}tj tjj||q:Wx*|D]"}tj tjj||qgWq$Wtj |d S( s-Delete the named folder, which must be empty.RRhRiiisFolder contains message(s): %sRgs%Folder contains subdirectory '%s': %sttopdownN( RRRjRRRt NotEmptyErrorRtwalkR=R!trmdir(RRRRtroottdirstfiles((s/usr/lib64/python2.7/mailbox.pyt remove_folders #"$!%   $cCstj}xptjtjj|jdD]M}tjj|jd|}|tjj|dkr.tj|q.q.WdS(sDelete old files in "tmp".Rgi@N(ttimeRRRRjRRR!(RtnowRR((s/usr/lib64/python2.7/mailbox.pytcleans  (icCsItj}tj}d|kr9|jdd}nd|krZ|jdd}ndt|t|ddtjtj|f}tj j |j d|}ytj |Wnvt k r4}|jtjkr.tjd7_yt|SWq1t k r*}|jtjkr+q+q1Xq5nXtd |d S( s=Create a file in the tmp subdirectory and open and return it.t/s\057Rfs\072s%s.M%sP%sQ%s.%sig.ARgs&Name clash prevented file creation: %sN(Rtsockett gethostnameRPtintRtgetpidRt_countRRjRtstatRRRt_create_carefullyRR(RRthostnameRRR((s/usr/lib64/python2.7/mailbox.pyRus,    & cCs?tj|jd|jkrt}xS|jD]H}tjj|j|}||j|krkt }n||j|RoRRjRR}Rz(RtrefreshRtmtimeRRtpR((s/usr/lib64/python2.7/mailbox.pyRs&    $cCsy:tjjtjj|j|j|r9|j|SWntk rMnX|jy|j|SWn!tk rtd|nXdS(s=Use TOC to return subpath for given key, or raise a KeyError.sNo message with key: %sN(RRRlRjRRoR#R(RR ((s/usr/lib64/python2.7/mailbox.pyRs+   cCsot|ds!|j|_nxGtrjy||jjSWq$tk rSdStk rfq$q$Xq$WdS(s0Return the next message in a one-time iteration.t _onetime_keysN(R<R,RR>tnextt StopIterationRVR#(R((s/usr/lib64/python2.7/mailbox.pyR's   ( RcRdReRztrfc822RR>RRR!R$R%R)R+R*R,R5R7RCRDRERFRRRRRRRuRRR(((s/usr/lib64/python2.7/mailbox.pyRs6 )                $ t_singlefileMailboxcBseZdZdedZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZddZdZRS(sA single-file mailbox.cCstj||||yt|jd}Wntk r}|jtjkr}|rkt|jd}qt|jq|jtjtj fkrt|jd}qnX||_ d|_ d|_ t|_t|_t|_d|_dS(s!Initialize a single-file mailbox.srb+swb+RiN(RRRRtIOErrorRRRntEACCEStEROFSt_fileRVRot _next_keyR=t_pendingt _pending_synct_lockedt _file_length(RRRRRR((s/usr/lib64/python2.7/mailbox.pyR7s$      cCsF|j|j||j|j<|jd7_t|_|jdS(s$Add message and return assigned key.i(Rt_append_messageRoRR>R(RR((s/usr/lib64/python2.7/mailbox.pyRNs   cCs$|j||j|=t|_dS(s=Remove the keyed message; raise KeyError if it doesn't exist.N(RRoR>R(RR ((s/usr/lib64/python2.7/mailbox.pyR!Xs  cCs0|j||j||j|Replace the keyed message; raise KeyError if it doesn't exist.N(RRRoR>R(RR R((s/usr/lib64/python2.7/mailbox.pyR%^s ccs-|jx|jjD] }|VqWdS(sReturn an iterator over keys.N(RRoR.(RR ((s/usr/lib64/python2.7/mailbox.pyR,ds cCs|j||jkS(s9Return True if the keyed message exists, False otherwise.(RRo(RR ((s/usr/lib64/python2.7/mailbox.pyR5js cCs|jt|jS(s*Return a count of messages in the mailbox.(RRRo(R((s/usr/lib64/python2.7/mailbox.pyR7os cCs&|js"t|jt|_ndS(sLock the mailbox.N(Rt _lock_fileRR>(R((s/usr/lib64/python2.7/mailbox.pyRDts  cCs&|jr"t|jt|_ndS(s#Unlock the mailbox if it is locked.N(Rt _unlock_fileRR=(R((s/usr/lib64/python2.7/mailbox.pyREzs  c Cs|js/|jr+t|jt|_ndS|jjdd|jj}||jkr|td|j|fnt |j }yi}|j |xt |j jD]}|j |\}}|jj||j||j}xOtrJ|jjtd||jj}|dkr:Pn|j|qW||jf||<|j|qW|j|_Wn$|jtj|jnXt||jjtj|j j} tj|j| ytj|j|j Wnrtk rv} | jtj ksGtjdkrp| jtj!krptj|j tj|j|j qwnXt"|j d|_||_ t|_t|_|j#rt$|jd tndS( s"Write any pending changes to disk.Niis4Size of mailbox file changed (expected %i, found %i)iRHtos2srb+tdotlock(%RRt _sync_flushRR=ROttellRRt_create_temporaryRt_pre_mailbox_hooktsortedRoR.t_pre_message_hookR>RGtminRRt_post_message_hookRFRR!RwRxRtst_modetchmodRRRRRRRR( Rtcur_lentnew_filetnew_tocR tstarttstopt new_startR]tmodeR((s/usr/lib64/python2.7/mailbox.pyRCsd             !    cCsdS(s,Called before writing the mailbox to file f.N((RR((s/usr/lib64/python2.7/mailbox.pyRscCsdS(s-Called before writing each message to file f.N((RR((s/usr/lib64/python2.7/mailbox.pyRscCsdS(s,Called after writing each message to file f.N((RR((s/usr/lib64/python2.7/mailbox.pyRscCsAz|jWdz|jr*|jnWd|jjXXdS(sFlush and close the mailbox.N(RCRRERRF(R((s/usr/lib64/python2.7/mailbox.pyRFs  cCsb|jdkr|jn|dk r^y|j|SWq^tk rZtd|q^XndS(s'Return (start, stop) or raise KeyError.sNo message with key: %sN(RoRVt _generate_tocR#(RR ((s/usr/lib64/python2.7/mailbox.pyRs   cCs|jjdd|jj}t|jdkrT|j rT|j|jny3|j|j|j|}|j |jWn$t k r|jj |nX|jj |jj|_ |S(s;Append message to mailbox and return (start, stop) offsets.ii(RRORRRoRRRt_install_messageRRvttruncateRCR(RRtbeforetoffsets((s/usr/lib64/python2.7/mailbox.pyRs  N(RcRdReRVR>RRR!R%R,R5R7RDRERCRRRRFRR(((s/usr/lib64/python2.7/mailbox.pyR4s"        D    t _mboxMMDFcBs>eZdZeZdZedZedZdZ RS(sAn mbox or MMDF mailbox.cCs|j|\}}|jj||jjjtjd}|jj||jj}|j |jtjd}|j |d|S(s4Return a Message representation or raise a KeyError.RHs i( RRRORWRPRRQRGRt_message_factorytset_from(RR RRt from_linetstringR((s/usr/lib64/python2.7/mailbox.pyR)scCsm|j|\}}|jj||s;|jjn|jj||jj}|jtjdS(s3Return a string representation or raise a KeyError.s ( RRRORWRGRRPRRQ(RR tfrom_RRR((s/usr/lib64/python2.7/mailbox.pyR+ s cCsW|j|\}}|jj||s;|jjnt|j|jj|S(s6Return a file-like representation or raise a KeyError.(RRRORWt _PartialFileR(RR RRR((s/usr/lib64/python2.7/mailbox.pyR*s cCs/d}t|tri|jdri|jd}|dkrZ|| }||d}q|}d}nFt|trd|j}n$t|tjj r|j }n|dkrdt j t j }n|jj}|jj|tj|j||j|j|jj}||fS(s1Format a message and blindly write to self._file.sFrom s iiRHsFrom MAILER-DAEMON %sN(RVRIRURXtfindt_mboxMMDFMessagetget_fromRJRRt get_unixfromRtasctimetgmtimeRRRRRRQRbt _mangle_from_(RRRtnewlineRR((s/usr/lib64/python2.7/mailbox.pyRs&    ( RcRdReR>RR)R=R+R*R(((s/usr/lib64/python2.7/mailbox.pyRs  cBs;eZdZeZeZdedZdZdZ RS(sA classic mbox mailbox.cCs#t|_tj||||dS(sInitialize an mbox mailbox.N(R RRR(RRRR((s/usr/lib64/python2.7/mailbox.pyR=s cCs|jtjdS(s,Called after writing each message to file f.N(RRRRQ(RR((s/usr/lib64/python2.7/mailbox.pyRBscCs\gg}}t}|jjdxtr|jj}|jj}|jdrt|t|kr|r|j|tt j q|j|n|j|t}q&|s|r|j|tt j n |j|Pq&|t j kr t}q&t}q&Wt t t |||_t|j|_|jj|_dS(s0Generate key-to-(start, stop) table of contents.isFrom N(R=RROR>RRWRXRRRRQtdictt enumeratetzipRoRR(Rtstartststopstlast_was_emptytline_posRa((s/usr/lib64/python2.7/mailbox.pyRFs0       N( RcRdReR>RRSRVRRR(((s/usr/lib64/python2.7/mailbox.pyR4s  cBs8eZdZdedZdZdZdZRS(sAn MMDF mailbox.cCs#t|_tj||||dS(sInitialize an MMDF mailbox.N(R RRR(RRRR((s/usr/lib64/python2.7/mailbox.pyRks cCs|jdtjdS(s-Called before writing each message to file f.sN(RRRRQ(RR((s/usr/lib64/python2.7/mailbox.pyRpscCs|jtjdtjdS(s,Called after writing each message to file f.sN(RRRRQ(RR((s/usr/lib64/python2.7/mailbox.pyRtscCsbgg}}|jjdd}xtr|}|jj}|jj}|jdtjr|j|xtr|}|jj}|jj}|dtjkr|j|t tjPqv|dkrv|j|PqvqvWq&|dkr&Pq&q&Wt t t |||_ t |j |_|jjdd|jj|_dS(s0Generate key-to-(start, stop) table of contents.isRHiN(RROR>RWRRXRRQRRRRRRoRR(RRRtnext_posRRa((s/usr/lib64/python2.7/mailbox.pyRxs2        N( RcRdReRVR>RRRR(((s/usr/lib64/python2.7/mailbox.pyRhs   cBseZdZdedZdZdZdZdZ dZ dZ dZ d Z d Zd Zd Zd ZdZdZdZdZdZdZdZdZdZRS(sAn MH mailbox.cCstj||||tjj|js|rtj|jdtjtjtjj |jdtj tj Btj Bdqt |jnt|_dS(sInitialize an MH instance.is .mh_sequencesiN(RRRRRlRRmRFRRjRtO_EXCLRRnR=R(RRRR((s/usr/lib64/python2.7/mailbox.pyRs!!cCs:|j}t|dkr'd}nt|d}tjj|jt|}t|}t }z|j rt |nzy|j ||WnGt k r|j rt|nt|t}tj|nXt|tr|j||nWd|j rt|nXWd|s5t|nX|S(s$Add message and return assigned key.iiN(R.RtmaxRRRjRRURR=RRRbRvRRxR>R!RIR t_dump_sequences(RRR.tnew_keyRRtclosed((s/usr/lib64/python2.7/mailbox.pyRs6           cCstjj|jt|}yt|d}Wn;tk rn}|jtjkrht d|qnX|j tj |dS(s=Remove the keyed message; raise KeyError if it doesn't exist.srb+sNo message with key: %sN( RRRjRRURRRRR#RFR!(RR RRR((s/usr/lib64/python2.7/mailbox.pyR!s cCstjj|jt|}yt|d}Wn;tk rn}|jtjkrht d|qonXz|j rt |nzYtj tj|tj tjB|j||t|tr|j||nWd|j rt|nXWdt|XdS(s>Replace the keyed message; raise KeyError if it doesn't exist.srb+sNo message with key: %sN(RRRjRRURRRRR#RRRFRtO_TRUNCRbRIR RRRx(RR RRRR((s/usr/lib64/python2.7/mailbox.pyR%s$  # cCs1y^|jr6ttjj|jt|d}n'ttjj|jt|d}Wn;tk r}|jtj krt d|qnXzD|jrt |nzt |}Wd|jrt |nXWd|jXx<|jjD](\}}||kr|j|qqW|S(s4Return a Message representation or raise a KeyError.sr+RsNo message with key: %sN(RRRRRjRRURRRR#RR RRFt get_sequencesR3t add_sequence(RR RRRRwtkey_list((s/usr/lib64/python2.7/mailbox.pyR)s( *+     cCsy^|jr6ttjj|jt|d}n'ttjj|jt|d}Wn;tk r}|jtj krt d|qnXzB|jrt |nz|j SWd|jrt |nXWd|jXdS(s3Return a string representation or raise a KeyError.sr+RsNo message with key: %sN(RRRRRjRRURRRR#RRGRRF(RR RR((s/usr/lib64/python2.7/mailbox.pyR+s  *+   cCssy+ttjj|jt|d}Wn;tk rh}|jtjkrbt d|qinXt |S(s6Return a file-like representation or raise a KeyError.RsNo message with key: %s( RRRRjRRURRRR#R(RR RR((s/usr/lib64/python2.7/mailbox.pyR*s+cCs&ttdtj|jDS(sReturn an iterator over keys.css'|]}|jrt|VqdS(N(tisdigitR(t.0R((s/usr/lib64/python2.7/mailbox.pys +s(titerRRRR(R((s/usr/lib64/python2.7/mailbox.pyR,)scCs(tjjtjj|jt|S(s9Return True if the keyed message exists, False otherwise.(RRRlRjRRU(RR ((s/usr/lib64/python2.7/mailbox.pyR5.scCstt|jS(s*Return a count of messages in the mailbox.(RR-R,(R((s/usr/lib64/python2.7/mailbox.pyR72scCsJ|jsFttjj|jdd|_t|jt|_ndS(sLock the mailbox.s .mh_sequencessrb+N( RRRRRjRRRR>(R((s/usr/lib64/python2.7/mailbox.pyRD6s $ cCs9|jr5t|jt|j|`t|_ndS(s#Unlock the mailbox if it is locked.N(RRRRxR=(R((s/usr/lib64/python2.7/mailbox.pyRE=s    cCsdS(s&Write any pending changes to the disk.N((R((s/usr/lib64/python2.7/mailbox.pyRCEscCs|jr|jndS(sFlush and close the mailbox.N(RRE(R((s/usr/lib64/python2.7/mailbox.pyRFIs cCs[g}xNtj|jD]:}tjjtjj|j|r|j|qqW|S(sReturn a list of folder names.(RRRRRRjR(RR9R((s/usr/lib64/python2.7/mailbox.pyRNs $cCs+ttjj|j|d|jdtS(s+Return an MH instance for the named folder.RR(RRRRjRRR=(RR((s/usr/lib64/python2.7/mailbox.pyRVscCs%ttjj|j|d|jS(s:Create a folder and return an MH instance representing it.R(RRRRjRR(RR((s/usr/lib64/python2.7/mailbox.pyR[scCstjj|j|}tj|}|dgkrUtjtjj|dn"|gkrdntd|jtj|dS(s-Delete the named folder, which must be empty.s .mh_sequencessFolder not empty: %sN(RRRjRRR!RR(RRRtentries((s/usr/lib64/python2.7/mailbox.pyR`s c Csmi}ttjj|jdd}z4t|j}x|D]}y|jd\}}t}xo|jD]a}|jr|j t |qwd|jdD\} } |j t | | dqwWgt |D]} | |kr| ^q||zst-iis"Invalid sequence specification: %sN(RRRRjRtsetR.R}RRRRBtrangeRRt ValueErrort FormatErrortrstripRF( RtresultsRtall_keysRaRwtcontentsR.tspecRRR ((s/usr/lib64/python2.7/mailbox.pyR ls,!     cCsettjj|jdd}z2tjtj|jtjtjBx|j D]\}}t |dkr{qWn|j d|d }t }xtt|D]r}|d|kr|st}|j dqn7|rt }|j d||fn|j d||}qW|rA|j t|d qW|j d qWWWd t|Xd S( s:Set sequences using the given name-to-key-list dictionary.s .mh_sequencessr+is%s:iRs%s %ss %ss N(RRRRjRRFRwRR R3RRRRVR=RRR>RURx(Rt sequencesRRwR.tprevt completingR ((s/usr/lib64/python2.7/mailbox.pyt set_sequencess.!& c Cs|j}d}g}x|jD]}|d|kr|j||dfttdrtjtjj|jt |tjj|jt |dtj tjj|jt |qtj tjj|jt |tjj|jt |dn|d7}q%W|d|_ t |dkrEdSxS|jD]E\}}x6|D].\}}||kre|||j|RRR!R%R)R+R*R,R5R7RDRERCRFRRRRR R R%R(((s/usr/lib64/python2.7/mailbox.pyRs. "                 cBseZdZedZdedZd Zd Z d Z d Z d Z dZ dZdZdZdZdZdZRS(sAn Rmail-style Babyl mailbox.tunseentdeletedtfiledtansweredt forwardedteditedtresentcCs#tj||||i|_dS(sInitialize a Babyl mailbox.N(RRt_labels(RRRR((s/usr/lib64/python2.7/mailbox.pyRscCs;tj||}t|tr7|j|j|Replace the keyed message; raise KeyError if it doesn't exist.N(RR%RIR R1R0(RR R((s/usr/lib64/python2.7/mailbox.pyR%sc Cs}|j|\}}|jj||jjtj}xXtr|jj}|dtjksu|dkryPn|j|j tjdqAWtj}xTtr|jj}|tjks|dkrPn|j|j tjdqW|jj ||jj j tjd}t |j |}|j|j ||jkry|j|j|n|S(s4Return a Message representation or raise a KeyError.s *** EOOH ***RHs (RRRORWRKR>RRQRRRPRGRR tgetvaluet set_visibleR0t set_labels( RR RRtoriginal_headersRatvisible_headerstbodyR((s/usr/lib64/python2.7/mailbox.pyR)s,       % cCs |j|\}}|jj||jjtj}xXtr|jj}|dtjksu|dkryPn|j|j tjdqAWx8tr|jj}|tjks|dkrPqqW|j |jj ||jj j tjdS(s3Return a string representation or raise a KeyError.s *** EOOH ***RHs ( RRRORWRKR>RRQRRRPR2RGR(RR RRR5Ra((s/usr/lib64/python2.7/mailbox.pyR+s       %cCs%tj|j|jdtjS(s6Return a file-like representation or raise a KeyError.s (RKR+RPRRQ(RR ((s/usr/lib64/python2.7/mailbox.pyR*scCsT|jt}x$|jjD]}|j|q#W|j|jt|S(s4Return a list of user-defined labels in the mailbox.(RRR0R2RBtdifference_updatet_special_labelsR-(Rtlabelst label_list((s/usr/lib64/python2.7/mailbox.pyR1s   c Csgg}}|jjdd}g}x[tr|}|jj}|jj}|dtjkrt|t|kr|j|ttjn|j|g|jjdj dD]$}|j dkr|j ^q}|j|q,|dks!|dtjkrYt|t|kr|j|ttjqq,|dkr,|j|ttjPq,q,Wt t t |||_t t ||_t|j|_|jjdd|jj|_dS( s0Generate key-to-(start, stop) table of contents.is it,RHsiN(RROR>RWRRRQRRR}tstripRRRRoR0RR( RRRRt label_listsRRatlabelR:((s/usr/lib64/python2.7/mailbox.pyR$s6    $  cCs9|jdtjtjdj|jtjfdS(s,Called before writing the mailbox to file f.s(BABYL OPTIONS:%sVersion: 5%sLabels:%s%sR<N(RRRRQRjR1(RR((s/usr/lib64/python2.7/mailbox.pyRBs cCs|jdtjdS(s-Called before writing each message to file f.s N(RRRRQ(RR((s/usr/lib64/python2.7/mailbox.pyRHscCs|jtjddS(s,Called after writing each message to file f.sN(RRRRQ(RR((s/usr/lib64/python2.7/mailbox.pyRLscCs,|jj}t|trg}g}x@|jD]2}||jkr\|j|q7|j|q7W|jjdx"|D]}|jjd|qW|jjdx&|D]}|jjd|dqW|jjtj n|jjdtj t|t j j rt j }t jj|td}|j||jdxQtr|j}|jj|jdtj |dks|d kr^Pq^q^W|jjd tj t|trct j } t jj| td} | j|jxtr_| j}|jj|jdtj |dksX|d krPqqWna|jdxQtr|j}|jj|jdtj |dks|d krsPqsqsWxLtr|jd } | d krPn|jj| jdtj qWnt|tr|jd d } | d dkr|jj|| jdtj |jjd tj |jj|| jdtj |jj|| jdtj q|jjd tj tj |jj|jdtj n t|dr|j} t}xtr|j}|jj|jdtj |dkst|d kr+|rt}|jjd tj |j| qPq+q+Wxatr|jd } | d krPn|jj| jdtj qWntdt||jj}||fS(s0Write message contents and return (start, stop).t1s, s,,t R<s1,,is RHs *** EOOH ***is iiRWsInvalid message type: %s(RRRIR R1R9RRRRRQRJRRRKRLRMR=RNROR>RWRPt get_visibleRGRURR<RYRZ(RRRtspecial_labelsR:R?t orig_buffertorig_generatorRat vis_buffert vis_generatorR]t body_startt original_post first_passR((s/usr/lib64/python2.7/mailbox.pyRPs                &  "     &(R)R*R+R,R-R.R/N(RcRdRet frozensetR9RVR>RRR!R%R)R+R*R1RRRRR(((s/usr/lib64/python2.7/mailbox.pyRs            cBs,eZdZddZdZdZRS(s0Message with mailbox-format-specific properties.cCst|tjjrM|jtj|t|tr|j|qnt|tru|jtj |n`t |dr|jtj |n8|dkrtjjj |ntdt|dS(sInitialize a Message instance.RGsInvalid message type: %sN(RIRJRRt_become_messagetcopytdeepcopyt _explain_toRUtmessage_from_stringR<tmessage_from_fileRVRRYRZ(RR((s/usr/lib64/python2.7/mailbox.pyRs cCs)x"d D]}|j||j|ntdt|dS(s;Copy Maildir-specific state to message insofar as possible.tStRRitOtTtDtFtAs MAILER-DAEMONR)trepliedtflaggedR*R,tPR-s$Cannot convert to specified type: %sN(RIR R`R^RRyRRRRRbRRRR R R t add_labelRRYRZ(RRR_((s/usr/lib64/python2.7/mailbox.pyROsN    "       N(RcRdReRVRRyRR^R`RbRcRRR{RRO(((s/usr/lib64/python2.7/mailbox.pyR s           RcBs\eZdZd dZdZd dZdZdZdZ dZ dZ RS( s/Message with mbox- or MMDF-specific properties.cCsw|jdtt|tjjrc|j}|dk rc|jdrc|j|dqcntj ||dS(s'Initialize an mboxMMDFMessage instance.s MAILER-DAEMONsFrom iN( RR>RIRJRRRRVRXR(RRtunixfrom((s/usr/lib64/python2.7/mailbox.pyR7s  cCs|jS(s Return contents of "From " line.(t_from(R((s/usr/lib64/python2.7/mailbox.pyR@scCsN|dk rA|tkr'tj}n|dtj|7}n||_dS(s>Set "From " line, formatting and appending time_ if specified.RAN(RVR>RRRRs(RRttime_((s/usr/lib64/python2.7/mailbox.pyRDs   cCs |jdd|jddS(s*Return as a string the flags that are set.tStatusRHsX-Status(R((R((s/usr/lib64/python2.7/mailbox.pyR^LscCst|}d \}}x4d D],}||kr||7}|j|qqWx4d D],}||krV||7}|j|qVqVW|djt|7}y|jd|Wn!tk r|jd|nXy|jd|Wn!tk r|jd|nXd S( s)Set the given flags and unset all others.RHRhRiRkRlRmRusX-StatusN(RHRH(RhRi(RkRlRm(RR!RjRtreplace_headerR#t add_header(RR_t status_flagst xstatus_flagsRa((s/usr/lib64/python2.7/mailbox.pyR`Ps&          cCs0|jdjt|jt|BdS(s.Set the given flag(s) without changing others.RHN(R`RjRR^(RRa((s/usr/lib64/python2.7/mailbox.pyRbfscCsKd|ksd|krG|jdjt|jt|ndS(s7Unset the given string flag(s) without changing others.RusX-StatusRHN(R`RjRR^(RRa((s/usr/lib64/python2.7/mailbox.pyRcjscCst|trt|j}d|kr=|jdnd|krY|jdnd|kru|jdnd|kr|jdnd|kr|jdn|d =|d =d j|jjd }y&|j t j t j |d Wqttfk rqXnlt|trU|j|j|j|jn4t|trt|j}d|kr|jdnd|kr|jdnd|kr|jdn|d =|d =nt|trat|j}d|kr|jdnd|kr4|jdnd|krP|jdn|d =|d =n(t|trsntdt|dS(sACopy mbox- or MMDF-specific state to message insofar as possible.RiRiRlRmRhRgRkRjtstatussx-statusRAis%a %b %d %H:%M:%S %YR)RnRoR*R,s$Cannot convert to specified type: %sN(RIR RR^RRbRjRR}RtcalendarttimegmRtstrptimeRt OverflowErrorRR`RR R R RqRRYRZ(RRR_t maybe_date((s/usr/lib64/python2.7/mailbox.pyROos^             N( RcRdReRVRRRR^R`RbRcRO(((s/usr/lib64/python2.7/mailbox.pyR4s      cBseZdZRS(s&Message with mbox-specific properties.(RcRdRe(((s/usr/lib64/python2.7/mailbox.pyR scBsGeZdZddZdZdZdZdZdZ RS(s$Message with MH-specific properties.cCsg|_tj||dS(s!Initialize an MHMessage instance.N(t _sequencesRR(RR((s/usr/lib64/python2.7/mailbox.pyRs cCs|jS(s4Return a list of sequences that include the message.(R(R((s/usr/lib64/python2.7/mailbox.pyR scCst||_dS(s3Set the list of sequences that include the message.N(R-R(RR((s/usr/lib64/python2.7/mailbox.pyR scCsNt|tr4||jkrJ|jj|qJntdt|dS(s8Add sequence to list of sequences including the message.ssequence must be a string: %sN(RIRURRRYRZ(RR(((s/usr/lib64/python2.7/mailbox.pyR scCs,y|jj|Wntk r'nXdS(sARemove sequence from the list of sequences including the message.N(RR!R(RR(((s/usr/lib64/python2.7/mailbox.pytremove_sequences cCst|trt|j}d|kr=|jdn|jd|jdd|krs|jdnd|kr|jdqn?t|trt|j}d|kr|jdn |jd d|kr|jdnd|kr|jd qnt|trMx|jD]}|j|q3Wnt|t rt|j}d|kr|j dnd|kr|j d qn(t|t rnt d t |d S(s6Copy MH-specific state to message insofar as possible.R)RiRgRoRlRnRhtRORiRmR,s$Cannot convert to specified type: %sN(RIR RR RRbRR R R RqRRYRZ(RRRR(((s/usr/lib64/python2.7/mailbox.pyROs@           N( RcRdReRVRR R R RRO(((s/usr/lib64/python2.7/mailbox.pyR s     cBsbeZdZd dZdZdZdZdZdZ dZ dZ d Z RS( s'Message with Babyl-specific properties.cCs)g|_t|_tj||dS(s#Initialize a BabylMessage instance.N(R0Rt_visibleR(RR((s/usr/lib64/python2.7/mailbox.pyRs  cCs|jS(s'Return a list of labels on the message.(R0(R((s/usr/lib64/python2.7/mailbox.pyR1scCst||_dS(s&Set the list of labels on the message.N(R-R0(RR:((s/usr/lib64/python2.7/mailbox.pyR4scCsNt|tr4||jkrJ|jj|qJntdt|dS(s+Add label to list of labels on the message.slabel must be a string: %sN(RIRUR0RRYRZ(RR?((s/usr/lib64/python2.7/mailbox.pyRqscCs,y|jj|Wntk r'nXdS(s4Remove label from the list of labels on the message.N(R0R!R(RR?((s/usr/lib64/python2.7/mailbox.pyt remove_labels cCs t|jS(s3Return a Message representation of visible headers.(RR(R((s/usr/lib64/python2.7/mailbox.pyRB scCst||_dS(s2Set the Message representation of visible headers.N(RR(Rtvisible((s/usr/lib64/python2.7/mailbox.pyR3scCsxG|jjD]6}||kr<|jj|||q|j|=qWx=dD]5}||krQ||jkrQ|||j|t|dr:t|jdr1|jjn|`ndS(sClose the file.RRFN(R<RRF(R((s/usr/lib64/python2.7/mailbox.pyRF{scCsJ|dkrd}n|jj|j||}|jj|_|S(s"Read size bytes using read_method.iN(RVRRORR(RRt read_methodR9((s/usr/lib64/python2.7/mailbox.pyRs    N( RcRdReRVRRGRWRR1RRORFR(((s/usr/lib64/python2.7/mailbox.pyRNs       RcBsDeZdZdddZdZddZdZdZRS(s&A read-only wrapper of part of a file.cCs)tj|||||_||_dS(sInitialize a _PartialFile.N(RRt_startt_stop(RRRR((s/usr/lib64/python2.7/mailbox.pyRs cCstj||jS(s*Return the position with respect to start.(RRR(R((s/usr/lib64/python2.7/mailbox.pyRsicCsY|dkr!|j|_d}n!|dkrB|j|_d}ntj|||dS(s8Change position, possibly with respect to start or stop.iiiN(RRRRRO(RRR((s/usr/lib64/python2.7/mailbox.pyROs      cCs`|j|j}|dkr dS|dksD|dksD||krM|}ntj|||S(s;Read size bytes using read_method, honoring start and stop.iRHN(RRRVRR(RRRt remaining((s/usr/lib64/python2.7/mailbox.pyRs  $ cCst|dr|`ndS(NR(R<R(R((s/usr/lib64/python2.7/mailbox.pyRFsN( RcRdReRVRRRORRF(((s/usr/lib64/python2.7/mailbox.pyRs   cCst}ytrytj|tjtjBWqtk r|}|jtjtjtj fkrvt d|j q}qXn|ry!t |j d}|j Wn5tk r}|jtjtj fkrdSnXyfttdr$tj|j |j dt}tj|j n tj|j |j dt}Wqtk r}|jtjkstj dkr|jtjkrtj|j t d|j qqXnWnCtrtj|tjn|rtj|j dnnXdS(s(Lock file f using lockf and dot locking.slockf: lock unavailable: %ss.lockNRtRsdot lock unavailable: %s(R=tfcntltlockftLOCK_EXtLOCK_NBRRtEAGAINRRRRwRRFR<RRtR>R!RRRR!tLOCK_UN(RRt dotlock_doneRtpre_lock((s/usr/lib64/python2.7/mailbox.pyRsL!  !cCsPtrtj|tjntjj|jdrLtj|jdndS(s*Unlock file f using lockf and dot locking.s.lockN(RRRRRRlRwR!(R((s/usr/lib64/python2.7/mailbox.pyRscCsLtj|tjtjBtjBd}zt|dSWdtj|XdS(sCCreate a file if it doesn't exist and open for reading and writing.isrb+N(RRRRtO_RDWRRF(Rtfd((s/usr/lib64/python2.7/mailbox.pyRs&cCs2td|ttjtjtjfS(sBCreate a temp file based on path and open for reading and writing.s %s.%s.%s.%s(RRRRRRR(R((s/usr/lib64/python2.7/mailbox.pyRs cCs3|jttdr/tj|jndS(s0Ensure changes to file f are physically on disk.tfsyncN(RCR<RRtfileno(R((s/usr/lib64/python2.7/mailbox.pyRs cCst||jdS(s:Close file f, ensuring all changes are physically on disk.N(RRF(R((s/usr/lib64/python2.7/mailbox.pyRxs t_MailboxcBs)eZejdZdZdZRS(cCs||_d|_||_dS(Ni(tfptseekpR(RRR((s/usr/lib64/python2.7/mailbox.pyRs  cCst|jdS(N(RRRV(R((s/usr/lib64/python2.7/mailbox.pyR1 scCsx|jj|jy|jWn$tk rJ|jj|_dSX|jj}|j|jj|_}||krPqqW|jt |j||S(N( RRORt _search_starttEOFErrorRRVt _search_endRR(RRR((s/usr/lib64/python2.7/mailbox.pyRs   (RcRdRRRR1R(((s/usr/lib64/python2.7/mailbox.pyRs cBs>eZdZdZdZdZdZdZeZ RS(cCskxd|jj}|jj}|s0tn|d dkr|j|r|jj|dSqWdS(NisFrom (RRRWRt_isrealfromlineRO(RRRa((s/usr/lib64/python2.7/mailbox.pyR!s cCss|jjx_|jj}|jj}|s8dS|d dkr|j|r|jj|dSqWdS(NisFrom (RRWRRRO(RRRa((s/usr/lib64/python2.7/mailbox.pyR+s saFrom \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*[^\s]*\s*$cCs=|js-ddl}|j|j|_n|jj|S(Ni(t_regexptretcompilet_fromlinepatterntmatch(RRaR((s/usr/lib64/python2.7/mailbox.pyt_strict_isrealfromlineUs  cCstS(N(R>(RRa((s/usr/lib64/python2.7/mailbox.pyt_portable_isrealfromline[sN( RcRdRRRRVRRRR(((s/usr/lib64/python2.7/mailbox.pyRs $  cBseZejZRS((RcRdRRR(((s/usr/lib64/python2.7/mailbox.pyRascBseZdZdZRS(cCs=x6|jj}|s!tn|d dkrdSqWdS(Nis (RRWR(RRa((s/usr/lib64/python2.7/mailbox.pyRgs  cCsSxL|jj}|jj}|s+dS|dkr|jj|dSqWdS(Ns (RRRWRO(RRRa((s/usr/lib64/python2.7/mailbox.pyRos (RcRdRR(((s/usr/lib64/python2.7/mailbox.pyRes cBs)eZejdZdZdZRS(cCsddl}|jd}||_tj|j}t|j|}tt|}|j tt ||_ |j j ||_ dS(Nis ^[1-9][0-9]*$(RRRsRRtfilterRtmaptlongtsortRUtboxestreverseR(RRsRRtpatR-((s/usr/lib64/python2.7/mailbox.pyR|s    cCst|jdS(N(RRRV(R((s/usr/lib64/python2.7/mailbox.pyR1scCst|js dS|jj}ttjj|j|}|j|}y ||_ Wnt t fk ronX|S(N( RRVR:RRRRjRsRt _mh_msgnotAttributeErrorRY(RtfnRR((s/usr/lib64/python2.7/mailbox.pyRs  (RcRdRRRR1R(((s/usr/lib64/python2.7/mailbox.pyRzs cBseZdZdZRS(cCs9x2|jj}|s!tn|dkrdSqWdS(Ns *** EOOH *** (RRWR(RRa((s/usr/lib64/python2.7/mailbox.pyRs   cCs_xX|jj}|jj}|s+dS|dksC|dkr|jj|dSqWdS(Ns s(RRRWRO(RRRa((s/usr/lib64/python2.7/mailbox.pyRs(RcRdRR(((s/usr/lib64/python2.7/mailbox.pyRs tErrorcBseZdZRS(s"Raised for module-specific errors.(RcRdRe(((s/usr/lib64/python2.7/mailbox.pyRsRncBseZdZRS(s:The specified mailbox does not exist and won't be created.(RcRdRe(((s/usr/lib64/python2.7/mailbox.pyRnsRcBseZdZRS(s>The specified mailbox is not empty and deletion was requested.(RcRdRe(((s/usr/lib64/python2.7/mailbox.pyRsRcBseZdZRS(s)Another process caused an action to fail.(RcRdRe(((s/usr/lib64/python2.7/mailbox.pyRsRcBseZdZRS(s)A file appears to have an invalid format.(RcRdRe(((s/usr/lib64/python2.7/mailbox.pyRs(<RetsysRRR{RRRMRJt email.messagetemail.generatorRKtplatformt ImportErrorRRVtwarningstcatch_warningst py3kwarningtfilterwarningstDeprecationWarningRt__all__RRRRRRRRRRR RR R R R RRR>RRRRRRxRRRRRRt ExceptionRRnRRR(((s/usr/lib64/python2.7/mailbox.pyts~                     C84-8 koF]>' -     B"