ROOTPLOIT
Server: LiteSpeed
System: Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User: niphet (1079)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //lib64/python3.8/__pycache__/mailbox.cpython-38.pyc
U

e5dE3ã@sRdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlZzddl
Z
Wnek
rˆdZ
YnXddddddd	d
ddd
ddddddgZej d¡ZGdd„dƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd	„d	ejjƒZGd d
„d
eƒZGd!d"„d"eƒZGd#d„deƒZGd$d„deƒZGd%d
„d
eƒZ Gd&d„deƒZ!Gd'd(„d(ƒZ"Gd)d*„d*e"ƒZ#d=d,d-„Z$d.d/„Z%d0d1„Z&d2d3„Z'd4d5„Z(d6d7„Z)Gd8d„de*ƒZ+Gd9d„de+ƒZ,Gd:d„de+ƒZ-Gd;d„de+ƒZ.Gd<d„de+ƒZ/dS)>zDRead/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.éNÚMailboxÚMaildirÚmboxÚMHÚBabylÚMMDFÚMessageÚMaildirMessageÚmboxMessageÚ	MHMessageÚBabylMessageÚMMDFMessageÚErrorÚNoSuchMailboxErrorÚ
NotEmptyErrorÚExternalClashErrorÚFormatErrorÚasciic@seZdZdZdCdd„Zdd„Zdd	„Zd
d„Zdd
„Zdd„Z	dDdd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„ZdEd0d1„Zd2d3„ZdFd4d5„Zd6d7„Zd8d9„Zd:d;„Zd<d=„Z d>d?„Z!d@Z"dGdAdB„Z#dS)Hrz*A group of messages in a particular place.NTcCs tj tj |¡¡|_||_dS)zInitialize a Mailbox instance.N)ÚosÚpathÚabspathÚ
expanduserÚ_pathÚ_factory©ÚselfrÚfactoryÚcreate©rú/usr/lib64/python3.8/mailbox.pyÚ__init__$szMailbox.__init__cCstdƒ‚dS)ú$Add message and return assigned key.ú&Method must be implemented by subclassN©ÚNotImplementedError©rÚmessagerrrÚadd)szMailbox.addcCstdƒ‚dS)ú=Remove the keyed message; raise KeyError if it doesn't exist.r"Nr#©rÚkeyrrrÚremove-szMailbox.removecCs| |¡dS©N)r+r)rrrÚ__delitem__1szMailbox.__delitem__cCs(z| |¡Wntk
r"YnXdS©z'If the keyed message exists, remove it.N)r+ÚKeyErrorr)rrrÚdiscard4szMailbox.discardcCstdƒ‚dS)ú>Replace the keyed message; raise KeyError if it doesn't exist.r"Nr#©rr*r&rrrÚ__setitem__;szMailbox.__setitem__cCs*z| |¡WStk
r$|YSXdS)z9Return the keyed message, or default if it doesn't exist.N)Ú__getitem__r/)rr*ÚdefaultrrrÚget?szMailbox.getc
CsB|js| |¡St | |¡¡}| |¡W5QR£SQRXdS)z=Return the keyed message; raise KeyError if it doesn't exist.N)rÚget_messageÚ
contextlibÚclosingÚget_file)rr*Úfilerrrr4Fs
zMailbox.__getitem__cCstdƒ‚dS)ú4Return a Message representation or raise a KeyError.r"Nr#r)rrrr7NszMailbox.get_messagecCst | |¡¡ ¡S)zœReturn a string representation or raise a KeyError.

        Uses email.message.Message to create a 7bit clean string
        representation of the message.©ÚemailÚmessage_from_bytesÚ	get_bytesZ	as_stringr)rrrÚ
get_stringRszMailbox.get_stringcCstdƒ‚dS)z8Return a byte string representation or raise a KeyError.r"Nr#r)rrrr@YszMailbox.get_bytescCstdƒ‚dS)ú6Return a file-like representation or raise a KeyError.r"Nr#r)rrrr:]szMailbox.get_filecCstdƒ‚dS)úReturn an iterator over keys.r"Nr#©rrrrÚiterkeysaszMailbox.iterkeyscCst| ¡ƒS)zReturn a list of keys.)ÚlistrErDrrrÚkeyseszMailbox.keysc	cs>| ¡D]0}z||}Wntk
r0YqYnX|VqdS)z%Return an iterator over all messages.N©rEr/©rr*ÚvaluerrrÚ
itervaluesis
zMailbox.itervaluescCs| ¡Sr,)rKrDrrrÚ__iter__rszMailbox.__iter__cCst| ¡ƒS)z,Return a list of messages. Memory intensive.)rFrKrDrrrÚvaluesuszMailbox.valuesc	csB| ¡D]4}z||}Wntk
r0YqYnX||fVqdS)z.Return an iterator over (key, message) tuples.NrHrIrrrÚ	iteritemsys
zMailbox.iteritemscCst| ¡ƒS)z9Return a list of (key, message) tuples. Memory intensive.)rFrNrDrrrÚitems‚sz
Mailbox.itemscCstdƒ‚dS)ú9Return True if the keyed message exists, False otherwise.r"Nr#r)rrrÚ__contains__†szMailbox.__contains__cCstdƒ‚dS)ú*Return a count of messages in the mailbox.r"Nr#rDrrrÚ__len__ŠszMailbox.__len__cCs| ¡D]}| |¡qdS)zDelete all messages.N)rGr0r)rrrÚclearŽsz
Mailbox.clearcCs4z||}Wntk
r$|YSX| |¡|S)z3Delete the keyed message and return it, or default.)r/r0)rr*r5ÚresultrrrÚpop“s

zMailbox.popcCs*| ¡D]}|| |¡fStdƒ‚dS)z6Delete an arbitrary (key, message) pair and return it.zNo messages in mailboxN)rErVr/r)rrrÚpopitemœszMailbox.popitemc	Cstt|dƒr| ¡}nt|dƒr(| ¡}n|}d}|D].\}}z|||<Wq4tk
r`d}Yq4Xq4|rptdƒ‚dS)z4Change the messages that correspond to certain keys.rNrOFTzNo message with key(s)N)ÚhasattrrNrOr/)rÚargÚsourceZbad_keyr*r&rrrÚupdate£s



zMailbox.updatecCstdƒ‚dS)ú&Write any pending changes to the disk.r"Nr#rDrrrÚflush´sz
Mailbox.flushcCstdƒ‚dS)úLock the mailbox.r"Nr#rDrrrÚlock¸szMailbox.lockcCstdƒ‚dS)ú#Unlock the mailbox if it is locked.r"Nr#rDrrrÚunlock¼szMailbox.unlockcCstdƒ‚dS)úFlush and close the mailbox.r"Nr#rDrrrÚcloseÀsz
Mailbox.closecCs.z| d¡WStk
r(tdƒ‚YnXdS)Nrz?String input must be ASCII-only; use bytes or a Message instead)ÚencodeÚUnicodeErrorÚ
ValueErrorr%rrrÚ_string_to_bytesÄszMailbox._string_to_bytesFc	Csüt|tjjƒrvt ¡}tj ||d¡}| |¡| 	d¡| 
¡}| dt¡}| 
|¡|jrr| t¡sr| 
t¡n‚t|tttjfƒrt|tjƒr¬t dtd¡| ¡}t|tƒrÀ| |¡}|rÐ| dd¡}| dt¡}| 
|¡|jrø| t¡sø| 
t¡nòt|dƒrèt|dƒr2t d	td¡|j}d
}| ¡}| d¡r\|d
d…d}n| d
¡rx|d
d…d}|s‚qÂ|r¤| d¡r¤d|dd
…}| dt¡}| 
|¡|}q6|jrø|rø| t¡sø| 
t¡ntdt|ƒƒ‚d
S)z%Dump message contents to target file.ró
ú8Use of StringIO input is deprecated, use BytesIO insteadés
From s
>From ÚreadÚbufferúDUse of text mode files is deprecated, use a binary mode file insteadNó
éþÿÿÿó
éÿÿÿÿóFrom s>From éúInvalid message type: %s)Ú
isinstancer>r&rÚioÚBytesIOÚ	generatorÚBytesGeneratorÚflattenÚseekrkÚreplaceÚlinesepÚwriteÚ_append_newlineÚendswithÚstrÚbytesÚStringIOÚwarningsÚwarnÚDeprecationWarningÚgetvaluergrXrlÚreadlineÚ
startswithÚ	TypeErrorÚtype)	rr&ÚtargetZmangle_from_rlÚgenÚdataZlastlineÚlinerrrÚ
_dump_messageÑs`


