Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/
Upload File :
Current File : //usr/lib/python2.7/mailbox.pyc


|_c@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZy(ejdkre
nddlZWne
k
reZnXddlZej0ejrejddenddlZWdQXdddd	d
ddd
dddddddddgZdfdYZdefdYZdefdYZdefdYZdefdYZdefdYZd	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 removedtMailboxtMaildirtmboxtMHtBabyltMMDFtMessagetMaildirMessagetmboxMessaget	MHMessagetBabylMessagetMMDFMessagetUnixMailboxtPortableUnixMailboxtMmdfMailboxt	MHMailboxtBabylMailboxcBs.eZdZdedZdZdZdZdZ	dZ
ddZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZddZdZddZdZdZdZ dZ!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/lib/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/lib/python2.7/mailbox.pytadd2scCstddS(s=Remove the keyed message; raise KeyError if it doesn't exist.s&Method must be implemented by subclassN(R(Rtkey((s/usr/lib/python2.7/mailbox.pytremove6scCs|j|dS(N(R!(RR ((s/usr/lib/python2.7/mailbox.pyt__delitem__:scCs)y|j|Wntk
r$nXdS(s'If the keyed message exists, remove it.N(R!tKeyError(RR ((s/usr/lib/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/lib/python2.7/mailbox.pyt__setitem__DscCs*y|j|SWntk
r%|SXdS(s9Return the keyed message, or default if it doesn't exist.N(t__getitem__R#(RR tdefault((s/usr/lib/python2.7/mailbox.pytgetHs
cCs0|js|j|S|j|j|SdS(s=Return the keyed message; raise KeyError if it doesn't exist.N(Rtget_messagetget_file(RR ((s/usr/lib/python2.7/mailbox.pyR&Os	
cCstddS(s4Return a Message representation or raise a KeyError.s&Method must be implemented by subclassN(R(RR ((s/usr/lib/python2.7/mailbox.pyR)VscCstddS(s3Return a string representation or raise a KeyError.s&Method must be implemented by subclassN(R(RR ((s/usr/lib/python2.7/mailbox.pyt
get_stringZscCstddS(s6Return a file-like representation or raise a KeyError.s&Method must be implemented by subclassN(R(RR ((s/usr/lib/python2.7/mailbox.pyR*^scCstddS(sReturn an iterator over keys.s&Method must be implemented by subclassN(R(R((s/usr/lib/python2.7/mailbox.pytiterkeysbscCst|jS(sReturn a list of keys.(tlistR,(R((s/usr/lib/python2.7/mailbox.pytkeysfsccsEx>|jD]0}y||}Wntk
r7q
nX|Vq
WdS(s%Return an iterator over all messages.N(R,R#(RR tvalue((s/usr/lib/python2.7/mailbox.pyt
itervaluesjs
cCs
|jS(N(R0(R((s/usr/lib/python2.7/mailbox.pyt__iter__sscCst|jS(s,Return a list of messages. Memory intensive.(R-R0(R((s/usr/lib/python2.7/mailbox.pytvaluesvsccsKxD|jD]6}y||}Wntk
r7q
nX||fVq
WdS(s.Return an iterator over (key, message) tuples.N(R,R#(RR R/((s/usr/lib/python2.7/mailbox.pyt	iteritemszs
cCst|jS(s9Return a list of (key, message) tuples. Memory intensive.(R-R3(R((s/usr/lib/python2.7/mailbox.pytitemsscCstddS(s9Return True if the keyed message exists, False otherwise.s&Method must be implemented by subclassN(R(RR ((s/usr/lib/python2.7/mailbox.pythas_keyscCs
|j|S(N(R5(RR ((s/usr/lib/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/lib/python2.7/mailbox.pyt__len__scCs(x!|jD]}|j|q
WdS(sDelete all messages.N(R,R$(RR ((s/usr/lib/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/lib/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/lib/python2.7/mailbox.pytpopitemscCst|dr|j}n$t|dr<|j}n|}t}x<|D]4\}}y|||<WqOtk
rt}qOXqOW|rtdndS(s4Change the messages that correspond to certain keys.R3R4sNo message with key(s)N(thasattrR3R4tFalseR#tTrue(Rtargtsourcetbad_keyR R((s/usr/lib/python2.7/mailbox.pytupdates
cCstddS(s&Write any pending changes to the disk.s&Method must be implemented by subclassN(R(R((s/usr/lib/python2.7/mailbox.pytflushscCstddS(sLock the mailbox.s&Method must be implemented by subclassN(R(R((s/usr/lib/python2.7/mailbox.pytlockscCstddS(s#Unlock the mailbox if it is locked.s&Method must be implemented by subclassN(R(R((s/usr/lib/python2.7/mailbox.pytunlockscCstddS(sFlush and close the mailbox.s&Method must be implemented by subclassN(R(R((s/usr/lib/python2.7/mailbox.pytclosescCsdt|tjjrxtj}tjj||d}|j||jd|j	|j
jdtj
nt|tr|r|jdd}n|jdtj
}|j	|nt|drJxtrF|j}|dkrPn|r!|jdr!d|d	}n|jdtj
}|j	|qWntd
t|dS(s%Dump message contents to target file.is
s
From s
>From treadtsFrom s>From isInvalid message type: %sN(t
isinstancetemailRRtStringIOt	generatort	GeneratortflattentseektwriteRGtreplaceRtlineseptstrR<R>treadlinet
startswitht	TypeErrorttype(RRttargettmangle_from_tbuffertgentline((s/usr/lib/python2.7/mailbox.pyt
_dump_messages*

%	N($t__name__t
__module__t__doc__tNoneR>RRR!R"R$R%R(R&R)R+R*R,R.R0R1R2R3R4R5R6R7R8R:R;RBRCRDRERFR=R](((s/usr/lib/python2.7/mailbox.pyR*s>																												cBseZdZdZejedZdZdZ	dZ
dZdZdZ
d	Zd
ZdZd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/lib/python2.7/mailbox.pyRs		cCs|j}y|j||Wn.tk
rP|jtj|jnXt|t|t	r|j
}|j|j}||jkrd}qnd}d}tj
j|jj|jd}tj
j|j|||}yLttdr,tj|j|tj|jntj|j|WnKtk
r}tj|j|jtjkrtd|qnXt|t	rtj|tj
j||jfn|S(s$Add message and return assigned key.RHRditlinks$Name clash with existing message: %s(t_create_tmpR]t
BaseExceptionRFRR!tnamet_sync_closeRIR	t
get_subdirtcolontget_infoRtbasenametsplitRfRR<RptrenametOSErrorterrnotEEXISTtExternalClashErrortutimetgetatimetget_date(RRttmp_filetsubdirtsuffixtuniqtdestte((s/usr/lib/python2.7/mailbox.pyRs>


%
+cCs,tjtjj|j|j|dS(s=Remove the keyed message; raise KeyError if it doesn't exist.N(RR!RRfRt_lookup(RR ((s/usr/lib/python2.7/mailbox.pyR!#scCsSy|j|Wn;tk
r$n+tk
rN}|jtjkrOqOnXdS(s'If the keyed message exists, remove it.N(R!R#R{R|tENOENT(RR R((s/usr/lib/python2.7/mailbox.pyR$'s
c
Cs|j|}|j|}|j|}t|trE|}n|}tjj|}|j|kr|j|j|jd}nd}|j	|tjj
|j|||}	tjtjj
|j||	t|trtj
|	tjj|	|jfndS(s>Replace the keyed message; raise KeyError if it doesn't exist.iRHN(RRRIR	RRRoRvRyR$RfRRzRRR(
RR Rtold_subpathttemp_keyttemp_subpathtdominant_subpathRRtnew_path((s/usr/lib/python2.7/mailbox.pyR%2s 	 
"cCs|j|}ttjj|j|d}z+|jrN|j|}nt|}Wd|jXtjj	|\}}|j
||j|kr|j|j	|jdn|j
tjjtjj|j||S(s4Return a Message representation or raise a KeyError.trNi(RtopenRRRfRRR	RFRyt
set_subdirRvtset_infotset_datetgetmtime(RR tsubpathtftmsgRRs((s/usr/lib/python2.7/mailbox.pyR)Is!	
 +cCsJttjj|j|j|d}z|jSWd|jXdS(s3Return a string representation or raise a KeyError.RN(RRRRfRRRGRF(RR R((s/usr/lib/python2.7/mailbox.pyR+[s*cCs4ttjj|j|j|d}t|S(s6Return a file-like representation or raise a KeyError.trb(RRRRfRRt
_ProxyFile(RR R((s/usr/lib/python2.7/mailbox.pyR*cs*ccsO|jx>|jD]3}y|j|Wntk
rAqnX|VqWdS(sReturn an iterator over keys.N(t_refreshRkRR#(RR ((s/usr/lib/python2.7/mailbox.pyR,hs

cCs|j||jkS(s9Return True if the keyed message exists, False otherwise.(RRk(RR ((s/usr/lib/python2.7/mailbox.pyR5rs
cCs|jt|jS(s*Return a count of messages in the mailbox.(RtlenRk(R((s/usr/lib/python2.7/mailbox.pyR7ws
cCsdS(s"Write any pending changes to disk.N((R((s/usr/lib/python2.7/mailbox.pyRC|scCsdS(sLock the mailbox.N((R((s/usr/lib/python2.7/mailbox.pyRDscCsdS(s#Unlock the mailbox if it is locked.N((R((s/usr/lib/python2.7/mailbox.pyREscCsdS(sFlush and close the mailbox.N((R((s/usr/lib/python2.7/mailbox.pyRFscCsg}xttj|jD]`}t|dkr|ddkrtjjtjj|j|r|j|dqqW|S(sReturn a list of folder names.iit.(RtlistdirRRRtisdirRftappend(RR9tentry((s/usr/lib/python2.7/mailbox.pytlist_folderss"$cCs/ttjj|jd|d|jdtS(s/Return a Maildir instance for the named folder.RRR(RRRRfRRR=(Rtfolder((s/usr/lib/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(RRRfRRRRhRFRtO_CREATtO_WRONLY(RRRR9tmaildirfolder_path((s/usr/lib/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]"}tjtjj||qgWq$Wtj|d
S(s-Delete the named folder, which must be empty.RRdReiisFolder contains message(s): %sRcs%Folder contains subdirectory '%s': %sttopdownN(RRRfRRRt
NotEmptyErrorRtwalkR=R!trmdir(RRRRtroottdirstfiles((s/usr/lib/python2.7/mailbox.pyt
remove_folders #"$!%
 
$cCstj}xptjtjj|jdD]M}tjj|jd|}|tjj|dkr.tj|q.q.WdS(sDelete old files in "tmp".Rci@N(ttimeRRRRfRRR!(RtnowRR((s/usr/lib/python2.7/mailbox.pytcleans
(icCsItj}tj}d|kr9|jdd}nd|krZ|jdd}ndt|t|ddtjtj|f}tj	j
|jd|}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\057Rbs\072s%s.M%sP%sQ%s.%sig.ARcs&Name clash prevented file creation: %sN(RtsockettgethostnameRQtintRtgetpidRt_countRRfRtstatR{R|Rt_create_carefullyR}R~(RRthostnameRRR((s/usr/lib/python2.7/mailbox.pyRqs,&
cCs?tj|jd|jkrt}xS|jD]H}tjj|j|}||j|krkt	}n||j|<q0W|sdSni|_
x|jD]}|j|}xvtj|D]e}tjj||}tjj
|rqn|j|jd}tjj|||j
|<qWqWtj|_dS(s!Update table of contents mapping.iNi(RRmRnR=RlRRRRgR>RkRRfRRyRv(RtrefreshRtmtimeRRtpR((s/usr/lib/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(RRRhRfRRkR#R(RR ((s/usr/lib/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
StopIterationRaR#(R((s/usr/lib/python2.7/mailbox.pyRs	

( R^R_R`Rvtrfc822RR>RRR!R$R%R)R+R*R,R5R7RCRDRERFRRRRRRRqRRR(((s/usr/lib/python2.7/mailbox.pyRs6	%							
										
				$	t_singlefileMailboxcBseZdZdedZdZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZddZdZRS(sA single-file mailbox.cCstj||||yt|jd}Wntk
r}|jtjkr}|rkt|jd}qt|jq|jtjtj	fkrt|jd}qnX||_
d|_d|_
t|_t|_d|_dS(s!Initialize a single-file mailbox.srb+swb+RiN(RRRRtIOErrorR|RRjtEACCEStEROFSt_fileRaRkt	_next_keyR=t_pendingt_lockedt_file_length(RRRRRR((s/usr/lib/python2.7/mailbox.pyR"s"					cCsF|j|j||j|j<|jd7_t|_|jdS(s$Add message and return assigned key.i(Rt_append_messageRkRR>R(RR((s/usr/lib/python2.7/mailbox.pyR8s

	cCs$|j||j|=t|_dS(s=Remove the keyed message; raise KeyError if it doesn't exist.N(RRkR>R(RR ((s/usr/lib/python2.7/mailbox.pyR!@s

cCs0|j||j||j|<t|_dS(s>Replace the keyed message; raise KeyError if it doesn't exist.N(RRRkR>R(RR R((s/usr/lib/python2.7/mailbox.pyR%Fs
ccs-|jx|jjD]}|VqWdS(sReturn an iterator over keys.N(RRkR.(RR ((s/usr/lib/python2.7/mailbox.pyR,Ls
cCs|j||jkS(s9Return True if the keyed message exists, False otherwise.(RRk(RR ((s/usr/lib/python2.7/mailbox.pyR5Rs
cCs|jt|jS(s*Return a count of messages in the mailbox.(RRRk(R((s/usr/lib/python2.7/mailbox.pyR7Ws
cCs&|js"t|jt|_ndS(sLock the mailbox.N(Rt
_lock_fileRR>(R((s/usr/lib/python2.7/mailbox.pyRD\s	
cCs&|jr"t|jt|_ndS(s#Unlock the mailbox if it is locked.N(Rt_unlock_fileRR=(R((s/usr/lib/python2.7/mailbox.pyREbs	
c
Cs}|js
dS|jdk	s"t|jjdd|jj}||jkrotd|j|fnt	|j
}yi}|j|xt|jj
D]}|j|\}}|jj||j||j}xOtr=|jjtd||jj}|dkr-Pn|j|qW||jf||<|j|qWWn$|jtj|jnXt||jjytj|j|j
Wnrtk
r2}	|	jtjkstjdkr,|	jtjkr,tj|j
tj|j|j
q3nXt|j
d|_||_t|_|j ryt!|jd	tndS(
s"Write any pending changes to disk.Niis4Size of mailbox file changed (expected %i, found %i)iRHtos2srb+tdotlock("RRkRatAssertionErrorRROttellRR~t_create_temporaryRt_pre_mailbox_hooktsortedR.t_pre_message_hookR>RGtminRPt_post_message_hookRFRR!RsRtRzR{R|R}RRR=RR(
Rtcur_lentnew_filetnew_tocR tstarttstopt	new_startRZR((s/usr/lib/python2.7/mailbox.pyRChsX	

	


!			cCsdS(s,Called before writing the mailbox to file f.N((RR((s/usr/lib/python2.7/mailbox.pyRscCsdS(s-Called before writing each message to file f.N((RR((s/usr/lib/python2.7/mailbox.pyRscCsdS(s,Called after writing each message to file f.N((RR((s/usr/lib/python2.7/mailbox.pyRscCs1|j|jr |jn|jjdS(sFlush and close the mailbox.N(RCRRERRF(R((s/usr/lib/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(RkRat
_generate_tocR#(RR ((s/usr/lib/python2.7/mailbox.pyRs

cCs|jjdd|jj}y3|j|j|j|}|j|jWn$tk
r{|jj|nX|jj|jj|_	|S(s;Append message to mailbox and return (start, stop) offsets.ii(
RRORRt_install_messageRRrttruncateRCR(RRtbeforetoffsets((s/usr/lib/python2.7/mailbox.pyRs

N(R^R_R`RaR>RRR!R%R,R5R7RDRERCRRRRFRR(((s/usr/lib/python2.7/mailbox.pyRs"									:				
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(RRRORTRQRRRRGRt_message_factorytset_from(RR RRt	from_linetstringR((s/usr/lib/python2.7/mailbox.pyR)scCsm|j|\}}|jj||s;|jjn|jj||jj}|jtjdS(s3Return a string representation or raise a KeyError.s
(	RRRORTRGRRQRRR(RR tfrom_RRR((s/usr/lib/python2.7/mailbox.pyR+scCsW|j|\}}|jj||s;|jjnt|j|jj|S(s6Return a file-like representation or raise a KeyError.(RRRORTt_PartialFileR(RR RRR((s/usr/lib/python2.7/mailbox.pyR*s
cCs/d}t|tri|jdri|jd}|dkrZ|| }||d}q|}d}nFt|trd|j}n$t|tjj	r|j
}n|dkrdtjtj
}n|jj}|jj|tj|j||j|j|jj}||fS(s1Format a message and blindly write to self._file.sFrom s
iiRHsFrom MAILER-DAEMON %sN(RaRIRSRUtfindt_mboxMMDFMessagetget_fromRJRRtget_unixfromRtasctimetgmtimeRRRPRRRR]t
_mangle_from_(RRRtnewlineRR((s/usr/lib/python2.7/mailbox.pyRs&
	(
R^R_R`R>RR)R=R+R*R(((s/usr/lib/python2.7/mailbox.pyRs	
	cBs5eZdZeZdedZdZdZRS(sA classic mbox mailbox.cCs#t|_tj||||dS(sInitialize an mbox mailbox.N(R
RRR(RRRR((s/usr/lib/python2.7/mailbox.pyR
s	cCs)|jdkr%|jtjndS(s-Called before writing each message to file f.iN(RRPRRR(RR((s/usr/lib/python2.7/mailbox.pyRscCsgg}}|jjdxtr|jj}|jj}|jdrt|t|kr|j|ttj	n|j|q |dkr |j|Pq q Wt
tt|||_
t|j
|_|jj|_dS(s0Generate key-to-(start, stop) table of contents.isFrom RHN(RROR>RRTRURRRRRtdictt	enumeratetzipRkRR(Rtstartststopstline_posR\((s/usr/lib/python2.7/mailbox.pyRs
	
N(	R^R_R`R>RRaRRR(((s/usr/lib/python2.7/mailbox.pyRs
	cBs8eZdZdedZdZdZdZRS(sAn MMDF mailbox.cCs#t|_tj||||dS(sInitialize an MMDF mailbox.N(R
RRR(RRRR((s/usr/lib/python2.7/mailbox.pyR-s	cCs|jdtjdS(s-Called before writing each message to file f.sN(RPRRR(RR((s/usr/lib/python2.7/mailbox.pyR2scCs|jtjdtjdS(s,Called after writing each message to file f.sN(RPRRR(RR((s/usr/lib/python2.7/mailbox.pyR6scCsbgg}}|jjdd}xtr|}|jj}|jj}|jdtjr|j|xtr|}|jj}|jj}|dtjkr|j|t	tjPqv|dkrv|j|PqvqvWq&|dkr&Pq&q&Wt
tt|||_
t	|j
|_|jjdd|jj|_dS(s0Generate key-to-(start, stop) table of contents.isRHiN(RROR>RTRRURRRRRRRRRkRR(RRRtnext_posRR\((s/usr/lib/python2.7/mailbox.pyR:s2
	
	
N(	R^R_R`RaR>RRRR(((s/usr/lib/python2.7/mailbox.pyR*s
		cBseZdZdedZdZdZdZdZ	dZ
dZdZd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZdZdZRS(sAn MH mailbox.cCstj||||tjj|js|rtj|jdtjtjtjj	|jdtj
tjBtjBdqt
|jnt|_dS(sInitialize an MH instance.is
.mh_sequencesiN(RRRRRhRRiRFRRfRtO_EXCLRRjR=R(RRRR((s/usr/lib/python2.7/mailbox.pyRZs!!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.RtmaxRRRfRRSRR=RRR]RrRRtR>R!RIRt_dump_sequences(RRR.tnew_keyRRtclosed((s/usr/lib/python2.7/mailbox.pyRfs6		

	


	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(RRRfRRSRRR|RR#RFR!(RR RRR((s/usr/lib/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(RRRfRRSRRR|RR#RRRFRtO_TRUNCR]RIRRRRt(RR RRRR((s/usr/lib/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(RRRRRfRRSRR|RR#RRRRFt
get_sequencesR3tadd_sequence(RR RRRRstkey_list((s/usr/lib/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(RRRRRfRRSRR|RR#RRGRRF(RR RR((s/usr/lib/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(RRRRfRRSRR|RR#R(RR RR((s/usr/lib/python2.7/mailbox.pyR*s+cCs&ttdtj|jDS(sReturn an iterator over keys.css'|]}|jrt|VqdS(N(tisdigitR(t.0R((s/usr/lib/python2.7/mailbox.pys	<genexpr>s(titerRRRR(R((s/usr/lib/python2.7/mailbox.pyR,scCs(tjjtjj|jt|S(s9Return True if the keyed message exists, False otherwise.(RRRhRfRRS(RR ((s/usr/lib/python2.7/mailbox.pyR5scCstt|jS(s*Return a count of messages in the mailbox.(RR-R,(R((s/usr/lib/python2.7/mailbox.pyR7scCsJ|jsFttjj|jdd|_t|jt|_ndS(sLock the mailbox.s
.mh_sequencessrb+N(	RRRRRfRRRR>(R((s/usr/lib/python2.7/mailbox.pyRDs	$
cCs9|jr5t|jt|j|`t|_ndS(s#Unlock the mailbox if it is locked.N(RRRRtR=(R((s/usr/lib/python2.7/mailbox.pyREs
	

cCsdS(s&Write any pending changes to the disk.N((R((s/usr/lib/python2.7/mailbox.pyRCscCs|jr|jndS(sFlush and close the mailbox.N(RRE(R((s/usr/lib/python2.7/mailbox.pyRFs	cCs[g}xNtj|jD]:}tjjtjj|j|r|j|qqW|S(sReturn a list of folder names.(RRRRRRfR(RR9R((s/usr/lib/python2.7/mailbox.pyRs
$cCs+ttjj|j|d|jdtS(s+Return an MH instance for the named folder.RR(RRRRfRRR=(RR((s/usr/lib/python2.7/mailbox.pyRscCs%ttjj|j|d|jS(s:Create a folder and return an MH instance representing it.R(RRRRfRR(RR((s/usr/lib/python2.7/mailbox.pyRscCstjj|j|}tj|}|dgkrUtjtjj|dn"|gkrdntd|jtj|dS(s-Delete the named folder, which must be empty.s
.mh_sequencessFolder not empty: %sN(RRRfRRR!RR(RRRtentries((s/usr/lib/python2.7/mailbox.pyR"scCsmi}ttjj|jdd}z4t|j}x|D]}y|jd\}}t}xo|jD]a}|jr|j	t
|qwd|jdD\}	}
|jt|	|
dqwWgt
|D]}||kr|^q||<t||dkr+||=nWqCtk
rUtd|jqCXqCWWd	|jX|S(
s=Return a name-to-key-list dictionary to define each sequence.s
.mh_sequencesRRbcss|]}t|VqdS(N(R(Rtx((s/usr/lib/python2.7/mailbox.pys	<genexpr><st-iis"Invalid sequence specification: %sN(RRRRfRtsetR.RyRRRRBtrangeRRt
ValueErrortFormatErrortrstripRF(RtresultsRtall_keysR\RstcontentsR.tspecRRR ((s/usr/lib/python2.7/mailbox.pyR.s,!
	
cCsettjj|jdd}z2tjtj|jtjtjBx|j	D]\}}t
|dkr{qWn|jd|d
}t
}xtt|D]r}|d|kr|st}|jdqn7|rt
}|jd||fn|jd||}qW|rA|jt|d	qW|jd	qWWWd
t|Xd
S(s:Set sequences using the given name-to-key-list dictionary.s
.mh_sequencessr+is%s:iR	s%s %ss %ss
N(RRRRfRRFRsRRR3RRPRaR=RR
R>RSRt(Rt	sequencesRRsR.tprevt
completingR ((s/usr/lib/python2.7/mailbox.pyt
set_sequencesIs.!&
c	Cs|j}d}g}x|jD]}|d|kr|j||dfttdrtjtjj|jt	|tjj|jt	|dtj
tjj|jt	|qtjtjj|jt	|tjj|jt	|dn|d7}q%W|d|_t
|dkrEdSxS|jD]E\}}x6|D].\}}||kre|||j|<qeqeWqRW|j|dS(s?Re-name messages to eliminate numbering gaps. Invalidates keys.iiRpN(RR,RR<RRpRRfRRStunlinkRzRRR4tindexR(	RRRtchangesR RsRtoldRd((s/usr/lib/python2.7/mailbox.pytpackfs*!#(!&
cCs|j}|j}xU|jD]G\}}||krM|j|q%||kr%||j|=q%q%Wx*|D]"}||krw|g||<qwqwW|j|dS(s;Inspect a new MHMessage and update sequences appropriately.N(RR3RRR(RRR tpending_sequencest
all_sequencesRsRtsequence((s/usr/lib/python2.7/mailbox.pyRs
N(R^R_R`RaR>RRR!R%R)R+R*R,R5R7RDRERCRFRRRRRRRR(((s/usr/lib/python2.7/mailbox.pyRWs.	"																			cBseZdZedZdedZd	Zd
Z	dZ
dZd
ZdZ
dZdZdZdZdZdZRS(sAn Rmail-style Babyl mailbox.tunseentdeletedtfiledtansweredt	forwardedteditedtresentcCs#tj||||i|_dS(sInitialize a Babyl mailbox.N(RRt_labels(RRRR((s/usr/lib/python2.7/mailbox.pyRscCs;tj||}t|tr7|j|j|<n|S(s$Add message and return assigned key.(RRRIRt
get_labelsR&(RRR ((s/usr/lib/python2.7/mailbox.pyRscCs0tj||||jkr,|j|=ndS(s=Remove the keyed message; raise KeyError if it doesn't exist.N(RR!R&(RR ((s/usr/lib/python2.7/mailbox.pyR!scCs<tj|||t|tr8|j|j|<ndS(s>Replace the keyed message; raise KeyError if it doesn't exist.N(RR%RIRR'R&(RR R((s/usr/lib/python2.7/mailbox.pyR%sc	Cs}|j|\}}|jj||jjtj}xXtr|jj}|dtjksu|dkryPn|j|j	tjdqAWtj}xTtr|jj}|tjks|dkrPn|j|j	tjdqW|jj
||jjj	tjd}t|j
|}|j|j
||jkry|j|j|n|S(s4Return a Message representation or raise a KeyError.s*** EOOH ***RHs
(RRRORTRKR>RRRRPRQRGRRtgetvaluetset_visibleR&t
set_labels(	RR RRtoriginal_headersR\tvisible_headerstbodyR((s/usr/lib/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
(
RRRORTRKR>RRRRPRQR(RGR(RR RRR+R\((s/usr/lib/python2.7/mailbox.pyR+s 
	 		%cCs%tj|j|jdtjS(s6Return a file-like representation or raise a KeyError.s
(RKR+RQRRR(RR ((s/usr/lib/python2.7/mailbox.pyR*scCsT|jt}x$|jjD]}|j|q#W|j|jt|S(s4Return a list of user-defined labels in the mailbox.(RR
R&R2RBtdifference_updatet_special_labelsR-(Rtlabelst
label_list((s/usr/lib/python2.7/mailbox.pyR's
	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,Wttt
|||_tt||_t|j|_|jjdd|jj|_dS(	s0Generate key-to-(start, stop) table of contents.isit,RHsiN(RROR>RTRRRRRRRytstripRRRRkR&RR(	RRRRtlabel_listsRR\tlabelR0((s/usr/lib/python2.7/mailbox.pyRs6
	
 $ cCs9|jdtjtjdj|jtjfdS(s,Called before writing the mailbox to file f.s(BABYL OPTIONS:%sVersion: 5%sLabels:%s%sR2N(RPRRRRfR'(RR((s/usr/lib/python2.7/mailbox.pyRs	cCs|jdtjdS(s-Called before writing each message to file f.sN(RPRRR(RR((s/usr/lib/python2.7/mailbox.pyR
scCs|jtjddS(s,Called after writing each message to file f.sN(RPRRR(RR((s/usr/lib/python2.7/mailbox.pyRscCs,|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
jj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+|jjd
tj	|rt}|j|
qPq+q+Wxatr|jd}|d	krPn|jj|jdtj	qWntdt||jj}||fS(s0Write message contents and return (start, stop).t1s, s,,t R2s1,,is
RHs*** EOOH ***is

iiRTsInvalid message type: %s(RRRIRR'R/RRPRRRRJRRRKRLRMR=RNROR>RTRQtget_visibleRGRSRR<RVRW(RRRtspecial_labelsR0R5torig_buffertorig_generatorR\t
vis_buffert
vis_generatorRZt
body_starttoriginal_post
first_passR((s/usr/lib/python2.7/mailbox.pyRs



		
		&

"		&(RR R!R"R#R$R%N(R^R_R`t	frozensetR/RaR>RRR!R%R)R+R*R'RRRRR(((s/usr/lib/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_toRStmessage_from_stringR<tmessage_from_fileRaRRVRW(RR((s/usr/lib/python2.7/mailbox.pyRnscCs)x"d
D]}|j||j|<qWd	S(s0Assume the non-format-specific state of message.t_headerst	_unixfromt_payloadt_charsettpreambletepiloguetdefectst
_default_typeN(RHRIRJRKRLRMRNRO(t__dict__(RRRs((s/usr/lib/python2.7/mailbox.pyRB}s
cCs#t|trdStddS(s:Copy format-specific state to message insofar as possible.Ns Cannot convert to specified type(RIRRV(RR((s/usr/lib/python2.7/mailbox.pyREsN(R^R_R`RaRRBRE(((s/usr/lib/python2.7/mailbox.pyRks	cBs}eZdZd
dZdZdZdZdZdZ	dZ
dZd	Zd
Z
dZdZRS(s)Message with Maildir-specific properties.cCs5d|_d|_tj|_tj||dS(s%Initialize a MaildirMessage instance.RdRHN(t_subdirt_infoRt_dateRR(RR((s/usr/lib/python2.7/mailbox.pyRs		cCs|jS(sReturn 'new' or 'cur'.(RQ(R((s/usr/lib/python2.7/mailbox.pyRuscCs8|dks|dkr$||_ntd|dS(sSet subdir to 'new' or 'cur'.RdRes!subdir must be 'new' or 'cur': %sN(RQR(RR((s/usr/lib/python2.7/mailbox.pyRscCs%|jjdr|jdSdSdS(s*Return as a string the flags that are set.s2,iRHN(RRRU(R((s/usr/lib/python2.7/mailbox.pyt	get_flagsscCs ddjt||_dS(s)Set the given flags and unset all others.s2,RHN(RfRRR(Rtflags((s/usr/lib/python2.7/mailbox.pyt	set_flagsscCs0|jdjt|jt|BdS(s.Set the given flag(s) without changing others.RHN(RVRfR
RT(Rtflag((s/usr/lib/python2.7/mailbox.pytadd_flagscCsE|jdkrA|jdjt|jt|ndS(s7Unset the given string flag(s) without changing others.RHN(RTRVRfR
(RRW((s/usr/lib/python2.7/mailbox.pytremove_flagscCs|jS(s<Return delivery date of message, in seconds since the epoch.(RS(R((s/usr/lib/python2.7/mailbox.pyRscCs;yt||_Wn!tk
r6td|nXdS(s9Set delivery date of message, in seconds since the epoch.scan't convert to float: %sN(tfloatRSRRV(Rtdate((s/usr/lib/python2.7/mailbox.pyRs
cCs|jS(s%Get the message's "info" as a string.(RR(R((s/usr/lib/python2.7/mailbox.pyRwscCs5t|tr||_ntdt|dS(s Set the message's "info" string.sinfo must be a string: %sN(RIRSRRRVRW(Rtinfo((s/usr/lib/python2.7/mailbox.pyRscCsXt|trK|j|j|j|j|j|jn	t|tr t	|j}d|kr|j
dn|jdkr|j
dnd|kr|j
dnd|kr|j
dnd|kr|j
dn|jd	tj
|jn4t|trt	|j}d|kr]|jd
nd|kry|jdnd|krT|jdqTnt|tr,t	|j}d|kr|jd
nd|kr|jd
nd|kr
|jdnd|krT|jdqTn(t|tr>ntdt|dS(s;Copy Maildir-specific state to message insofar as possible.tStRRetOtTtDtFtAs
MAILER-DAEMONRtrepliedtflaggedR R"tPR#s$Cannot convert to specified type: %sN(RIR	RVRTRRuRRRR
RXRRRRRRt	add_labelRRVRW(RRRU((s/usr/lib/python2.7/mailbox.pyREsN"N(R^R_R`RaRRuRRTRVRXRYRRRwRRE(((s/usr/lib/python2.7/mailbox.pyR	s										RcBs\eZdZd	dZdZd	dZdZdZdZ	dZ
dZRS(
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>RIRJRRRRaRUR(RRtunixfrom((s/usr/lib/python2.7/mailbox.pyRscCs|jS(s Return contents of "From " line.(t_from(R((s/usr/lib/python2.7/mailbox.pyRscCsN|dk	rA|tkr'tj}n|dtj|7}n||_dS(s>Set "From " line, formatting and appending time_ if specified.R7N(RaR>RRRRi(RRttime_((s/usr/lib/python2.7/mailbox.pyRs
cCs |jdd|jddS(s*Return as a string the flags that are set.tStatusRHsX-Status(R((R((s/usr/lib/python2.7/mailbox.pyRTscCst|}d
\}}x4dD],}||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.RHR^R_RaRbRcRksX-StatusN(RHRH(R^R_(RaRbRc(R
R!RfRtreplace_headerR#t
add_header(RRUtstatus_flagst
xstatus_flagsRW((s/usr/lib/python2.7/mailbox.pyRVs&





cCs0|jdjt|jt|BdS(s.Set the given flag(s) without changing others.RHN(RVRfR
RT(RRW((s/usr/lib/python2.7/mailbox.pyRX(scCsKd|ksd|krG|jdjt|jt|ndS(s7Unset the given string flag(s) without changing others.RksX-StatusRHN(RVRfR
RT(RRW((s/usr/lib/python2.7/mailbox.pyRY,scCst|trt|j}d|kr=|jdnd|krY|jdnd|kru|jdnd|kr|jdnd|kr|jdn|d	=|d
=dj|jjd}y&|j	t
jt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.R_ReRbRcR^R]RaR`tstatussx-statusR7is%a %b %d %H:%M:%S %YRRdReR R"s$Cannot convert to specified type: %sN(RIR	R
RTRRXRfRRyRtcalendarttimegmRtstrptimeRt
OverflowErrorRRVRRRRRgRRVRW(RRRUt
maybe_date((s/usr/lib/python2.7/mailbox.pyRE1s^

N(R^R_R`RaRRRRTRVRXRYRE(((s/usr/lib/python2.7/mailbox.pyRs						cBseZdZRS(s&Message with mbox-specific properties.(R^R_R`(((s/usr/lib/python2.7/mailbox.pyR
escBsGeZdZddZdZdZdZdZdZ	RS(s$Message with MH-specific properties.cCsg|_tj||dS(s!Initialize an MHMessage instance.N(t
_sequencesRR(RR((s/usr/lib/python2.7/mailbox.pyRls	cCs|jS(s4Return a list of sequences that include the message.(Rv(R((s/usr/lib/python2.7/mailbox.pyRqscCst||_dS(s3Set the list of sequences that include the message.N(R-Rv(RR((s/usr/lib/python2.7/mailbox.pyRuscCsNt|tr4||jkrJ|jj|qJntdt|dS(s8Add sequence to list of sequences including the message.ssequence must be a string: %sN(RIRSRvRRVRW(RR((s/usr/lib/python2.7/mailbox.pyRyscCs,y|jj|Wntk
r'nXdS(sARemove sequence from the list of sequences including the message.N(RvR!R(RR((s/usr/lib/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
dqn(t|trntdt
|d
S(s6Copy MH-specific state to message insofar as possible.RReR]ReRbRdR^tROR_RcR"s$Cannot convert to specified type: %sN(RIR	R
RRRXRRRRRgRRVRW(RRRR((s/usr/lib/python2.7/mailbox.pyREs@


N(
R^R_R`RaRRRRRwRE(((s/usr/lib/python2.7/mailbox.pyRis				cBsbeZdZd
dZdZdZdZdZdZ	dZ
dZd	ZRS(s'Message with Babyl-specific properties.cCs)g|_t|_tj||dS(s$Initialize an BabylMessage instance.N(R&Rt_visibleR(RR((s/usr/lib/python2.7/mailbox.pyRs	cCs|jS(s'Return a list of labels on the message.(R&(R((s/usr/lib/python2.7/mailbox.pyR'scCst||_dS(s&Set the list of labels on the message.N(R-R&(RR0((s/usr/lib/python2.7/mailbox.pyR*scCsNt|tr4||jkrJ|jj|qJntdt|dS(s+Add label to list of labels on the message.slabel must be a string: %sN(RIRSR&RRVRW(RR5((s/usr/lib/python2.7/mailbox.pyRgscCs,y|jj|Wntk
r'nXdS(s4Remove label from the list of labels on the message.N(R&R!R(RR5((s/usr/lib/python2.7/mailbox.pytremove_labels
cCs
t|jS(s3Return a Message representation of visible headers.(RRy(R((s/usr/lib/python2.7/mailbox.pyR8scCst||_dS(s2Set the Message representation of visible headers.N(RRy(Rtvisible((s/usr/lib/python2.7/mailbox.pyR)scCsxG|jjD]6}||kr<|jj|||q|j|=qWx=dD]5}||krQ||jkrQ|||j|<qQqQWdS(	s9Update and/or sensibly generate a set of visible headers.tDatetFromsReply-TotTotCCtSubjectN(R|R}sReply-ToR~RR(RyR.Rl(Rtheader((s/usr/lib/python2.7/mailbox.pytupdate_visibles
cCst|trt|j}d|kr=|jdn|jd|jdd|ksod|kr|jdnd|kr|jdnd	|kr|jd
qnRt|tr?t|j}d|kr|jdn
|jdd	|kr |jd
nd|kr|jdqnt|trt|j}d|kr||jdnd|kr|jdqnqt|t	r|j
|jxL|jD]}|j|qWn(t|t
rntdt|dS(s9Copy Babyl-specific state to message insofar as possible.RReR]R#R%RfR"R^R R`RxR_RaRcRds$Cannot convert to specified type: %sN(RIR	R
R'RRXRRRRR)R8RgRRVRW(RRR0R5((s/usr/lib/python2.7/mailbox.pyREsF


N(
R^R_R`RaRR'R*RgRzR8R)RRE(((s/usr/lib/python2.7/mailbox.pyRs							cBseZdZRS(s&Message with MMDF-specific properties.(R^R_R`(((s/usr/lib/python2.7/mailbox.pyR
sRcBsneZdZddZddZddZddZdZdZ	ddZ
d	Zd
ZRS(sA read-only wrapper of a file.cCs4||_|dkr'|j|_n	||_dS(sInitialize a _ProxyFile.N(RRaRt_pos(RRtpos((s/usr/lib/python2.7/mailbox.pyRs	cCs|j||jjS(sRead bytes.(t_readRRG(Rtsize((s/usr/lib/python2.7/mailbox.pyRGscCs|j||jjS(sRead a line.(RRRT(RR((s/usr/lib/python2.7/mailbox.pyRTscCsWg}xJ|D]B}|j||dk	r
|t|8}|dkrOPqOq
q
W|S(sRead multiple lines.iN(RRaR(RtsizehintR9R\((s/usr/lib/python2.7/mailbox.pyt	readlines#s

cCst|jdS(sIterate over lines.RH(RRT(R((s/usr/lib/python2.7/mailbox.pyR1.scCs|jS(sReturn the position.(R(R((s/usr/lib/python2.7/mailbox.pyR2sicCsK|dkr"|jj|jn|jj|||jj|_dS(sChange position.iN(RRORR(Rtoffsettwhence((s/usr/lib/python2.7/mailbox.pyRO6scCs>t|dr:t|jdr1|jjn|`ndS(sClose the file.RRFN(R<RRF(R((s/usr/lib/python2.7/mailbox.pyRF=scCsJ|dkrd}n|jj|j||}|jj|_|S(s"Read size bytes using read_method.iN(RaRRORR(RRtread_methodR9((s/usr/lib/python2.7/mailbox.pyRDs	N(
R^R_R`RaRRGRTRR1RRORFR(((s/usr/lib/python2.7/mailbox.pyRs			RcBsDeZdZdddZdZddZdZdZRS(s&A read-only wrapper of part of a file.cCs)tj|||||_||_dS(sInitialize a _PartialFile.N(RRt_startt_stop(RRRR((s/usr/lib/python2.7/mailbox.pyRQs	cCstj||jS(s*Return the position with respect to start.(RRR(R((s/usr/lib/python2.7/mailbox.pyRWsicCsY|dkr!|j|_d}n!|dkrB|j|_d}ntj|||dS(s8Change position, possibly with respect to start or stop.iiiN(RRRRRO(RRR((s/usr/lib/python2.7/mailbox.pyRO[s		cCs`|j|j}|dkr dS|dksD|dksD||krM|}ntj|||S(s;Read size bytes using read_method, honoring start and stop.iRHN(RRRaRR(RRRt	remaining((s/usr/lib/python2.7/mailbox.pyRes$	cCst|dr|`ndS(NR(R<R(R((s/usr/lib/python2.7/mailbox.pyRFnsN(	R^R_R`RaRRRORRF(((s/usr/lib/python2.7/mailbox.pyRNs	
		cCst}ytrytj|tjtjBWqtk
r|}|jtjtjtj	fkrvt
d|jq}qXn|ry!t|jd}|j
Wn5tk
r}|jtjtj	fkrdSnXyfttdr$tj|j|jdt}tj|jn tj|j|jdt}Wqtk
r}|jtjkstjdkr|jtjkrtj|jt
d|jqqXnWnCtrtj|tjn|rtj|jdnnXdS(s(Lock file f using lockf and dot locking.slockf: lock unavailable: %ss.lockNRpRsdot lock unavailable: %s(R=tfcntltlockftLOCK_EXtLOCK_NBRR|tEAGAINRRR~RsRRFR<RRpR>RRzR{R}R!tLOCK_UN(RRtdotlock_doneRtpre_lock((s/usr/lib/python2.7/mailbox.pyRusL!

!cCsPtrtj|tjntjj|jdrLtj|jdndS(s*Unlock file f using lockf and dot locking.s.lockN(RRRRRRhRsR!(R((s/usr/lib/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/lib/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/lib/python2.7/mailbox.pyRs	cCs3|jttdr/tj|jndS(s0Ensure changes to file f are physically on disk.tfsyncN(RCR<RRtfileno(R((s/usr/lib/python2.7/mailbox.pyt_sync_flushs
cCst||jdS(s:Close file f, ensuring all changes are physically on disk.N(RRF(R((s/usr/lib/python2.7/mailbox.pyRts
t_MailboxcBs)eZejdZdZdZRS(cCs||_d|_||_dS(Ni(tfptseekpR(RRR((s/usr/lib/python2.7/mailbox.pyRs		cCst|jdS(N(RRRa(R((s/usr/lib/python2.7/mailbox.pyR1scCsx|jj|jy|jWn$tk
rJ|jj|_dSX|jj}|j|jj|_}||krPqq|jt	|j||S(N(
RRORt
_search_starttEOFErrorRRat_search_endRR(RRR((s/usr/lib/python2.7/mailbox.pyRs

(R^R_RRRR1R(((s/usr/lib/python2.7/mailbox.pyRs	cBs>eZdZdZdZdZdZdZeZ	RS(cCsjxc|jj}|jj}|s0tn|d dkr|j|r|jj|dSqdS(NisFrom (RRRTRt_isrealfromlineRO(RRR\((s/usr/lib/python2.7/mailbox.pyRs	cCsr|jjx^|jj}|jj}|s8dS|d dkr|j|r|jj|dSqdS(NisFrom (RRTRRRO(RRR\((s/usr/lib/python2.7/mailbox.pyRs
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(RR\R((s/usr/lib/python2.7/mailbox.pyt_strict_isrealfromlines	cCstS(N(R>(RR\((s/usr/lib/python2.7/mailbox.pyt_portable_isrealfromlinesN(
R^R_RRRRaRRRR(((s/usr/lib/python2.7/mailbox.pyRs	
	$		cBseZejZRS((R^R_RRR(((s/usr/lib/python2.7/mailbox.pyR#scBseZdZdZRS(cCs<x5|jj}|s!tn|d dkrdSqdS(Nis
(RRTR(RR\((s/usr/lib/python2.7/mailbox.pyR)s	cCsRxK|jj}|jj}|s+dS|dkr|jj|dSqdS(Ns
(RRRTRO(RRR\((s/usr/lib/python2.7/mailbox.pyR1s(R^R_RR(((s/usr/lib/python2.7/mailbox.pyR's	cBs)eZejdZdZdZRS(cCsddl}|jd}||_tj|j}t|j|}tt|}|j	tt
||_|jj||_
dS(Nis
^[1-9][0-9]*$(RRRoRRtfilterRtmaptlongtsortRStboxestreverseR(RRoRRtpatR-((s/usr/lib/python2.7/mailbox.pyR>s	

cCst|jdS(N(RRRa(R((s/usr/lib/python2.7/mailbox.pyR1NscCst|js
dS|jj}ttjj|j|}|j|}y
||_	Wnt
tfk
ronX|S(N(RRaR:RRRRfRoRt	_mh_msgnotAttributeErrorRV(RtfnRR((s/usr/lib/python2.7/mailbox.pyRQs	
(R^R_RRRR1R(((s/usr/lib/python2.7/mailbox.pyR<s	cBseZdZdZRS(cCs8x1|jj}|s!tn|dkrdSqdS(Ns
*** EOOH ***
(RRTR(RR\((s/usr/lib/python2.7/mailbox.pyR`s	cCs^xW|jj}|jj}|s+dS|dksC|dkr|jj|dSqdS(Ns
s(RRRTRO(RRR\((s/usr/lib/python2.7/mailbox.pyRhs(R^R_RR(((s/usr/lib/python2.7/mailbox.pyR^s	tErrorcBseZdZRS(s"Raised for module-specific errors.(R^R_R`(((s/usr/lib/python2.7/mailbox.pyRusRjcBseZdZRS(s:The specified mailbox does not exist and won't be created.(R^R_R`(((s/usr/lib/python2.7/mailbox.pyRjxsRcBseZdZRS(s>The specified mailbox is not empty and deletion was requested.(R^R_R`(((s/usr/lib/python2.7/mailbox.pyR{sR~cBseZdZRS(s)Another process caused an action to fail.(R^R_R`(((s/usr/lib/python2.7/mailbox.pyR~~sR
cBseZdZRS(s)A file appears to have an invalid format.(R^R_R`(((s/usr/lib/python2.7/mailbox.pyR
s(<R`tsysRRRqRR|RCRJt
email.messagetemail.generatorRKtplatformtImportErrorRRatwarningstcatch_warningstpy3kwarningtfilterwarningstDeprecationWarningRt__all__RRRRRRRRRRR	RR
RRR
RRR>RRRRRRtRRRRRRt	ExceptionRRjRR~R
(((s/usr/lib/python2.7/mailbox.pyt<module>s~	


	
	;8"-8 koF]>'-					
B"