Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3.10/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3.10/__pycache__/mailbox.cpython-310.pyc
o

�*�g�3�@s>dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlZddl
mZzddlZWneyIdZYnwgd�Zej�d�ZGdd�d�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dejj�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�de�Z!Gd d!�d!e�Z"Gd"d#�d#e�Z#Gd$d%�d%�Z$Gd&d'�d'e$�Z%d?d)d*�Z&d+d,�Z'd-d.�Z(d/d0�Z)d1d2�Z*d3d4�Z+Gd5d6�d6e,�Z-Gd7d8�d8e-�Z.Gd9d:�d:e-�Z/Gd;d<�d<e-�Z0Gd=d>�d>e-�Z1dS)@zDRead/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes.�N)�GenericAlias)�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/�ZdDd0d1�Zd2d3�ZdDd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@Z"dEdAdB�Z#e$e%�Z&dS)Frz*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/lib/python3.10/mailbox.py�__init__%s
zMailbox.__init__cC�td��)�$Add message and return assigned key.�&Method must be implemented by subclass��NotImplementedError�r�messagerrr �add*�zMailbox.addcCr")�=Remove the keyed message; raise KeyError if it doesn't exist.r$r%�r�keyrrr �remove.r*zMailbox.removecCs|�|�dS�N)r.r,rrr �__delitem__2szMailbox.__delitem__cCs&z|�|�WdStyYdSw�z'If the keyed message exists, remove it.N)r.�KeyErrorr,rrr �discard5s
�zMailbox.discardcCr")�>Replace the keyed message; raise KeyError if it doesn't exist.r$r%�rr-r(rrr �__setitem__<r*zMailbox.__setitem__cCs$z|�|�WSty|YSw)z9Return the keyed message, or default if it doesn't exist.)�__getitem__r2)rr-�defaultrrr �get@s
�zMailbox.getcCsN|js|�|�St�|�|���
}|�|�Wd�S1s wYdS)z=Return the keyed message; raise KeyError if it doesn't exist.N)r�get_message�
contextlib�closing�get_file)rr-�filerrr r7Gs

$�zMailbox.__getitem__cCr")�4Return a Message representation or raise a KeyError.r$r%r,rrr r:Or*zMailbox.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_bytes�	as_stringr,rrr �
get_stringSszMailbox.get_stringcCr")z8Return a byte string representation or raise a KeyError.r$r%r,rrr rCZr*zMailbox.get_bytescCr")�6Return a file-like representation or raise a KeyError.r$r%r,rrr r=^r*zMailbox.get_filecCr")�Return an iterator over keys.r$r%�rrrr �iterkeysbr*zMailbox.iterkeyscC�t|���S)zReturn a list of keys.)�listrIrHrrr �keysf�zMailbox.keysc	cs:�|��D]}z||}Wn	tyYqw|VqdS)z%Return an iterator over all messages.N�rIr2�rr-�valuerrr �
itervaluesjs���zMailbox.itervaluescCs|��Sr/)rQrHrrr �__iter__sszMailbox.__iter__cCrJ)z,Return a list of messages. Memory intensive.)rKrQrHrrr �valuesvrMzMailbox.valuesc	cs>�|��D]}z||}Wn	tyYqw||fVqdS)z.Return an iterator over (key, message) tuples.NrNrOrrr �	iteritemszs���zMailbox.iteritemscCrJ)z9Return a list of (key, message) tuples. Memory intensive.)rKrTrHrrr �items�rMz
Mailbox.itemscCr")�9Return True if the keyed message exists, False otherwise.r$r%r,rrr �__contains__�r*zMailbox.__contains__cCr")�*Return a count of messages in the mailbox.r$r%rHrrr �__len__�r*zMailbox.__len__cCs|��D]}|�|�qdS)zDelete all messages.N)rLr3r,rrr �clear�s�z
Mailbox.clearcCs2z||}Wnty|YSw|�|�|S)z3Delete the keyed message and return it, or default.)r2r3)rr-r8�resultrrr �pop�s�
zMailbox.popcCs&|��D]
}||�|�fStd��)z6Delete an arbitrary (key, message) pair and return it.zNo messages in mailbox)rIr\r2r,rrr �popitem�szMailbox.popitemc	Cspt|d�r
|��}nt|d�r|��}n|}d}|D]\}}z|||<Wqty/d}Yqw|r6td��dS)z4Change the messages that correspond to certain keys.rTrUFTzNo message with key(s)N)�hasattrrTrUr2)r�arg�source�bad_keyr-r(rrr �update�s



��zMailbox.updatecCr")�&Write any pending changes to the disk.r$r%rHrrr �flush�r*z
Mailbox.flushcCr")�Lock the mailbox.r$r%rHrrr �lock�r*zMailbox.lockcCr")�#Unlock the mailbox if it is locked.r$r%rHrrr �unlock�r*zMailbox.unlockcCr")�Flush and close the mailbox.r$r%rHrrr �close�r*z
Mailbox.closecCs$z|�d�WStytd��w)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�r?t��}tj�||d�}|�|�|�	d�|�
�}|�dt�}|�
|�|jr;|�t�s=|�
t�d
Sd
Sd
St|tttjf�r�t|tj�rYt�dtd�|��}t|t�rc|�|�}|rk|�dd�}|�dt�}|�
|�|jr�|�t�s�|�
t�d
Sd
Sd
St|d�r�t|d�r�t�d	td�|j}d
}	|��}|�d�r�|d
d
�d}n
|�d�r�|d
d�d}|s�n|r�|�d�r�d|dd
�}|�dt�}|�
|�|}q�|jr�|r�|�t�s�|�
t�d
Sd
Sd
Sd
Stdt|���)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 insteadNT�
����
����From s>From ��Invalid message type: %s)�
isinstancerAr(r	�io�BytesIO�	generator�BytesGenerator�flatten�seekrr�replace�linesep�write�_append_newline�endswith�str�bytes�StringIO�warnings�warn�DeprecationWarning�getvaluernr^rs�readline�
startswith�	TypeError�type)	rr(�target�mangle_from_rs�gen�data�lastline�linerrr �
_dump_message�sf


��


�

�


��zMailbox._dump_message�NTr/�F)'�__name__�
__module__�__qualname__�__doc__r!r)r.r0r3r6r9r7r:rErCr=rIrLrQrRrSrTrUrWrYrZr\r]rbrdrfrhrjrnr�r��classmethodr�__class_getitem__rrrr r"sF

		
	