ÿ


ÿ
zMailbox._dump_message)NT)N)N)N)F)$Ú__name__Ú
__module__Ú__qualname__Ú__doc__r r'r+r-r0r3r6r4r7rAr@r:rErGrKrLrMrNrOrQrSrTrVrWr[r]r_rarcrgrrrrrrr!sB

		
	
c@sÚeZdZdZdZd6dd„Zdd„Zd	d
„Zdd„Zd
d„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-Zd.d/„Zd0d1„Zd2d3„Zd4d5„ZdS)7rzA qmail-style Maildir mailbox.ú:NTcCs¬t ||||¡tj |jd¡tj |jd¡tj |jd¡dœ|_tj |j¡sŠ|r€t |jd¡|j 	¡D]}t |d¡qln
t
|jƒ‚i|_dddœ|_d|_
d|_d	S)
zInitialize a Maildir instance.ÚtmpÚnewÚcur)r–r—r˜éÀr)r˜r—gš™™™™™¹?N)rr rrÚjoinrÚ_pathsÚexistsÚmkdirrMrÚ_tocÚ_toc_mtimesÚ
_last_readÚ_skewfactor)rÚdirnamerrrrrrr 
sý
zMaildir.__init__c
Cs~| ¡}z| ||¡Wn*tk
rB| ¡t |j¡‚YnXt|ƒt|t	ƒr|| 
¡}|j| ¡}||jkr„d}nd}d}tj
 |j¡ |j¡d}tj
 |j|||¡}t|t	ƒrÞt |jtj
 |j¡| ¡f¡zLzt |j|¡Wn(ttfk
rt |j|¡YnXt |j¡WnNtk
rx}z.t |j¡|jtjkrftd|ƒ‚n‚W5d}~XYnX|S)r!Úr—rz$Name clash with existing message: %sN)Ú_create_tmprÚ
BaseExceptionrcrr+ÚnameÚ_sync_closerur	Ú
get_subdirÚcolonÚget_inforÚbasenameÚsplitršrÚutimeÚgetatimeÚget_dateÚlinkÚAttributeErrorÚPermissionErrorÚrenameÚOSErrorÚerrnoZEEXISTr)rr&Ztmp_fileÚsubdirÚsuffixÚuniqÚdestÚerrrr'!sF


ÿÿzMaildir.addcCs t tj |j| |¡¡¡dS©r(N)rr+rršrÚ_lookupr)rrrr+KszMaildir.removec	Cs,z| |¡Wnttfk
r&YnXdSr.)r+r/ÚFileNotFoundErrorr)rrrr0OszMaildir.discardcCsÊ| |¡}| |¡}| |¡}t|tƒr.|}n|}tj |¡}|j|kr`|j| |j¡d}nd}| 	|¡tj 
|j|¡}	tj 
|j|||¡}
t|tƒrºt |	tj 
|	¡| ¡f¡t |	|
¡dS)r1rqr£N)r¼r'rur	rrr¢r©r¬r0ršrr­r®r¯r³)rr*r&Zold_subpathZtemp_keyZtemp_subpathZdominant_subpathr¶r·Ztmp_pathÚnew_pathrrrr3Ws$






ÿzMaildir.__setitem__c	Cs¢| |¡}ttj |j|¡dƒ }|jr4| |¡}nt|ƒ}W5QRXtj |¡\}}| 	|¡|j
|kr€| | |j
¡d¡| tj 
tj |j|¡¡¡|S)r<Úrbrq)r¼Úopenrrršrrr	r¬Ú
set_subdirr©Úset_infoÚset_dateÚgetmtime)rr*ZsubpathÚfÚmsgr¶r¦rrrr7rs


zMaildir.get_messagec
CsDttj |j| |¡¡dƒ}| ¡ td¡W5QR£SQRXdS)ú2Return a bytes representation or raise a KeyError.r¿rhN)	rÀrrršrr¼rkr|r}©rr*rÅrrrr@szMaildir.get_bytescCs$ttj |j| |¡¡dƒ}t|ƒS)rBr¿)rÀrrršrr¼Ú
_ProxyFilerÈrrrr:†szMaildir.get_filec	csF| ¡|jD]2}z| |¡Wntk
r8YqYnX|VqdS©rCN)Ú_refreshržr¼r/r)rrrrE‹s

zMaildir.iterkeyscCs| ¡||jkS©rP)rËržr)rrrrQ•szMaildir.__contains__cCs| ¡t|jƒS©rR)rËÚlenržrDrrrrSšszMaildir.__len__cCsdS)ú"Write any pending changes to disk.NrrDrrrr]Ÿsz
Maildir.flushcCsdS)r^NrrDrrrr_¥szMaildir.lockcCsdS)r`NrrDrrrra©szMaildir.unlockcCsdS©rbNrrDrrrrc­sz
Maildir.closecCs\g}t |j¡D]F}t|ƒdkr|ddkrtj tj |j|¡¡r| |dd…¡q|S)úReturn a list of folder names.érÚ.N)rÚlistdirrrÎrÚisdirršÚappend©rrUÚentryrrrÚlist_folders±sÿzMaildir.list_folderscCs ttj |jd|¡|jddS)z/Return a Maildir instance for the named folder.rÓF©rr)rrrršrr©rÚfolderrrrÚ
get_folderºsþzMaildir.get_foldercCs\tj |jd|¡}t||jd}tj |d¡}tj |¡sXt t |tj	tj
Bd¡¡|S)z>Create a folder and return a Maildir instance representing it.rÓ©rZ
maildirfolderé¶)rrršrrrrœrcrÀÚO_CREATÚO_WRONLY)rrÜrrUZmaildirfolder_pathrrrÚ
add_folderÀsÿzMaildir.add_foldercCstj |jd|¡}t tj |d¡¡t tj |d¡¡D](}t|ƒdksX|ddkr<td|ƒ‚q<t |¡D]B}|dkrp|dkrp|dkrptj tj ||¡¡rptd||fƒ‚qptj|d	d
D]F\}}}|D]}t 	tj ||¡¡qÐ|D]}t 
tj ||¡¡qîqÂt 
|¡dS)ú-Delete the named folder, which must be empty.rÓr—r˜rÒrzFolder contains message(s): %sr–z%Folder contains subdirectory '%s': %sF)ÚtopdownN)rrršrrÔrÎrrÕÚwalkr+Úrmdir)rrÜrrØÚrootÚdirsÚfilesrrrÚ
remove_folderÊs&ÿÿÿzMaildir.remove_foldercCsXt ¡}t tj |jd¡¡D]4}tj |jd|¡}|tj |¡dkrt |¡qdS)zDelete old files in "tmp".r–i@úN)ÚtimerrÔrršrr®r+)rÚnowrØrrrrÚcleanÝs
z
Maildir.cleanrÒcCsØt ¡}t ¡}d|kr$| dd¡}d|kr8| dd¡}dt|ƒt|ddƒt ¡tj|f}tj	 
|jd|¡}zt |¡WnFt
k
rÆtjd7_zt|ƒWYStk
rÀYnXYnXtd	|ƒ‚d
S)z=Create a file in the tmp subdirectory and open and return it.ú/z\057r•z\072z%s.M%sP%sQ%s.%srÒg€„.Ar–z&Name clash prevented file creation: %sN)rëÚsocketÚgethostnamer|ÚintrÚgetpidrÚ_countrršrÚstatr½Ú_create_carefullyÚFileExistsErrorr)rrìZhostnamer¸rrrrr¤çs,ÿÿzMaildir._create_tmpcCsØt ¡|jd|jkr^d}|jD]2}tj |j|¡}||j|krJd}||j|<q"|s^dSi|_|jD]^}|j|}t 	|¡D]D}tj 
||¡}tj |¡r¢q‚| |j
¡d}tj 
||¡|j|<q‚qjt ¡|_dS)z!Update table of contents mapping.éFTNr)rër r¡rŸrrrÄr›ržrÔršrÕr¬r©)rZrefreshr¶ÚmtimerrØÚpr¸rrrrËÿs&


zMaildir._refreshcCs€z.tj tj |j|j|¡¡r,|j|WSWntk
rBYnX| ¡z|j|WStk
rztd|ƒd‚YnXdS)z=Use TOC to return subpath for given key, or raise a KeyError.úNo message with key: %sN)rrrœršrržr/rËr)rrrr¼#szMaildir._lookupcCsXt|dƒs| ¡|_z|t|jƒWStk
r:YdStk
rPYqYqXqdS)z0Return the next message in a one-time iteration.Ú
_onetime_keysN)rXrErûÚnextÚ
StopIterationr/rDrrrrü1s

zMaildir.next)NT)r‘r’r“r”r©r r'r+r0r3r7r@r:rErQrSr]r_rarcrÙrÝrârêrírór¤rËr¼rürrrrrs6
*
	
$c@s”eZdZdZd$dd„Zdd„Zdd	„Zd
d„Zdd
„Zdd„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdd„Zd%d d!„Zd"d#„ZdS)&Ú_singlefileMailboxzA single-file mailbox.NTc
Cs¾t ||||¡zt|jdƒ}Wnntk
rŽ}zP|jtjkr\|rPt|jdƒ}q~t|jƒ‚n"|jtjtj	fkr|t|jdƒ}n‚W5d}~XYnX||_
d|_d|_d|_
d|_d|_d|_dS)z!Initialize a single-file mailbox.úrb+zwb+r¿NrF)rr rÀrr´rµÚENOENTrÚEACCESÚEROFSÚ_fileržÚ	_next_keyÚ_pendingÚ
_pending_syncÚ_lockedÚ_file_length)rrrrrÅrºrrrr As$z_singlefileMailbox.__init__cCs8| ¡| |¡|j|j<|jd7_d|_|jdS)r!rÒT)r¼Ú_append_messageržrrr%rrrr'Xs
z_singlefileMailbox.addcCs| |¡|j|=d|_dS)r(TN)r¼ržrr)rrrr+bs
z_singlefileMailbox.removecCs$| |¡| |¡|j|<d|_dS)r1TN)r¼r	ržrr2rrrr3hs
z_singlefileMailbox.__setitem__ccs| ¡|j ¡EdHdSrÊ)r¼ržrGrDrrrrEnsz_singlefileMailbox.iterkeyscCs| ¡||jkSrÌ)r¼ržr)rrrrQssz_singlefileMailbox.__contains__cCs| ¡t|jƒSrÍ)r¼rÎržrDrrrrSxsz_singlefileMailbox.__len__cCs|jst|jƒd|_dS)r^TN)rÚ
_lock_filerrDrrrr_}s
z_singlefileMailbox.lockcCs|jrt|jƒd|_dS©r`FN)rÚ_unlock_filerrDrrrraƒs
z_singlefileMailbox.unlockc
Csä|js |jrt|jƒd|_dS|jdk	s.t‚|j dd¡|j ¡}||jkrbt	d|j|fƒ‚t
|jƒ}z¤i}| |¡t
|j ¡ƒD]x}|j|\}}|j |¡| |¡| ¡}|j td||j ¡ƒ¡}|sÜqè| |¡qº|| ¡f||<| |¡qŠ| ¡|_Wn"| ¡t |j¡‚YnXt|ƒ|j ¡t |j¡j}	t |j|	¡zt |j|j¡Wn2tk
r¨t |j¡t |j|j¡YnXt|jdƒ|_||_d|_d|_|jràt |jdddS)	rÏFNrr÷z4Size of mailbox file changed (expected %i, found %i)érÿ)Údotlock)!rrÚ_sync_flushrržÚAssertionErrorr{ÚtellrrÚ_create_temporaryrÚ_pre_mailbox_hookÚsortedrGÚ_pre_message_hookrkÚminr~Ú_post_message_hookrcrr+r¦r§rôÚst_modeÚchmodr³rörÀrr
)
rZcur_lenZnew_fileZnew_tocr*ÚstartÚstopZ	new_startrlÚmoderrrr]‰sb


þ



ÿ
z_singlefileMailbox.flushcCsdS)ú,Called before writing the mailbox to file f.Nr©rrÅrrrrÉsz$_singlefileMailbox._pre_mailbox_hookcCsdS)ú-Called before writing each message to file f.NrrrrrrÍsz$_singlefileMailbox._pre_message_hookcCsdS©ú,Called after writing each message to file f.NrrrrrrÑsz%_singlefileMailbox._post_message_hookcCs4z| ¡W5z|jr| ¡W5|j ¡XXdSrÐ)rrcrrar]rDrrrrcÕsz_singlefileMailbox.closecCsN|jdkr| ¡|dk	rJz|j|WStk
rHtd|ƒd‚YnXdS)z'Return (start, stop) or raise KeyError.Nrú)ržÚ
_generate_tocr/r)rrrr¼às
z_singlefileMailbox._lookupcCsœ|j dd¡|j ¡}t|jƒdkr8|js8| |j¡z&| |j¡| |¡}| 	|j¡Wn"t
k
r€|j |¡‚YnX|j ¡|j ¡|_
|S)z;Append message to mailbox and return (start, stop) offsets.rr÷)rr{rrÎržrrrÚ_install_messagerr¥Útruncater]r)rr&ZbeforeZoffsetsrrrr	ês


z"_singlefileMailbox._append_message)NT)N)r‘r’r“r”r r'r+r3rErQrSr_rar]rrrrcr¼r	rrrrrþ>s"

@

rþc@sBeZdZdZdZdd„Zddd„Zddd	„Zdd
d„Zdd
„Z	dS)Ú	_mboxMMDFzAn mbox or MMDF mailbox.TcCsp| |¡\}}|j |¡|j ¡ td¡}|j ||j ¡¡}| | td¡¡}| 	|dd… 
d¡¡|S)r<órhrsNr)r¼rr{rˆr|r}rkrÚ_message_factoryÚset_fromÚdecode)rr*rrÚ	from_lineÚstringrÆrrrr7sz_mboxMMDF.get_messageFcCst | ||¡¡j|dS)ú3Return a string representation or raise a KeyError.)Úunixfromr=)rr*Úfrom_rrrrAs

ÿÿz_mboxMMDF.get_stringcCsJ| |¡\}}|j |¡|s(|j ¡|j ||j ¡¡}| td¡S)r,rh)r¼rr{rˆrkrr|r})rr*r.rrr+rrrr@s
z_mboxMMDF.get_bytescCs<| |¡\}}|j |¡|s(|j ¡t|j|j ¡|ƒS)rB)r¼rr{rˆÚ_PartialFiler)rr*r.rrrrrr:s

z_mboxMMDF.get_filecCsd}t|tƒr| |¡}t|tƒrf| d¡rf| d¡}|dkr\|d|…}||dd…}q°|}d}nJt|tƒrˆ| ¡ d¡}d|}n(t|t	j
jƒr°| ¡}|dk	r°| d¡}|dkrÎdt
 t
 ¡¡ ¡}|j ¡}|j |t¡| ||j|j¡|j ¡}||fS)	z1Format a message and blindly write to self._file.NrrrhrqrÒr&rsFrom MAILER-DAEMON )rurrgr‚r‰ÚfindÚ_mboxMMDFMessageÚget_fromrdr>r&rÚget_unixfromrëÚasctimeÚgmtimerrr~r}rÚ
_mangle_from_)rr&r*ÚnewlineZauthorrrrrrr#&s0







z_mboxMMDF._install_messageN)F)F)F)
r‘r’r“r”r6r7rAr@r:r#rrrrr%s


	
r%c@s2eZdZdZdZdZd
dd„Zdd„Zdd	„ZdS)rzA classic mbox mailbox.TNcCst|_t ||||¡dS)zInitialize an mbox mailbox.N)r
r'r%r rrrrr Lsz
mbox.__init__cCs| t¡dSr ©r~r}rrrrrQszmbox._post_message_hookcCsègg}}d}|j d¡|j ¡}|j ¡}| d¡rzt|ƒt|ƒkrj|r`| |ttƒ¡n
| |¡| |¡d}q|s¤|r–| |ttƒ¡q¸| |¡q¸q|tkr²d}qd}qtt	t
||ƒƒƒ|_t|jƒ|_|j ¡|_
dS)ú0Generate key-to-(start, stop) table of contents.FrrrTN)rr{rrˆr‰rÎrÖr}ÚdictÚ	enumerateÚzipržrr)rÚstartsÚstopsZlast_was_emptyÚline_posrrrrr"Us.