6rc@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�sE|r@t�|jd�|j�	�D]}t�|d�q6nt
|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�mkdirrSr�_toc�_toc_mtimes�
_last_read�_skewfactor)r�dirnamerrrrrr r!s ��

zMaildir.__init__c
Csf|��}z|�||�Wnty|��t�|j��wt|�t|t	�r;|�
�}|j|��}||jkr:d}nd}d}tj
�|j��|j�d}tj
�|j|||�}t|t	�rlt�|jtj
�|j�|��f�z'z	t�|j|�Wnttfy�t�|j|�YW|Swt�|j�W|Sty�}zt�|j�|jtjkr�td|���d}~ww)r#�r�rz$Name clash with existing message: %sN)�_create_tmpr��
BaseExceptionrjrr.�name�_sync_closer|r
�
get_subdir�colon�get_infor�basename�splitr�r�utime�getatime�get_date�link�AttributeError�PermissionError�rename�OSError�errno�EEXISTr)rr(�tmp_file�subdir�suffix�uniq�dest�errr r)$sR�

�
�
�����zMaildir.addcCs t�tj�|j|�|���dS�r+N)rr.rr�r�_lookupr,rrr r.Ns zMaildir.removec	Cs*z|�|�WdSttfyYdSwr1)r.r2�FileNotFoundErrorr,rrr r3Rs
�zMaildir.discardcCs�|�|�}|�|�}|�|�}t|t�r|}n|}tj�|�}|j|vr0|j|�|j�d}nd}|�	|�tj�
|j|�}	tj�
|j|||�}
t|t�r]t�|	tj�
|	�|��f�t�|	|
�dS)r4rxr�N)r�r)r|r
rrr�r�r�r3r�rr�r�r�r�)rr-r(�old_subpath�temp_key�temp_subpath�dominant_subpathr�r��tmp_path�new_pathrrr r6Zs$






�zMaildir.__setitem__cCs�|�|�}ttj�|j|�d��}|jr|�|�}nt|�}Wd�n1s(wYtj�|�\}}|�	|�|j
|vrJ|�|�|j
�d�|�tj�
tj�|j|���|S)r?�rbNrx)r��openrrr�rrr
r��
set_subdirr��set_info�set_date�getmtime)rr-�subpath�f�msgr�r�rrr r:us
��

zMaildir.get_messagecCsPttj�|j|�|��d��}|���td�Wd�S1s!wYdS)�2Return a bytes representation or raise a KeyError.r�roN)	r�rrr�rr�rrr�r��rr-r�rrr rC�s$�zMaildir.get_bytescCs$ttj�|j|�|��d�}t|�S)rFr�)r�rrr�rr��
_ProxyFiler�rrr r=�szMaildir.get_filec	csB�|��|jD]}z|�|�Wn	tyYqw|VqdS�rGN)�_refreshr�r�r2r,rrr rI�s�
��zMaildir.iterkeyscC�|��||jvS�rV)r�r�r,rrr rW��
zMaildir.__contains__cC�|��t|j�S�rX)r��lenr�rHrrr rY�r�zMaildir.__len__cC�dS)�"Write any pending changes to disk.NrrHrrr rd�sz
Maildir.flushcCr�)reNrrHrrr rf��zMaildir.lockcCr�)rgNrrHrrr rh�r�zMaildir.unlockcCr��riNrrHrrr rj�r�z
Maildir.closecCs\g}t�|j�D]#}t|�dkr+|ddkr+tj�tj�|j|��r+|�|dd��q|S)�Return a list of folder names.�r�.N)r�listdirrr�r�isdirr��append�rr[�entryrrr �list_folders�s��zMaildir.list_folderscCs ttj�|jd|�|jdd�S)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�|�s,t�t�|tj	tj
Bd��|S)z>Create a folder and return a Maildir instance representing it.r��r�
maildirfolder�)rrr�rrrr�rjr��O_CREAT�O_WRONLY)rr�rr[�maildirfolder_pathrrr �
add_folder�s�zMaildir.add_foldercCstj�|jd|�}t�tj�|d��t�tj�|d��D]}t|�dks,|ddkr2td|��qt�|�D]!}|dkrY|dkrY|dkrYtj�tj�||��rYtd||f��q8tj|d	d
�D]#\}}}|D]}t�	tj�||��qh|D]}t�
tj�||��qwqat�
|�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]}tj�|jd|�}|tj�|�dkr)t�|�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|vr|�dd�}d|vr|�dd�}dt|�t|dd�t��tj|f}tj	�
|jd|�}zt�|�Wn!t
yatjd7_zt|�WYSty^YnwYnwtd	|��)
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: %s)r�socket�gethostnamer��intr�getpidr�_countrr�r�statr��_create_carefully�FileExistsErrorr)rr�hostnamer�rrrr r��s0����zMaildir._create_tmpcCs�t��|jd|jkr/d}|jD]}tj�|j|�}||j|kr%d}||j|<q|s/dSi|_|jD]/}|j|}t�	|�D]"}tj�
||�}tj�|�rQqA|�|j
�d}tj�
||�|j|<qAq5t��|_dS)z!Update table of contents mapping.�FTNr)rr�r�r�rrr�r�r�r�r�r�r�r�)r�refreshr��mtimerr��pr�rrr r�s(


�zMaildir._refreshcCstztj�tj�|j|j|��r|j|WSWn	ty Ynw|��z|j|WSty9td|�d�w)z=Use TOC to return subpath for given key, or raise a KeyError.�No message with key: %sN)rrr�r�rr�r2r�r,rrr r�&s���zMaildir._lookupcCsLt|d�s
|��|_	z|t|j�WStyYdSty%Yq
w)z0Return the next message in a one-time iteration.�
_onetime_keysTN)r^rIr�next�
StopIterationr2rHrrr r4s