zmbox._generate_toc)NT)	r‘r’r“r”r6rr rr"rrrrrCs
c@s2eZdZdZddd„Zdd„Zdd	„Zd
d„ZdS)
rzAn MMDF mailbox.NTcCst|_t ||||¡dS)zInitialize an MMDF mailbox.N)r
r'r%r rrrrr zsz
MMDF.__init__cCs| dt¡dS)róNr8rrrrrszMMDF._pre_message_hookcCs| tdt¡dS)r!r@Nr8rrrrrƒszMMDF._post_message_hookcCsÞgg}}|j d¡d}|}|j ¡}|j ¡}| dt¡r˜| |¡|}|j ¡}|j ¡}|dtkr„| |ttƒ¡qžqJ|sJ| |¡qžqJq|sq qtt	t
||ƒƒƒ|_t|jƒ|_|j dd¡|j ¡|_
dS)r9rr@r÷N)rr{rˆrr‰r}rÖrÎr:r;r<ržrr)rr=r>Únext_posr?rrrrr"‡s.






zMMDF._generate_toc)NT)r‘r’r“r”r rrr"rrrrrws

c@sÂeZdZdZd0dd„Zdd„Zdd	„Zd
d„Zdd
„Zdd„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zd$d%„Zd&d'„Zd(d)„Zd*d+„Zd,d-„Zd.d/„ZdS)1rzAn MH mailbox.NTcCstt ||||¡tj |j¡sj|r`t |jd¡t t tj 	|jd¡tj
tjBtjBd¡¡n
t
|jƒ‚d|_dS)zInitialize an MH instance.r™ú
.mh_sequencesi€FN)rr rrrœrrrcrÀršràÚO_EXCLrárrrrrrr §sÿ
zMH.__init__cCsä| ¡}t|ƒdkrd}nt|ƒd}tj |jt|ƒ¡}t|ƒ}d}zŠ|j
rVt|ƒzfz| 
||¡Wn:tk
r¢|j
r†t|ƒt	|ƒd}t |¡‚YnXt|tƒrº| ||¡W5|j
rÌt|ƒXW5|sÞt	|ƒX|S)r!rrÒFT)rGrÎÚmaxrrršrrrõr§rr
rrr¥r+rurÚ_dump_sequences)rr&rGZnew_keyr¾rÅÚclosedrrrr'³s6


zMH.addc
Csxtj |jt|ƒ¡}zt|dƒ}Wn>tk
r`}z |jtjkrNt	d|ƒ‚n‚W5d}~XYnX| 
¡t |¡dS)r(rÿrúN)rrršrrrÀr´rµrr/rcr+)rr*rrÅrºrrrr+Õsz	MH.removec
CsÖtj |jt|ƒ¡}zt|dƒ}Wn>tk
r`}z |jtjkrNt	d|ƒ‚n‚W5d}~XYnXzd|jrrt|ƒz@t t |tjtjB¡¡| ||¡t|tƒr°| ||¡W5|jrÂt
|ƒXW5t
|ƒXdS)r1rÿrúN)rrršrrrÀr´rµrr/r§rr
rrcráÚO_TRUNCrrurrE)rr*r&rrÅrºrrrr3ãs$
zMH.__setitem__c
Csèz@|jr$ttj |jt|ƒ¡dƒ}nttj |jt|ƒ¡dƒ}Wn>tk
r~}z |jtj	krlt
d|ƒ‚n‚W5d}~XYnX|2|jr”t|ƒzt
|ƒ}W5|jr°t|ƒXW5QRX| ¡ ¡D]\}}||krÈ| |¡qÈ|S)r<rÿr¿rúN)rrÀrrršrrr´rµrr/r
rrÚ
get_sequencesrOÚadd_sequence)rr*rÅrºrÆr¦Úkey_listrrrr7ûs&zMH.get_messagec
CsÔz@|jr$ttj |jt|ƒ¡dƒ}nttj |jt|ƒ¡dƒ}Wn>tk
r~}z |jtj	krlt
d|ƒ‚n‚W5d}~XYnX|F|jr”t|ƒz | 
¡ td¡W¢W5QR£S|jrÄt|ƒXW5QRXdS)rÇrÿr¿rúNrh)rrÀrrršrrr´rµrr/r
rrkr|r}©rr*rÅrºrrrr@s zMH.get_bytesc
Csfzttj |jt|ƒ¡dƒ}Wn>tk
r\}z |jtjkrJt	d|ƒ‚n‚W5d}~XYnXt
|ƒS)rBr¿rúN)rÀrrršrrr´rµrr/rÉrKrrrr:)szMH.get_filecCsttdd„t |j¡DƒƒƒS)rCcss|]}| ¡rt|ƒVqdSr,)Úisdigitrñ)Ú.0rØrrrÚ	<genexpr>6sÿzMH.iterkeys.<locals>.<genexpr>)ÚiterrrrÔrrDrrrrE4szMH.iterkeyscCstj tj |jt|ƒ¡¡SrÌ)rrrœršrrr)rrrrQ9szMH.__contains__cCstt| ¡ƒƒSrÍ)rÎrFrErDrrrrS=sz
MH.__len__cCs2|js.ttj |jd¡dƒ|_t|jƒd|_dS)r^rBrÿTN)rrÀrrršrrr
rDrrrr_As
zMH.lockcCs(|jr$t|jƒt|jƒ|`d|_dSr)rrrr§rDrrrraHs


z	MH.unlockcCsdS)r\NrrDrrrr]PszMH.flushcCs|jr| ¡dSrÐ)rrarDrrrrcTszMH.closecCs<g}t |j¡D]&}tj tj |j|¡¡r| |¡q|S)rÑ)rrÔrrrÕršrÖr×rrrrÙYs
zMH.list_folderscCsttj |j|¡|jddS)z+Return an MH instance for the named folder.FrÚ©rrrršrrrÛrrrrÝasÿz
MH.get_foldercCsttj |j|¡|jdS)z:Create a folder and return an MH instance representing it.rÞrPrÛrrrrâfsÿz
MH.add_foldercCs`tj |j|¡}t |¡}|dgkr:t tj |d¡¡n|gkrDntd|jƒ‚t |¡dS)rãrBzFolder not empty: %sN)rrršrrÔr+rræ)rrÜrÚentriesrrrrêks