�zMaildir.nextr�)r�r�r�r�r�r!r)r.r3r6r:rCr=rIrWrYrdrfrhrjr�r�r�rr	rr�r�r�rrrrr rs8
*
	
$rc@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�}Wn7tyG}z+|jtjkr,|r't|jd�}nt|j��|jtjtj	fvr<t|jd�}n�WYd}~nd}~ww||_
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�rrr r!Ds(
��

z_singlefileMailbox.__init__cCs8|��|�|�|j|j<|jd7_d|_|jdS)r#r�T)r��_append_messager�r"r$r'rrr r)[s

z_singlefileMailbox.addcCs|�|�|j|=d|_dS)r+TN)r�r�r#r,rrr r.es

z_singlefileMailbox.removecCs$|�|�|�|�|j|<d|_dS)r4TN)r�r'r�r#r5rrr r6ks

z_singlefileMailbox.__setitem__ccs�|��|j��EdHdSr�)r�r�rLrHrrr rIqs�z_singlefileMailbox.iterkeyscCr�r�)r�r�r,rrr rWvr�z_singlefileMailbox.__contains__cCr�r�)r�r�r�rHrrr rY{r�z_singlefileMailbox.__len__cCs|js
t|j�d|_dSdS)reTN)r%�
_lock_filer!rHrrr rf��

�z_singlefileMailbox.lockcCs|jr
t|j�d|_dSdS�rgFN)r%�_unlock_filer!rHrrr rh�r)z_singlefileMailbox.unlockc
Cs�|js|jrt|j�d|_dS|jdusJ�|j�dd�|j��}||jkr1td|j|f��t	|j
�}zSi}|�|�t|j�
��D]=}|j|\}}|j�|�|�|�|��}	|j�td||j����}|son|�|�q^||��f||<|�|�qE|��|_Wn|��t�|j��t|�|j��t�|j
�j}	t�|j|	�z
t�|j|j
�Wnty�t�|j
�t�|j|j
�Ynwt|j
d�|_||_d|_d|_|jr�t|jdd	�dSdS)
r�FNrrz4Size of mailbox file changed (expected %i, found %i)T�r)�dotlock) r#r$�_sync_flushr!r�r��tellr&r�_create_temporaryr�_pre_mailbox_hook�sortedrL�_pre_message_hookrr�minr��_post_message_hookrjrr.r�r�r�st_mode�chmodr�rr�r%r()
r�cur_len�new_file�new_tocr-�start�stop�	new_startrs�moderrr rd�sj


�



�
�
��z_singlefileMailbox.flushcCr�)�,Called before writing the mailbox to file f.Nr�rr�rrr r1�r�z$_singlefileMailbox._pre_mailbox_hookcCr�)�-Called before writing each message to file f.Nrr@rrr r3�r�z$_singlefileMailbox._pre_message_hookcCr���,Called after writing each message to file f.Nrr@rrr r5�r�z%_singlefileMailbox._post_message_hookcCs�z#|��Wz|jr|��W|j��dSW|j��dS|j��wz|jr3|��W|j��wW|j��w|j��wr�)rdr%rhr!rjrHrrr rj�s

��
�z_singlefileMailbox.closecCsH|jdur	|��|dur"z|j|WSty!td|�d�wdS)z'Return (start, stop) or raise KeyError.Nr)r��
_generate_tocr2r,rrr r��s
��z_singlefileMailbox._lookupcCs�|j�dd�|j��}t|j�dkr|js|�|j�z|�|j�|�|�}|�	|j�Wnt
y=|j�|��w|j��|j��|_
|S)z;Append message to mailbox and return (start, stop) offsets.rr)r!r�r/r�r�r#r1r3�_install_messager5r��truncaterdr&)rr(�before�offsetsrrr r'�s

�
z"_singlefileMailbox._append_messager�r/)r�r�r�r�r!r)r.r6rIrWrYrfrhrdr1r3r5rjr�r'rrrr rAs$

@

rc@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?�rorzNr)r�r!r�r�r�r�rrr/�_message_factory�set_from�decode)rr-r;r<�	from_line�stringr�rrr r:	sz_mboxMMDF.get_messageFcCst�|�||��j|d�S)�3Return a string representation or raise a KeyError.)�unixfromr@)rr-�from_rrr rEs

��z_mboxMMDF.get_stringcCsJ|�|�\}}|j�|�|s|j��|j�||j���}|�td�S)rPro)r�r!r�r�rrr/r�r�)rr-rRr;r<rOrrr rCs
z_mboxMMDF.get_bytescCs<|�|�\}}|j�|�|s|j��t|j|j��|�S)rF)r�r!r�r��_PartialFiler/)rr-rRr;r<rrr r=!s

z_mboxMMDF.get_filecCsd}t|t�r|�|�}t|t�r3|�d�r3|�d�}|dkr.|d|�}||dd�}n*|}d}n%t|t�rD|���d�}d|}nt|t	j
j�rX|��}|durX|�d�}|durgdt
�t
�����}|j��}|j�|t�|�||j|j�|j��}||fS)	z1Format a message and blindly write to self._file.Nryrorxr�rJrsFrom MAILER-DAEMON )r|r�rnr�r��find�_mboxMMDFMessage�get_fromrkrAr(r	�get_unixfromr�asctime�gmtimer!r/r�r�r��
_mangle_from_)rr(rN�newline�authorr;r<rrr rE)s0







z_mboxMMDF._install_messageNr�)
r�r�r�r�rZr:rErCr=rErrrr rIs



	rIc@s2eZdZdZdZdZd
dd�Zdd�Zdd	�ZdS)rzA classic mbox mailbox.TNcC�t|_t�||||�dS)zInitialize an mbox mailbox.N)rrKrIr!rrrr r!O�z
mbox.__init__cCs|�t�dSrB�r�r�r@rrr r5T�zmbox._post_message_hookcCs�gg}}d}|j�d�	|j��}|j��}|�d�r>t|�t|�kr6|r1|�|tt��n|�|�|�|�d}n|sR|rL|�|tt��n|�|�n
|tkrYd}nd}qtt	t
||���|_t|j�|_|j��|_
dS)�0Generate key-to-(start, stop) table of contents.FrTryN)r!r�r/r�r�r�r�r��dict�	enumerate�zipr�r"r&)r�starts�stops�last_was_empty�line_posr�rrr rDXs2






�zmbox._generate_tocr�)	r�r�r�r�rZr�r!r5rDrrrr rFs
rc@s2eZdZdZddd�Zdd�Zdd	�Zd
d�ZdS)
rzAn MMDF mailbox.NTcCr])zInitialize an MMDF mailbox.N)rrKrIr!rrrr r!}r^z
MMDF.__init__cC�|�dt�dS)rA�Nr_r@rrr r3��zMMDF._pre_message_hookcCs|�tdt�dS)rCrjNr_r@rrr r5�szMMDF._post_message_hookcCs�gg}}|j�d�d}	|}|j��}|j��}|�dt�rM|�|�	|}|j��}|j��}|dtkrC|�|tt��n	|sK|�|�nq'n|sPnqtt	t
||���|_t|j�|_|j�dd�|j��|_
dS)rarTrjrN)r!r�r�r/r�r�r�r�rbrcrdr�r"r&)rrerf�next_posrhr�rrr rD�s8






��
�zMMDF._generate_tocr�)r�r�r�r�r!r3r5rDrrrr rzs
rc@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�s5|r0t�|jd�t�t�tj�	|jd�tj
tjBtjBd��nt
|j��d|_dS)zInitialize an MH instance.r��
.mh_sequencesi�FN)rr!rrr�rr�rjr�r�r��O_EXCLr�rr%rrrr r!�s�

zMH.__init__cCs�|��}t|�dkr
d}nt|�d}tj�|jt|��}t|�}d}zQ|j	r+t
|�z7z|�||�WntyN|j	rBt
|�t|�d}t�|��wt|t�rZ|�||�W|j	rbt
|�n	|j	rkt
|�wwW|sst|�|S|s|t|�ww)r#rr�FT)rLr��maxrrr�rr�rr%r(r�r�r+r�r.r|r�_dump_sequences)rr(rL�new_keyr�r��closedrrr r)�sJ
�
���
���
�zMH.addc
Csltj�|jt|��}zt|d�}Wnty*}z
|jtjkr%t	d|���d}~ww|�
�t�|�dS)r+rrN)rrr�rr�r�r�r�rr2rjr.)rr-rr�r�rrr r.�s��z	MH.removec
Cs�tj�|jt|��}zt|d�}Wnty*}z
|jtjkr%t	d|���d}~wwz?|j
r3t|�z't�t�|tj
tjB��|�||�t|t�rR|�||�W|j
rZt|�n	|j
rct|�wwWt|�dSt|�w)r4rrN)rrr�rr�r�r�r�rr2r%r(rjr��O_TRUNCr�r|rrpr+r�)rr-r(rr�r�rrr r6�s4��
���
��zMH.__setitem__c
Csz |jrttj�|jt|��d�}n
ttj�|jt|��d�}Wnty9}z
|jtj	kr4t
d|���d}~ww|�&|jrDt|�z
t|�}W|jrQt
|�n	|jrZt
|�wwWd�n1sewY|����D]
\}}||vr}|�|�qp|S)r?rr�rN)r%r�rrr�rr�r�r�rr2r(rr+�
get_sequencesrU�add_sequence)rr-r�r�r�r��key_listrrr r:�s:���
��
���
�zMH.get_messagec
Cs�z |jrttj�|jt|��d�}n
ttj�|jt|��d�}Wnty9}z
|jtj	kr4t
d|���d}~ww|�)|jrDt|�z|���
td�W|jrTt|�Wd�S|jrdt|�ww1shwYdS)r�rr�rNro)r%r�rrr�rr�r�r�rr2r(rrr�r�r+�rr-r�r�rrr rCs.����
��zMH.get_bytesc
CsXzttj�|jt|��d�}Wt
|�Sty+}z
|jtjkr&t	d|���d}~ww)rFr�rN)r�rrr�rr�r�r�rr2r�rwrrr r=,s���zMH.get_filecCsttdd�t�|j�D���S)rGcss �|]}|��rt|�VqdSr/)�isdigitr
)�.0r�rrr �	<genexpr>9s��zMH.iterkeys.<locals>.<genexpr>)�iterr2rr�rrHrrr rI7szMH.iterkeyscCstj�tj�|jt|���Sr�)rrr�r�rr�r,rrr rW<szMH.__contains__cCstt|����Sr�)r�rKrIrHrrr rY@�z
MH.__len__cCs6|jsttj�|jd�d�|_t|j�d|_dSdS)rermrTN)r%r�rrr�rr!r(rHrrr rfDs


�zMH.lockcCs,|jrt|j�t|j�|`d|_dSdSr*)r%r+r!r�rHrrr rhKs


�z	MH.unlockcCr�)rcNrrHrrr rdSr�zMH.flushcCs|jr	|��dSdSr�)r%rhrHrrr rjWs�zMH.closecCs<g}t�|j�D]}tj�tj�|j|��r|�|�q|S)r�)rr�rrr�r�r�r�rrr r�\s
�zMH.list_folderscCsttj�|j|�|jdd�S)z+Return an MH instance for the named folder.Fr��rrrr�rrr�rrr r�ds�z
MH.get_foldercCsttj�|j|�|jd�S)z:Create a folder and return an MH instance representing it.r�r}r�rrr r�is�z
MH.add_foldercCs`tj�|j|�}t�|�}|dgkrt�tj�|d��n|gkr"ntd|j��t�|�dS)r�rmzFolder not empty: %sN)rrr�rr�r.rr)rr�r�entriesrrr rns

zMH.remove_folderc