zMH.remove_folderc

si}ttj |jd¡dddÜ}t| ¡ƒ‰|D]Ä}zš| d¡\}}tƒ}| ¡D]H}| ¡rn| 	t
|ƒ¡qRdd„| d¡Dƒ\}}	| t||	d	ƒ¡qR‡fd
d„t
|ƒDƒ||<t||ƒdkrÌ||=Wq0tk
ròtd
| ¡ƒ‚Yq0Xq0W5QRX|S)z=Return a name-to-key-list dictionary to define each sequence.rBÚrÚASCII©Úencodingr•css|]}t|ƒVqdSr,)rñ)rMÚxrrrrN„sz#MH.get_sequences.<locals>.<genexpr>ú-rÒcsg|]}|ˆkr|‘qSrr)rMr*©Zall_keysrrÚ
<listcomp>†sÿz$MH.get_sequences.<locals>.<listcomp>rz"Invalid sequence specification: %s)rÀrrršrÚsetrGr¬rLr'rñr[ÚrangerrÎrfrÚrstrip)
rZresultsrÅrr¦ÚcontentsrGÚspecrrrrXrrHws(
ÿzMH.get_sequencescCsttj |jd¡ddd}zØt t |jtjtj	B¡¡| 
¡D]®\}}t|ƒdkrVq@| |d¡d}d}t
t|ƒƒD]R}|d	|krœ|sÆd
}| d¡n*|r¸d}| d||f¡n| d
|¡|}qx|rä| t|ƒd¡q@| d¡q@W5t|ƒXdS)z:Set sequences using the given name-to-key-list dictionary.rBzr+rSrTrr•NFrÒTrWz%s %sz %sÚ
)rÀrrršrr§rcr¦rárGrOrÎr~rrZr)rÚ	sequencesrÅr¦rGÚprevZ
completingr*rrrÚ
set_sequencess.zMH.set_sequencesc	
Cs>| ¡}d}g}| ¡D]Â}|d|krÒ| ||df¡z4t tj |jt|ƒ¡tj |jt|dƒ¡¡WnHt	t
fk
r¶t tj |jt|ƒ¡tj |jt|dƒ¡¡YnXt tj |jt|ƒ¡¡|d7}q|d|_
t|ƒdkrödS| ¡D]0\}}|D]"\}}||kr
||| |¡<q
qþ| |¡dS)z?Re-name messages to eliminate numbering gaps. Invalidates keys.rrÒN)rHrErÖrr°rršrrr±r²r³ÚunlinkrrÎrOÚindexrb)	rr`raZchangesr*r¦rJÚoldr—rrrÚpack¬s0ÿÿ



zMH.packcCst| ¡}| ¡}| ¡D]0\}}||kr4| |¡q||kr|| |¡=q|D]}||krN|g||<qN| |¡dS)z;Inspect a new MHMessage and update sequences appropriately.N)rHrOrÖrdrb)rr&r*Zpending_sequencesZ
all_sequencesr¦rJÚsequencerrrrEÆszMH._dump_sequences)NT)r‘r’r“r”r r'r+r3r7r@r:rErQrSr_rar]rcrÙrÝrârêrHrbrfrErrrrr¤s.
"c@seZdZdZedddddddhƒZd%dd„Zd
d„Zdd„Zdd„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd „Zd!d"„Zd#d$„Zd	S)&rzAn Rmail-style Babyl mailbox.ÚunseenÚdeletedZfiledÚansweredÚ	forwardedZeditedÚresentNTcCst ||||¡i|_dS)zInitialize a Babyl mailbox.N)rþr Ú_labelsrrrrr ÛszBabyl.__init__cCs(t ||¡}t|tƒr$| ¡|j|<|S)r!)rþr'rurÚ
get_labelsrm)rr&r*rrrr'às
z	Babyl.addcCs"t ||¡||jkr|j|=dSr»)rþr+rmr)rrrr+çs
zBabyl.removecCs*t |||¡t|tƒr&| ¡|j|<dS)r1N)rþr3rurrnrmr2rrrr3ís
zBabyl.__setitem__c
Csþ| |¡\}}|j |¡|j ¡t ¡}|j ¡}|dtks\|sHq\| | td¡¡q,t ¡}|j ¡}|tks|s|q| | td¡¡qd||j 	¡}|dksªt
‚|j |¡}| td¡}t| 
¡|ƒ}	|	 | 
¡¡||jkrú|	 |j|¡|	S)r<ó*** EOOH ***rhr)r¼rr{rˆrvrwr}r~r|rrrkrr‡Úset_visiblermÚ
set_labels)
rr*rrÚoriginal_headersrZvisible_headersÚnZbodyrÆrrrr7ós,



zBabyl.get_messagec	Cs¸| |¡\}}|j |¡|j ¡t ¡}|j ¡}|dtks\|sHq\| | td¡¡q,|j ¡}|tksv|s\qvq\| 	¡}||j 
¡}|dks˜t‚|j |¡}| td¡}||S)r,rorhr)
r¼rr{rˆrvrwr}r~r|r‡rrrk)	rr*rrrrrZheadersrsrŽrrrr@s"


zBabyl.get_bytescCst | |¡ dt¡¡S)rBrh)rvrwr@r|r}r)rrrr:%szBabyl.get_filecCs<| ¡tƒ}|j ¡D]}| |¡q| |j¡t|ƒS)z4Return a list of user-defined labels in the mailbox.)r¼rZrmrMr[Údifference_updateÚ_special_labelsrF)rÚlabelsZ
label_listrrrrn)szBabyl.get_labelscCs:gg}}|j d¡d}g}|}|j ¡}|j ¡}|dtkrœt|ƒt|ƒkrd| |ttƒ¡| |¡dd„|j ¡dd… d¡Dƒ}| |¡q|dks°|dtkrÔt|ƒt|ƒkrì| |ttƒ¡q|s| |ttƒ¡qîqtt	t
||ƒƒƒ|_tt	|ƒƒ|_t|jƒ|_
|j dd	¡|j ¡|_dS)
r9rscSsg|]}| ¡r| ¡‘qSr)Ústrip©rMÚlabelrrrrY@sþz'Babyl._generate_toc.<locals>.<listcomp>rÒNó,ór÷)rr{rˆrr}rÎrÖr¬r:r;r<ržrmrr)rr=r>rAZlabel_listsr?rrvrrrr"2s4



ÿzBabyl._generate_toccCsVdt}|dt7}| ¡}dd„|Dƒ}|dd |¡t7}|d7}| |¡dS)	rsBABYL OPTIONS:s
Version: 5css|]}| ¡VqdSr,)rdrxrrrrNUsz*Babyl._pre_mailbox_hook.<locals>.<genexpr>sLabels:rzr{N)r}rnršr~)rrÅZbabylrvrrrrPszBabyl._pre_mailbox_hookcCs| dt¡dS)róNr8rrrrrZszBabyl._pre_message_hookcCs| td¡dS)r!r{Nr8rrrrr^szBabyl._post_message_hookcCsx|j ¡}t|tƒr°g}g}| ¡D]$}||jkr>| |¡q$| |¡q$|j d¡|D]}|j d| ¡¡qZ|j d¡|D]}|j d| ¡d¡q„|j t	¡n|j dt	¡t|t
jjƒrt
 ¡}t
j |dd¡}| |¡| d¡| ¡}|j | d	t	¡¡|d	ks,|süq,qü|j d
t	¡t|tƒr¤t
 ¡}	t
j |	dd¡}
|
 | ¡¡|	 ¡}|j | d	t	¡¡|d	ks¢|snqâqnn>| d¡| ¡}|j | d	t	¡¡|d	ksâ|s®qâq®| d¡}|söqf|j | d	t	¡¡qânTt|ttt
jfƒrt|t
jƒrJt dtd
¡| ¡}t|tƒr`| |¡}| d¡d}|ddkrâ|j |d|… d	t	¡¡|j d
t	¡|j |d|… d	t	¡¡|j ||d… d	t	¡¡n(|j d
t	t	¡|j | d	t	¡¡nXt |dƒrVt |dƒr:t dtd
¡|j!}| ¡}
d}| ¡}| "d¡rl|dd…d	}n| "d¡rˆ|dd…d	}|j | d	t	¡¡|d	ks¬|sF|rÚd}|j d
t	¡| |
¡nqÚqF| ¡}|sìqf| "d¡r
|dd…t	}n:| "d¡r(|dd…t	}n| "d	¡rD|dd…t	}|j |¡qÚnt#dt$|ƒƒ‚|j ¡}||fS)z0Write message contents and return (start, stop).ó1s, s,,ó rzs1,,Frrhror
rirjs