si}ttj�|jd�ddd��p}t|����|D]^}zM|�d�\}}t�}|��D]$}|��r7|�	t
|��q)dd�|�d�D�\}}	|�t||	d	��q)�fd
d�t
|�D�||<t||�dkrf||=Wqtyvtd
|����wWd�|S1s�wY|S)z=Return a name-to-key-list dictionary to define each sequence.rm�r�ASCII��encodingr�css�|]}t|�VqdSr/)r
)ry�xrrr rz���z#MH.get_sequences.<locals>.<genexpr>�-r�csg|]}|�vr|�qSrr)ryr-��all_keysrr �
<listcomp>�s�z$MH.get_sequences.<locals>.<listcomp>rz"Invalid sequence specification: %sN)r�rrr�r�setrLr�rxr)r
rb�ranger2r�rmr�rstrip)
r�resultsr�r�r��contentsrL�specr;r<rr�r rtzs4����
��zMH.get_sequencescCsttj�|jd�ddd�}zqt�t�|jtjtjB��|�	�D]W\}}t
|�dkr+q |�|d�d}d}tt
|��D])}|d	|krN|sMd
}|�d�n|r\d}|�d||f�n|�d
|�|}q<|rr|�t|�d�q |�d�q Wt|�dSt|�w)z:Set sequences using the given name-to-key-list dictionary.rmzr+r�r�rr�NFr�Tr�z%s %sz %s�
)r�rrr�rrjr�r�rsrUr�r�r2r�r�r�)r�	sequencesr�r�rL�prev�
completingr-rrr �
set_sequences�s2
��zMH.set_sequencesc	
Cs8|��}d}g}|��D]`}|d|krh|�||df�zt�tj�|jt|��tj�|jt|d���Wn#t	t
fyZt�tj�|jt|��tj�|jt|d���Ynwt�tj�|jt|���|d7}q|d|_
t|�dkrzdS|��D]\}}|D]\}}||vr�|||�|�<q�q~|�|�dS)z?Re-name messages to eliminate numbering gaps. Invalidates keys.rr�N)rtrIr�rr�rr�rr�r�r�r��unlinkr"r�rU�indexr�)	rr�r��changesr-r�rv�oldr�rrr �pack�s6���

��zMH.packcCst|��}|��}|��D]\}}||vr|�|�q||vr$||�|�=q|D]}||vr2|g||<q'|�|�dS)z;Inspect a new MHMessage and update sequences appropriately.N)rtrUr�r�r�)rr(r-�pending_sequences�
all_sequencesr�rv�sequencerrr rp�s�
�zMH._dump_sequencesr�)r�r�r�r�r!r)r.r6r:rCr=rIrWrYrfrhrdrjr�r�r�rrtr�r�rprrrr r�s0
"rc@s�eZdZdZehd��Zddd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�ZdS) rzAn Rmail-style Babyl mailbox.>�filed�edited�resent�unseen�deleted�answered�	forwardedNTcCst�||||�i|_dS)zInitialize a Babyl mailbox.N)rr!�_labelsrrrr r!�s
zBabyl.__init__cCs(t�||�}t|t�r|��|j|<|S)r#)rr)r|r
�
get_labelsr�)rr(r-rrr r)�s
z	Babyl.addcCs&t�||�||jvr|j|=dSdSr�)rr.r�r,rrr r.�s
�zBabyl.removecCs.t�|||�t|t�r|��|j|<dSdS)r4N)rr6r|r
r�r�r5rrr r6�s
�zBabyl.__setitem__c
Cs|�|�\}}|j�|�|j��t��}	|j��}|dtks$|s%n
|�|�td��qt��}	|j��}|tks?|s@n
|�|�td��q4||j�	�}|dksWJ�|j�
|�}|�td�}t|��|�}	|	�
|���||jvr|	�|j|�|	S)r?T�*** EOOH ***ror)r�r!r�r�r}r~r�r�r�r/rrr
r��set_visibler��
set_labels)
rr-r;r<�original_headersr��visible_headers�n�bodyr�rrr r:�s4

�
�
zBabyl.get_messagec	Cs�|�|�\}}|j�|�|j��t��}	|j��}|dtks$|s%n
|�|�td��q	|j��}|tks;|s<nq0|�	�}||j�
�}|dksNJ�|j�|�}|�td�}||S)rPTr�ror)r�r!r�r�r}r~r�r�r�r�r/rr)	rr-r;r<r�r��headersr�r�rrr rCs*

�
�zBabyl.get_bytescCst�|�|��dt��S)rFro)r}r~rCr�r�r,rrr r=(�zBabyl.get_filecCs<|��t�}|j��D]}|�|�q|�|j�t|�S)z4Return a list of user-defined labels in the mailbox.)r�r�r�rSrb�difference_update�_special_labelsrK)r�labels�
label_listrrr r�,szBabyl.get_labelscCs<gg}}|j�d�d}g}	|}|j��}|j��}|dtkrOt|�t|�kr3|�|tt��|�|�dd�|j��dd��d�D�}|�|�n(|d	ksY|d	tkrkt|�t|�krj|�|tt��n|sw|�|tt��nqtt	t
||���|_tt	|��|_t|j�|_
|j�dd
�|j��|_dS)rarTscSsg|]
}|��r|���qSr)�strip�ry�labelrrr r�Cs�z'Babyl._generate_toc.<locals>.<listcomp>r�N�,�r)r!r�r�r/r�r�r�r�rbrcrdr�r�r"r&)rrerfrl�label_listsrhr�r�rrr rD5s:



���zBabyl._generate_toccCsVdt}|dt7}|��}dd�|D�}|dd�|�t7}|d7}|�|�dS)	r?sBABYL OPTIONS:s
Version: 5css�|]}|��VqdSr/)rkr�rrr rzXr�z*Babyl._pre_mailbox_hook.<locals>.<genexpr>sLabels:r�r�N)r�r�r�r�)rr��babylr�rrr r1SszBabyl._pre_mailbox_hookcCri)rA�Nr_r@rrr r3]rkzBabyl._pre_message_hookcCs|�td�dS)rCr�Nr_r@rrr r5arkzBabyl._post_message_hookcCs`|j��}t|t�rXg}g}|��D]}||jvr|�|�q|�|�q|j�d�|D]}|j�d|���q-|j�d�|D]}|j�d|��d�qB|j�t	�n|j�dt	�t|t
jj�r�t
��}t
j�|dd�}|�|�|�d�	|��}|j�|�d
t	��|d
ks�|s�nq~|j�dt	�t|t�r�t
��}	t
j�|	dd�}
|
�|���	|	��}|j�|�d
t	��|d
ks�|s�nq�n|�d�	|��}|j�|�d
t	��|d
ks�|s�nq�	|�d�}|s�n|j�|�d
t	��q�n)t|ttt
jf��r{t|t
j��rt�d
td�|��}t|t��r%|�|�}|�d�d}|ddk�rf|j�|d|��d
t	��|j�dt	�|j�|d|��d
t	��|j�||d��d
t	��n�|j�dt	t	�|j�|�d
t	��n�t |d��rt |d��r�t�dtd�|j!}|��}
d	}	|��}|�"d��r�|dd�d
}n|�"d��r�|dd�d
}|j�|�d
t	��|d
k�s�|�s�|�r�d}|j�dt	�|�|
�nn�q�	|��}|�s�n4|�"d��r�|dd�t	}n|�"d��r|dd�t	}n|�"d
��r|dd�t	}|j�|��q�nt#dt$|���|j��}||fS)z0Write message contents and return (start, stop).�1s, s,,� r�s1,,FrTror�r,rprqs

rrxNr�rsrtrurvrwr{)%r!r/r|r
r�r�r�r�rkr�rAr(r	r}r~rr�r�r�r�r��get_visiblerrr�r�r�r�r�r�r�rnrTr^rsr�r�r�)rr(r;�special_labelsr�r��orig_buffer�orig_generatorr��
vis_buffer�
vis_generatorrs�
body_start�original_pos�
first_passr<rrr rEes�




�
�
�
��
���

zBabyl._install_messager�)r�r�r�r��	frozensetr�r!r)r.r6r:rCr=r�rDr1r3r5rErrrr r�s 
	
rc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
r	z0Message with mailbox-format-specific properties.NcCs�t|tjj�r|�t�|��t|t�r|�|�dSdSt|t�r,|�t�	|��dSt|t
�r;|�t�|��dSt|tj
�rK|�t�|��dSt|d�rZ|�t�|��dS|durgtjj�|�dStdt|���)zInitialize a Message instance.rrNr{)r|rAr(r	�_become_message�copy�deepcopy�_explain_tor�rBr��message_from_stringr}�
TextIOWrapper�message_from_filer^�message_from_binary_filer!r�r�r'rrr r!�s 
�


zMessage.__init__cCs4t|dg�}|jD]}||vr|j||j|<q	dS)z0Assume the non-format-specific state of message.�_type_specific_attributesN)�getattr�__dict__)rr(�
type_specificr�rrr r��s
��zMessage._become_messagecCst|t�rdStd��)z:Copy format-specific state to message insofar as possible.Nz Cannot convert to specified type)r|r	r�r'rrr r��s
zMessage._explain_tor/)r�r�r�r�r!r�r�rrrr r	�s

r	c@szeZdZdZgd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�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�rr�r	r!r'rrr r!�s
zMaildirMessage.__init__cC�|jS)zReturn 'new' or 'cur'.)r�rHrrr r��zMaildirMessage.get_subdircCs&|dks|dkr
||_dStd|��)zSet subdir to 'new' or 'cur'.r�r�z!subdir must be 'new' or 'cur': %sN)r�rm)rr�rrr r�s
zMaildirMessage.set_subdircCs|j�d�r
|jdd�SdS)�*Return as a string the flags that are set.�2,rNr�)r�r�rHrrr �	get_flags
szMaildirMessage.get_flagscCsdd�t|��|_dS)�)Set the given flags and unset all others.r�r�N)r�r2r�)r�flagsrrr �	set_flagsr�zMaildirMessage.set_flagscC�$|�d�t|���t|�B��dS�z.Set the given flag(s) without changing others.r�N�r�r�r�r��r�flagrrr �add_flag�$zMaildirMessage.add_flagcCs0|��r|�d�t|���t|���dSdS)�7Unset the given string flag(s) without changing others.r�N)r�r�r�r�r�rrr �remove_flags$�zMaildirMessage.remove_flagcCr�)z<Return delivery date of message, in seconds since the epoch.)r�rHrrr r�!r�zMaildirMessage.get_datecCs.zt|�|_WdStytd|�d�w)z9Set delivery date of message, in seconds since the epoch.zcan't convert to float: %sN)�floatr�rmr�)r�daterrr r�%s
�zMaildirMessage.set_datecCr�)z%Get the message's "info" as a string.)r�rHrrr r�,r�zMaildirMessage.get_infocCs$t|t�r
||_dStdt|���)z Set the message's "info" string.zinfo must be a string: %sN)r|r�r�r�r�)r�inforrr r�0s

zMaildirMessage.set_infocCs�t|t�r|�|���|�|���|�|���dSt|t�rct	|���}d|vr0|�
d�|��dkr;|�
d�d|vrD|�
d�d|vrM|�
d�d|vrV|�
d�|�d	t�
|����dSt|t�r�t	|���}d|vrw|�d
�d|vr�|�d�d|vr�|�d�dSdSt|t�r�t	|���}d|vr�|�d
�d|vr�|�d
�d|vr�|�d�d|vr�|�d�dSdSt|t�r�dStdt|���)z;Copy Maildir-specific state to message insofar as possible.�S�Rr��O�T�D�F�A�
MAILER-DAEMONr��replied�flaggedr�r��Pr��$Cannot convert to specified type: %sN)r|r
r�r�r�r�r�r�rUr�r�rLrrYrrur
�	add_labelr	r�r�)rr(r�rrr r�7sT









�



�
�zMaildirMessage._explain_tor/)r�r�r�r�r�r!r�r�r�r�r�r�r�r�r�r�r�rrrr r
�s
r
c@sZeZdZdZdgZddd�Zdd�Zddd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)rUz/Message with mbox- or MMDF-specific properties.�_fromNcCsV|�dd�t|tjj�r#|��}|dur#|�d�r#|�|dd��t�||�dS)z'Initialize an mboxMMDFMessage instance.r�TNzFrom rz)rLr|rAr(r	rWr�r!)rr(rQrrr r!hsz_mboxMMDFMessage.__init__cCr�)z Return contents of "From " line.)r�rHrrr rVqr�z_mboxMMDFMessage.get_fromcCs4|dur|durt��}|dt�|�7}||_dS)z>Set "From " line, formatting and appending time_ if specified.NT� )rrYrXr�)rrR�time_rrr rLus