r÷rqNrˆrlrmTrnrorprt)%rrrurrnrurÖr~rdr}r>r&rrvrwrxryrzr{rˆr|Úget_visiblerkr‚rrƒr„r…r†r‡rgr0rXrlr€rŠr‹)rr&rZspecial_labelsrvryZorig_bufferZorig_generatorrZ
vis_bufferZ
vis_generatorrlZ
body_startZoriginal_posZ
first_passrrrrr#bs¼







ÿ
ÿ
zBabyl._install_message)NT)r‘r’r“r”Ú	frozensetrur r'r+r3r7r@r:rnr"rrrr#rrrrrÕs&
ÿ
	
c@s*eZdZdZd	dd„Zdd„Zdd„ZdS)
rz0Message with mailbox-format-specific properties.NcCsÒt|tjjƒr4| t |¡¡t|tƒrÎ| |¡nšt|tƒrP| t 	|¡¡n~t|t
ƒrl| t |¡¡nbt|tj
ƒrŠ| t |¡¡nDt|dƒr¦| t |¡¡n(|dkr¾tjj |¡ntdt|ƒƒ‚dS)zInitialize a Message instance.rkNrt)rur>r&rÚ_become_messageÚcopyZdeepcopyÚ_explain_tor‚r?rZmessage_from_stringrvÚ
TextIOWrapperZmessage_from_filerXZmessage_from_binary_filer rŠr‹r%rrrr Ñs



zMessage.__init__cCs4t|dgƒ}|jD]}||kr|j||j|<qdS)z0Assume the non-format-specific state of message.Ú_type_specific_attributesN)ÚgetattrÚ__dict__)rr&Z
type_specificr¦rrrräs
zMessage._become_messagecCst|tƒrdStdƒ‚dS)z:Copy format-specific state to message insofar as possible.Nz Cannot convert to specified type)rurrŠr%rrrrƒës
zMessage._explain_to)N)r‘r’r“r”r rrƒrrrrrÎs
c@s|eZdZdZdddgZddd„Zdd	„Zd
d„Zdd
„Zdd„Z	dd„Z
dd„Zdd„Zdd„Z
dd„Zdd„Zdd„ZdS)r	z)Message with Maildir-specific properties.Ú_subdirÚ_infoÚ_dateNcCs&d|_d|_t ¡|_t ||¡dS)z%Initialize a MaildirMessage instance.r—r£N)rˆr‰rërŠrr r%rrrr øs
zMaildirMessage.__init__cCs|jS)zReturn 'new' or 'cur'.)rˆrDrrrr¨ÿszMaildirMessage.get_subdircCs(|dks|dkr||_ntd|ƒ‚dS)zSet subdir to 'new' or 'cur'.r—r˜z!subdir must be 'new' or 'cur': %sN)rˆrf)rr¶rrrrÁszMaildirMessage.set_subdircCs"|j d¡r|jdd…SdSdS)ú*Return as a string the flags that are set.ú2,r÷Nr£)r‰r‰rDrrrÚ	get_flags
szMaildirMessage.get_flagscCsdd t|ƒ¡|_dS)ú)Set the given flags and unset all others.rŒr£N)ršrr‰)rÚflagsrrrÚ	set_flagsszMaildirMessage.set_flagscCs$| d t| ¡ƒt|ƒB¡¡dS©z.Set the given flag(s) without changing others.r£N©rršrZr©rÚflagrrrÚadd_flagszMaildirMessage.add_flagcCs,| ¡r(| d t| ¡ƒt|ƒ¡¡dS)ú7Unset the given string flag(s) without changing others.r£N)rrršrZr“rrrÚremove_flagszMaildirMessage.remove_flagcCs|jS)z<Return delivery date of message, in seconds since the epoch.)rŠrDrrrr¯szMaildirMessage.get_datecCs6zt|ƒ|_Wn"tk
r0td|ƒd‚YnXdS)z9Set delivery date of message, in seconds since the epoch.zcan't convert to float: %sN)ÚfloatrŠrfrŠ)rÚdaterrrrÃ"szMaildirMessage.set_datecCs|jS)z%Get the message's "info" as a string.)r‰rDrrrrª)szMaildirMessage.get_infocCs&t|tƒr||_ntdt|ƒƒ‚dS)z Set the message's "info" string.zinfo must be a string: %sN)rurr‰rŠr‹)rÚinforrrrÂ-s
zMaildirMessage.set_infocCs¤t|tƒr8| | ¡¡| | ¡¡| | ¡¡nht|tƒrÄt	| ¡ƒ}d|kr`| 
d¡| ¡dkrv| 
d¡d|krˆ| 
d¡d|krš| 
d¡d|kr¬| 
d¡| d	t 
| ¡¡¡nÜt|tƒrt	| ¡ƒ}d|krî| d
¡d|kr| d¡d|kr | d¡nˆt|tƒr‚t	| ¡ƒ}d|krD| d
¡d|krX| d
¡d|krl| d¡d|kr | d¡nt|tƒrntdt|ƒƒ‚dS)z;Copy Maildir-specific state to message insofar as possible.ÚSÚRr˜ÚOÚTÚDÚFÚAú
MAILER-DAEMONrhÚrepliedÚflaggedrirjÚPrkú$Cannot convert to specified type: %sN)rur	rrrÁr¨rÃr¯r1rZr•r(rër5rrIrÚ	add_labelrrŠr‹)rr&rrrrrƒ4sP

















ÿzMaildirMessage._explain_to)N)r‘r’r“r”r…r r¨rÁrrr•r—r¯rÃrªrÂrƒrrrrr	ós

c@sZeZdZdZdgZddd„Zdd„Zddd	„Zd
d„Zdd
„Z	dd„Z
dd„Zdd„ZdS)r1z/Message with mbox- or MMDF-specific properties.Ú_fromNcCsV| dd¡t|tjjƒrF| ¡}|dk	rF| d¡rF| |dd…¡t ||¡dS)z'Initialize an mboxMMDFMessage instance.r¢TNzFrom rs)r(rur>r&rr3r‰r )rr&r-rrrr esz_mboxMMDFMessage.__init__cCs|jS)z Return contents of "From " line.)r¨rDrrrr2nsz_mboxMMDFMessage.get_fromcCs4|dk	r*|dkrt ¡}|dt |¡7}||_dS)z>Set "From " line, formatting and appending time_ if specified.NTú )rër5r4r¨)rr.Ztime_rrrr(rs
z_mboxMMDFMessage.set_fromcCs| dd¡| dd¡S)r‹ÚStatusr£úX-Status)r6rDrrrrzsz_mboxMMDFMessage.get_flagscCsÒt|ƒ}d\}}dD]}||kr||7}| |¡qdD]}||kr8||7}| |¡q8|d t|ƒ¡7}z| d|¡Wn tk
rš| d|¡YnXz| d|¡Wn tk
rÌ| d|¡YnXdS)rŽ)r£r£)rœr)rŸr r¡r£rªr«N)rZr+ršrÚreplace_headerr/Z
add_header)rrZstatus_flagsZ
xstatus_flagsr”rrrr~s&z_mboxMMDFMessage.set_flagscCs$| d t| ¡ƒt|ƒB¡¡dSr‘r’r“rrrr•”sz_mboxMMDFMessage.add_flagcCs4d|ksd|kr0| d t| ¡ƒt|ƒ¡¡dS)r–rªr«r£Nr’r“rrrr—˜sz_mboxMMDFMessage.remove_flagc	CsÞt|tƒrÐt| ¡ƒ}d|kr(| d¡d|kr:| d¡d|krL| d¡d|kr^| d¡d|krp| d¡|d	=|d
=d | ¡ ¡dd
…¡}z| 	t
 t 
|d¡¡¡Wnttfk
rÊYnXn
t|tƒrø| | ¡¡| | ¡¡nât|tƒrZt| ¡ƒ}d|kr$| d¡d|kr8| d¡d|krL| d¡|d	=|d
=n€t|tƒr¼t| ¡ƒ}d|kr†| d¡d|krš| d¡d|kr®| d¡|d	=|d
=nt|tƒrÊntdt|ƒƒ‚d
S)zACopy mbox- or MMDF-specific state to message insofar as possible.rr˜r r¡rœr›rŸržZstatuszx-statusr©éûÿÿÿNz%a %b %d %H:%M:%S %Yrhr£r¤rirjr¦)rur	rZrrÁr•ršr2r¬rÃÚcalendarZtimegmrëÚstrptimerfÚ
OverflowErrorr1rr(rrIrr§rrŠr‹)rr&rZ
maybe_daterrrrƒsb





ÿ













ÿz_mboxMMDFMessage._explain_to)N)N)
r‘r’r“r”r…r r2r(rrr•r—rƒrrrrr1`s
	