z_mboxMMDFMessage.set_fromcCs|�dd�|�dd�S)r��Statusr��X-Status)r9rHrrr r�}r�z_mboxMMDFMessage.get_flagscCs�t|�}d\}}dD]}||vr||7}|�|�q
dD]}||vr+||7}|�|�q|d�t|��7}z|�d|�WntyL|�d|�Ynwz	|�d|�WdStyf|�d|�YdSw)r�)r�r�)r�r�)r�r�r�r�r�r�N)r�r.r�r2�replace_headerr2�
add_header)rr��status_flags�
xstatus_flagsr�rrr r��s.
�
���z_mboxMMDFMessage.set_flagscCr�r�r�r�rrr r��r�z_mboxMMDFMessage.add_flagcCs8d|vsd|vr|�d�t|���t|���dSdS)r�r�r�r�Nr�r�rrr r��s$�z_mboxMMDFMessage.remove_flagc	Cs�t|t�rgt|���}d|vr|�d�d|vr|�d�d|vr&|�d�d|vr/|�d�d|vr8|�d�|d	=|d
=d�|����dd
��}z|�	t
�t�
|d���Wd
SttfyfYd
Swt|t�r||�|���|�|���d
St|t�r�t|���}d|vr�|�d�d|vr�|�d�d|vr�|�d�|d	=|d
=d
St|t�r�t|���}d|vr�|�d�d|vr�|�d�d|vr�|�d�|d	=|d
=d
St|t�r�d
Stdt|���)zACopy mbox- or MMDF-specific state to message insofar as possible.r�r�r�r�r�r�r�r��statuszx-statusr����Nz%a %b %d %H:%M:%S %Yr�r�r�r�r�r�)r|r
r�r�r�r�r�rVr�r��calendar�timegmr�strptimerm�
OverflowErrorrUr�rLrrur
r�r	r�r�)rr(r��
maybe_daterrr r��sd





��











�z_mboxMMDFMessage._explain_tor/)
r�r�r�r�r�r!rVrLr�r�r�r�r�rrrr rUcs
	
rUc@�eZdZdZdS)rz&Message with mbox-specific properties.N�r�r�r�r�rrrr r��rc@sHeZdZdZdgZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)rz$Message with MH-specific properties.�
_sequencesNcCsg|_t�||�dS)z!Initialize an MHMessage instance.N)r	r	r!r'rrr r!�szMHMessage.__init__cC�|jdd�S)z4Return a list of sequences that include the message.N)r	rHrrr rt�r`zMHMessage.get_sequencescC�t|�|_dS)z3Set the list of sequences that include the message.N)rKr	)rr�rrr r��r`zMHMessage.set_sequencescC�8t|t�r||jvr|j�|�dSdStdt|���)z8Add sequence to list of sequences including the message.zsequence type must be str: %sN)r|r�r	r�r�r��rr�rrr ru��


�zMHMessage.add_sequencecC�(z	|j�|�WdStyYdSw)zARemove sequence from the list of sequences including the message.N)r	r.rmr
rrr �remove_sequence��
�zMHMessage.remove_sequencecCsPt|t�r5t|���}d|vr|�d�n
|�d�|�d�d|vr(|�d�d|vr3|�d�d
Sd
St|t�ret|���}d|vrJ|�d�n|�d	�d|vrX|�d�d|vrc|�d
�d
Sd
St|t�rx|��D]}|�|�qnd
St|t	�r�t|���}d|vr�|�
d�d|vr�|�
d�d
Sd
St|t�r�d
Stdt
|���)z6Copy MH-specific state to message insofar as possible.r�r�r�r�r�r�r��ROr�r�r�r�N)r|r
r�rtr�r�rUrrur
r�r	r�r�)rr(r�r�rrr r��sJ



�


�
�

�
�zMHMessage._explain_tor/)r�r�r�r�r�r!rtr�rurr�rrrr r�s
rc@sbeZdZdZddgZddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)r
z'Message with Babyl-specific properties.r��_visibleNcCsg|_t�|_t�||�dS)z#Initialize a BabylMessage instance.N)r�r	rr!r'rrr r!%szBabylMessage.__init__cCr
)z'Return a list of labels on the message.N)r�rHrrr r�+r`zBabylMessage.get_labelscCr)z&Set the list of labels on the message.N)rKr�)rr�rrr r�/r`zBabylMessage.set_labelscCr)z+Add label to list of labels on the message.zlabel must be a string: %sN)r|r�r�r�r�r��rr�rrr r�3rzBabylMessage.add_labelcCr)z4Remove label from the list of labels on the message.N)r�r.rmrrrr �remove_label;rzBabylMessage.remove_labelcCs
t|j�S)z3Return a Message representation of visible headers.�r	rrHrrr r�Bs
zBabylMessage.get_visiblecCr)z2Set the Message representation of visible headers.Nr)r�visiblerrr r�Fr`zBabylMessage.set_visiblecCsb|j��D]}||vr|j�|||�q|j|=qdD]}||vr.||jvr.|||j|<qdS)z9Update and/or sensibly generate a set of visible headers.)�Date�FromzReply-To�To�CC�SubjectN)rrLr�)r�headerrrr �update_visibleJs
��zBabylMessage.update_visiblecCsxt|t�rBt|���}d|vr|�d�n
|�d�|�d�d|vs'd|vr,|�d�d|vr5|�d�d	|vr@|�d
�dSdSt|t�rrt|���}d|vrW|�d�n|�d�d	|vre|�d
�d|vrp|�d�dSdSt|t�r�t|���}d|vr�|�d�d|vr�|�d�dSdSt|t	�r�|�
|���|��D]}|�|�q�dSt|t
�r�dStdt|���)z9Copy Babyl-specific state to message insofar as possible.r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�N)r|r
r�r�r�r�rUrrur
r�r�r�r	r�r�)rr(r�r�rrr r�UsP




�


�

�
�
�zBabylMessage._explain_tor/)r�r�r�r�r�r!r�r�r�rr�r�rr�rrrr r
 s
r
c@r)rz&Message with MMDF-specific properties.Nrrrrr rrrc@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%��Zee�ZdS)(r�zA read-only wrapper of a file.NcCs&||_|dur|��|_dS||_dS)zInitialize a _ProxyFile.N)r!r/�_pos)rr��posrrr r!�s
z_ProxyFile.__init__cC�|�||jj�S�zRead bytes.)�_readr!rr�r�sizerrr rr�r|z_ProxyFile.readcCr!r")r#r!�read1r$rrr r&�r|z_ProxyFile.read1cCr!)zRead a line.)r#r!r�r$rrr r��r|z_ProxyFile.readlinecCs>g}|D]}|�|�|dur|t|�8}|dkr|Sq|S)zRead multiple lines.Nr)r�r�)r�sizehintr[r�rrr �	readlines�s
�z_ProxyFile.readlinesccs�	|��}|s
dS|Vq)zIterate over lines.TN)r�)rr�rrr rR�s��z_ProxyFile.__iter__cCr�)zReturn the position.)rrHrrr r/�r�z_ProxyFile.tellrcCs4|dkr|j�|j�|j�||�|j��|_dS)zChange position.r�N�r!r�rr/�r�offset�whencerrr r��sz_ProxyFile.seekcCs@t|d�rzt|jd�r|j��W|`dSW|`dS|`wdS)zClose the file.r!rjN)r^r!rjrHrrr rj�s
��z_ProxyFile.closecCs2|durd}|j�|j�||�}|j��|_|S)z"Read size bytes using read_method.Nrxr))rr%�read_methodr[rrr r#�sz_ProxyFile._readcCs|S)z$Context management protocol support.rrHrrr �	__enter__�r�z_ProxyFile.__enter__cGs|��dSr/)rj)r�excrrr �__exit__�sz_ProxyFile.__exit__cC�
|j��Sr/)r!�readablerHrrr r2��
z_ProxyFile.readablecCr1r/)r!�writablerHrrr r4�r3z_ProxyFile.writablecCr1r/)r!�seekablerHrrr r5�r3z_ProxyFile.seekablecCr1r/)r!rdrHrrr rd�r3z_ProxyFile.flushcCs&t|d�sdSt|jd�sdS|jjS)Nr!TrrF)r^r!rrrHrrr rr�s