r1c@seZdZdZdS)r
z&Message with mbox-specific properties.N©r‘r’r“r”rrrrr
Ñsc@sHeZdZdZdgZddd„Zdd„Zdd	„Zd
d„Zdd
„Z	dd„Z
dS)rz$Message with MH-specific properties.Ú
_sequencesNcCsg|_t ||¡dS)z!Initialize an MHMessage instance.N)r²rr r%rrrr ÚszMHMessage.__init__cCs|jdd…S)z4Return a list of sequences that include the message.N)r²rDrrrrHßszMHMessage.get_sequencescCst|ƒ|_dS)z3Set the list of sequences that include the message.N)rFr²)rr`rrrrbãszMHMessage.set_sequencescCs6t|tƒr"||jkr2|j |¡ntdt|ƒƒ‚dS)z8Add sequence to list of sequences including the message.zsequence type must be str: %sN)rurr²rÖrŠr‹©rrgrrrrIçs

zMHMessage.add_sequencecCs*z|j |¡Wntk
r$YnXdS)zARemove sequence from the list of sequences including the message.N)r²r+rfr³rrrÚremove_sequenceïszMHMessage.remove_sequencecCsFt|tƒrdt| ¡ƒ}d|kr*| d¡n| d¡| d¡d|krP| d¡d|krb| d¡nÞt|tƒr¾t| ¡ƒ}d|krŽ| d¡n
| d	¡d|krª| d¡d|kr¼| d
¡n„t|tƒrâ| ¡D]}| |¡qÐn`t|t	ƒr$t| ¡ƒ}d|kr| 
d¡d|krB| 
d¡nt|tƒr2ntdt
|ƒƒ‚d
S)z6Copy MH-specific state to message insofar as possible.rhr˜r›r¤r r£rœÚROrr¡rjr¦N)rur	rZrHrÁr•r1rrIrr§rrŠr‹)rr&r`rgrrrrƒösB










ÿzMHMessage._explain_to)N)r‘r’r“r”r…r rHrbrIr´rƒrrrrrÕs
c@sbeZdZdZddgZddd„Zdd„Zd	d
„Zdd„Zd
d„Z	dd„Z
dd„Zdd„Zdd„Z
dS)rz'Message with Babyl-specific properties.rmÚ_visibleNcCsg|_tƒ|_t ||¡dS)z#Initialize a BabylMessage instance.N)rmrr¶r r%rrrr "szBabylMessage.__init__cCs|jdd…S)z'Return a list of labels on the message.N)rmrDrrrrn(szBabylMessage.get_labelscCst|ƒ|_dS)z&Set the list of labels on the message.N)rFrm)rrvrrrrq,szBabylMessage.set_labelscCs6t|tƒr"||jkr2|j |¡ntdt|ƒƒ‚dS)z+Add label to list of labels on the message.zlabel must be a string: %sN)rurrmrÖrŠr‹©rryrrrr§0s

zBabylMessage.add_labelcCs*z|j |¡Wntk
r$YnXdS)z4Remove label from the list of labels on the message.N)rmr+rfr·rrrÚremove_label8szBabylMessage.remove_labelcCs
t|jƒS)z3Return a Message representation of visible headers.©rr¶rDrrrr?szBabylMessage.get_visiblecCst|ƒ|_dS)z2Set the Message representation of visible headers.Nr¹)rZvisiblerrrrpCszBabylMessage.set_visiblecCsb|j ¡D](}||kr*|j |||¡q
|j|=q
dD]$}||kr8||jkr8|||j|<q8dS)z9Update and/or sensibly generate a set of visible headers.)ZDateZFromzReply-ToZToZCCZSubjectN)r¶rGr¬)rÚheaderrrrÚupdate_visibleGs
zBabylMessage.update_visiblecCsrt|tƒr~t| ¡ƒ}d|kr*| d¡n| d¡| d¡d|ksNd|krX| d¡d|krj| d¡d	|kr|| d
¡nðt|tƒrØt| ¡ƒ}d|kr¨| d¡n
| d¡d	|krÄ| d
¡d|krÖ| d¡n–t|tƒrt| ¡ƒ}d|kr| d¡d|krn| d¡nTt|t	ƒrP| 
| ¡¡| ¡D]}| |¡q<nt|t
ƒr^ntdt|ƒƒ‚dS)z9Copy Babyl-specific state to message insofar as possible.rhr˜r›rkrlr¥rjrœriržrµrrŸr¡r£r¦N)rur	rZrnrÁr•r1rrIrrprr§rrŠr‹)rr&rvryrrrrƒRsH










ÿzBabylMessage._explain_to)N)r‘r’r“r”r…r rnrqr§r¸rrpr»rƒrrrrrs
c@seZdZdZdS)r
z&Message with MMDF-specific properties.Nr±rrrrr
|sc@s¨eZdZdZd&dd„Zd'dd„Zd(dd„Zd)d	d
„Zd*dd„Zd
d„Z	dd„Z
d+dd„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdd„Zd d!„Zd"d#„Zed$d%„ƒZdS),rÉzA read-only wrapper of a file.NcCs$||_|dkr| ¡|_n||_dS)zInitialize a _ProxyFile.N)rrÚ_pos)rrÅÚposrrrr ƒsz_ProxyFile.__init__cCs| ||jj¡S©zRead bytes.)Ú_readrrk©rÚsizerrrrk‹sz_ProxyFile.readcCs| ||jj¡Sr¾)r¿rÚread1rÀrrrrÂsz_ProxyFile.read1cCs| ||jj¡S)zRead a line.)r¿rrˆrÀrrrrˆ“sz_ProxyFile.readlinecCs<g}|D].}| |¡|dk	r|t|ƒ8}|dkrq8q|S)zRead multiple lines.Nr)rÖrÎ)rÚsizehintrUrrrrÚ	readlines—s
z_ProxyFile.readlinesccs| ¡}|sdS|VqdS)zIterate over lines.N)rˆ)rrrrrrL¢sz_ProxyFile.__iter__cCs|jS)zReturn the position.)r¼rDrrrrªsz_ProxyFile.tellrcCs4|dkr|j |j¡|j ||¡|j ¡|_dS)zChange position.rÒN©rr{r¼r©rÚoffsetÚwhencerrrr{®sz_ProxyFile.seekcCs0t|dƒr,zt|jdƒr"|j ¡W5|`XdS)zClose the file.rrcN)rXrrcrDrrrrcµs