z_ProxyFile.closedr/�r)r�r�r�r�r!rrr&r�r(rRr/r�rjr#r.r0r2r4r5rd�propertyrrr�rr�rrrr r��s*





		
r�c@s<eZdZdZddd�Zdd�Zddd	�Zd
d�Zdd
�ZdS)rSz&A read-only wrapper of part of a file.NcCst�|||�||_||_dS)zInitialize a _PartialFile.N)r�r!�_start�_stop)rr�r;r<rrr r!�s
z_PartialFile.__init__cCst�|�|jS)z*Return the position with respect to start.)r�r/r8rHrrr r/�r|z_PartialFile.tellrcCs<|dkr|j|_d}n
|dkr|j|_d}t�|||�dS)z8Change position, possibly with respect to start or stop.rr�rN)r8rr9r�r�r*rrr r��sz_PartialFile.seekcCsB|j|j}|dkrdS|dus|dks||kr|}t�|||�S)z;Read size bytes using read_method, honoring start and stop.rrJN)r9rr�r#)rr%r-�	remainingrrr r#�sz_PartialFile._readcCst|d�r	|`dSdS)Nr!)r^r!rHrrr rjs
�z_PartialFile.close)NNr6)	r�r�r�r�r!r/r�r#rjrrrr rS�s


	rSTc
Cs�d}z�tr1zt�|tjtjB�Wnty0}z|jtjtjtjfvr+t	d|j
���d}~ww|r�z
t|j
d�}|��Wnty^}z|jtjtjfvrYWYd}~WdS�d}~wwz4zt
�|j
|j
d�d}Wnttfy�t
�|j
|j
d�d}Ynwt
�|j
�WWdSWWdSty�t
�|j
�t	d|j
��wWdStr�t�|tj�|r�t
�|j
d��)z(Lock file f using lockf and dot locking.Fzlockf: lock unavailable: %sN�.lockTzdot lock unavailable: %s)�fcntl�lockf�LOCK_EX�LOCK_NBr�r��EAGAINrr rr�r0rjrr�r�r�r�r�rr.�LOCK_UN)r�r-�dotlock_doner��pre_lockrrr r(s\����������r(cCs<tr	t�|tj�tj�|jd�rt�|jd�dSdS)z*Unlock file f using lockf and dot locking.r;N)r<r=rArrr�r�r.�r�rrr r+9s
�r+c	Cs@t�|tjtjBtjBd�}zt|d�Wt�|�St�|�w)zCCreate a file if it doesn't exist and open for reading and writing.r�r)rr�r�rn�O_RDWRrj)r�fdrrr r@s
rcCs$td|tt���t��t��f�S)zBCreate a temp file based on path and open for reading and writing.z%s.%s.%s.%s)rr
rrrrr)rrrr r0Hs�r0cCs(|��ttd�rt�|���dSdS)z0Ensure changes to file f are physically on disk.�fsyncN)rdr^rrG�filenorDrrr r.Ns
�r.cCst|�|��dS)z:Close file f, ensuring all changes are physically on disk.N)r.rjrDrrr r�Tsr�c@r)rz"Raised for module-specific errors.Nrrrrr rZrrc@r)rz:The specified mailbox does not exist and won't be created.Nrrrrr r]rrc@r)rz>The specified mailbox is not empty and deletion was requested.Nrrrrr r`rrc@r)rz)Another process caused an action to fail.Nrrrrr rcrrc@r)rz)A file appears to have an invalid format.Nrrrrr rfrr)T)2r�rrrrr�r�r�rA�
email.message�email.generatorr}r;�typesrr<�ImportError�__all__r�rkrrrrIrrrrr(r	r
rUrrr
rr�rSr(r+rr0r.r��	Exceptionrrrrrrrrr �<module>sp�j8DB4-3z%mqH_e
'*

Spamworldpro Mini