z_ProxyFile.closecCs2|dkrd}|j |j¡||ƒ}|j ¡|_|S)z"Read size bytes using read_method.NrqrÅ)rrÁÚread_methodrUrrrr¿¾sz_ProxyFile._readcCs|S)z$Context management protocol support.rrDrrrÚ	__enter__Çsz_ProxyFile.__enter__cGs| ¡dSr,)rc)rÚexcrrrÚ__exit__Ësz_ProxyFile.__exit__cCs
|j ¡Sr,)rÚreadablerDrrrrÍÎsz_ProxyFile.readablecCs
|j ¡Sr,)rÚwritablerDrrrrÎÑsz_ProxyFile.writablecCs
|j ¡Sr,)rÚseekablerDrrrrÏÔsz_ProxyFile.seekablecCs
|j ¡Sr,)rr]rDrrrr]×sz_ProxyFile.flushcCs&t|dƒsdSt|jdƒsdS|jjS)NrTrFF)rXrrFrDrrrrFÚs

z_ProxyFile.closed)N)N)N)N)N)r)r‘r’r“r”r rkrÂrˆrÄrLrr{rcr¿rÊrÌrÍrÎrÏr]ÚpropertyrFrrrrrÉ€s&





		rÉc@s<eZdZdZddd„Zdd„Zddd	„Zd
d„Zdd
„ZdS)r/z&A read-only wrapper of part of a file.NcCst |||¡||_||_dS)zInitialize a _PartialFile.N)rÉr Ú_startÚ_stop)rrÅrrrrrr æsz_PartialFile.__init__cCst |¡|jS)z*Return the position with respect to start.)rÉrrÑrDrrrrìsz_PartialFile.tellrcCs<|dkr|j|_d}n|dkr*|j|_d}t |||¡dS)z8Change position, possibly with respect to start or stop.rrÒr÷N)rÑr¼rÒrÉr{rÆrrrr{ðsz_PartialFile.seekcCsB|j|j}|dkrdS|dks0|dks0||kr4|}t |||¡S)z;Read size bytes using read_method, honoring start and stop.rr&N)rÒr¼rÉr¿)rrÁrÉZ	remainingrrrr¿úsz_PartialFile._readcCst|dƒr|`dS)Nr)rXrrDrrrrcs
z_PartialFile.close)NN)r)	r‘r’r“r”r rr{r¿rcrrrrr/ãs


	r/Tc
Cs¦d}zbtrpzt |tjtjB¡WnJtk
rn}z,|jtjtjtjfkr\t	d|j
ƒ‚n‚W5d}~XYnX|rfzt|j
dƒ}| ¡WnBtk
rÒ}z$|jtjtjfkrÀWY¢WdS‚W5d}~XYnXz`zt
 |j
|j
d¡d}Wn2ttfk
r$t
 |j
|j
d¡d}YnXt
 |j
¡Wn0tk
rdt
 |j
¡t	d|j
ƒ‚YnXWn8tr„t |tj¡|ršt
 |j
d¡‚YnXdS)z(Lock file f using lockf and dot locking.Fzlockf: lock unavailable: %sNú.lockTzdot lock unavailable: %s)ÚfcntlÚlockfZLOCK_EXZLOCK_NBr´rµZEAGAINrrrr¦rrcrr°r±r²r³rcrör+ÚLOCK_UN)rÅrZdotlock_donerºZpre_lockrrrr

sLÿ
ÿr
cCs8trt |tj¡tj |jd¡r4t |jd¡dS)z*Unlock file f using lockf and dot locking.rÓN)rÔrÕrÖrrrœr¦r+©rÅrrrr4src	Cs<t |tjtjBtjBd¡}zt|dƒW¢St |¡XdS)zCCreate a file if it doesn't exist and open for reading and writing.rßrÿN)rrÀràrCÚO_RDWRrc)rÚfdrrrrõ;srõcCs$td|tt ¡ƒt ¡t ¡fƒS)zBCreate a temp file based on path and open for reading and writing.z%s.%s.%s.%s)rõrñrërïrðrrò)rrrrrCsþrcCs$| ¡ttdƒr t | ¡¡dS)z0Ensure changes to file f are physically on disk.ÚfsyncN)r]rXrrÚÚfilenor×rrrrIs
rcCst|ƒ| ¡dS)z:Close file f, ensuring all changes are physically on disk.N)rrcr×rrrr§Osr§c@seZdZdZdS)rz"Raised for module-specific errors.Nr±rrrrrUsc@seZdZdZdS)rz:The specified mailbox does not exist and won't be created.Nr±rrrrrXsc@seZdZdZdS)rz>The specified mailbox is not empty and deletion was requested.Nr±rrrrr[sc@seZdZdZdS)rz)Another process caused an action to fail.Nr±rrrrr^sc@seZdZdZdS)rz)A file appears to have an invalid format.Nr±rrrrras)T)0r”rrër®rïrµr‚r„r>Z
email.messageZemail.generatorrvr8rÔÚImportErrorÚ__all__r}rdrrrþr%rrrrr&rr	r1r
rrr
rÉr/r
rrõrrr§Ú	ExceptionrrrrrrrrrÚ<module>s‚
ýh8DB4-3z%mqH_c'
*