AlkantarClanX12

Your IP : 3.147.86.143


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/mailbox.cpython-310.opt-2.pyc

o

6��f�3�@s<	ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
Z
ddlZddlm
Z
zddlZWneyHdZYnwgd�Zej�d�ZGdd�d�ZGdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dejj�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd �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.d/�Z(d0d1�Z)d2d3�Z*Gd4d5�d5e+�Z,Gd6d7�d7e,�Z-Gd8d9�d9e,�Z.Gd:d;�d;e,�Z/Gd<d=�d=e,�Z0dS)?�N)�GenericAlias)�Mailbox�Maildir�mbox�MH�Babyl�MMDF�Message�MaildirMessage�mboxMessage�	MHMessage�BabylMessage�MMDFMessage�Error�NoSuchMailboxError�
NotEmptyError�ExternalClashError�FormatError�asciic@seZdZ	dBdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�ZdCdd�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.�ZdCd/d0�Zd1d2�ZdCd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?Z!dDd@dA�Z"e#e$�Z%dS)ErNTcCs"	tj�tj�|��|_||_dS�N)�os�path�abspath�
expanduser�_path�_factory��selfr�factory�create�r �./opt/alt/python310/lib64/python3.10/mailbox.py�__init__%s
zMailbox.__init__cC�
	td���Nz&Method must be implemented by subclass��NotImplementedError�r�messager r r!�add*�zMailbox.addcCr#r$r%�r�keyr r r!�remove.r*zMailbox.removecCs|�|�dSr)r-r+r r r!�__delitem__2szMailbox.__delitem__cCs(	z|�|�WdStyYdSwr)r-�KeyErrorr+r r r!�discard5s�zMailbox.discardcCr#r$r%�rr,r(r r r!�__setitem__<r*zMailbox.__setitem__cCs&	z|�|�WSty|YSwr)�__getitem__r/)rr,�defaultr r r!�get@s�zMailbox.getcCsP	|js	|�|�St�|�|���
}|�|�Wd�S1s!wYdSr)r�get_message�
contextlib�closing�get_file)rr,�filer r r!r3Gs
$�zMailbox.__getitem__cCr#r$r%r+r r r!r6Or*zMailbox.get_messagecCs	t�|�|����Sr��email�message_from_bytes�	get_bytesZ	as_stringr+r r r!�
get_stringSszMailbox.get_stringcCr#r$r%r+r r r!r>Zr*zMailbox.get_bytescCr#r$r%r+r r r!r9^r*zMailbox.get_filecCr#r$r%�rr r r!�iterkeysbr*zMailbox.iterkeyscC�	t|���Sr)�listrAr@r r r!�keysf�zMailbox.keysc	cs<�	|��D]}z||}Wn	tyYqw|VqdSr�rAr/�rr,�valuer r r!�
itervaluesjs���zMailbox.itervaluescCs|��Sr)rIr@r r r!�__iter__sszMailbox.__iter__cCrBr)rCrIr@r r r!�valuesvrEzMailbox.valuesc	cs@�	|��D]}z||}Wn	tyYqw||fVqdSrrFrGr r r!�	iteritemszs���zMailbox.iteritemscCrBr)rCrLr@r r r!�items�rEz
Mailbox.itemscCr#r$r%r+r r r!�__contains__�r*zMailbox.__contains__cCr#r$r%r@r r r!�__len__�r*zMailbox.__len__cCs	|��D]}|�|�qdSr)rDr0r+r r r!�clear�s�z
Mailbox.clearcCs4	z||}Wnty|YSw|�|�|Sr)r/r0)rr,r4�resultr r r!�pop�s�
zMailbox.popcCs(	|��D]
}||�|�fStd��)NzNo messages in mailbox)rArRr/r+r r r!�popitem�szMailbox.popitemc	Csr	t|d�r|��}nt|d�r|��}n|}d}|D]\}}z|||<Wqty0d}Yqw|r7td��dS)NrLrMFTzNo message with key(s))�hasattrrLrMr/)r�arg�sourceZbad_keyr,r(r r r!�update�s 



��zMailbox.updatecCr#r$r%r@r r r!�flush�r*z
Mailbox.flushcCr#r$r%r@r r r!�lock�r*zMailbox.lockcCr#r$r%r@r r r!�unlock�r*zMailbox.unlockcCr#r$r%r@r r r!�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'r r r!�_string_to_bytes�s
�zMailbox._string_to_bytesFc	Cs�	t|tjj�r@t��}tj�||d�}|�|�|�	d�|�
�}|�dt�}|�
|�|jr<|�t�s>|�
t�dSdSdSt|tttjf�r�t|tj�rZt�dtd�|��}t|t�rd|�|�}|rl|�dd�}|�dt�}|�
|�|jr�|�t�s�|�
t�dSdSdSt|d�r�t|d�r�t�d	td�|j}d}	|��}|�d�r�|dd�d}n
|�d
�r�|dd�d}|s�n|r�|�d�r�d|dd�}|�dt�}|�
|�|}q�|jr�|r�|�t�s�|�
t�dSdSdSdStdt|���)Nr�
�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 insteadT�
����
����From s>From ��Invalid message type: %s)�
isinstancer<r(r	�io�BytesIO�	generator�BytesGenerator�flatten�seekrc�replace�linesep�write�_append_newline�endswith�str�bytes�StringIO�warnings�warn�DeprecationWarning�getvaluer_rTrd�readline�
startswith�	TypeError�type)	rr(�targetZmangle_from_rd�gen�dataZlastline�liner r r!�
_dump_message�sh


��


�

�


��zMailbox._dump_message�NTr�F)&�__name__�
__module__�__qualname__r"r)r-r.r0r2r5r3r6r?r>r9rArDrIrJrKrLrMrNrOrPrRrSrWrXrYrZr[r_rwr��classmethodr�__class_getitem__r r r r!r"sF

		
	

6rc@s�eZdZ	dZd5dd�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,Zd-d.�Zd/d0�Zd1d2�Zd3d4�ZdS)6r�:NTcCs�	t�||||�tj�|jd�tj�|jd�tj�|jd�d�|_tj�|j�sF|rAt�|jd�|j�	�D]}t�|d�q7nt
|j��i|_ddd�|_d|_
d|_dS)	N�tmp�new�cur)r�r�r��r)r�r�g�������?)rr"rr�joinr�_paths�exists�mkdirrKr�_toc�_toc_mtimes�
_last_read�_skewfactor)r�dirnamerrrr r r!r"s"��

zMaildir.__init__c
Csh	|��}z|�||�Wnty|��t�|j��wt|�t|t	�r<|�
�}|j|��}||jkr;d}nd}d}tj
�|j��|j�d}tj
�|j|||�}t|t	�rmt�|jtj
�|j�|��f�z'z	t�|j|�Wnttfy�t�|j|�YW|Swt�|j�W|Sty�}zt�|j�|jtjkr�td|���d}~ww)N�r�rz$Name clash with existing message: %s)�_create_tmpr��
BaseExceptionr[rr-�name�_sync_closermr
�
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�er r r!r)$sT�

�
�
�����zMaildir.addcCs"	t�tj�|j|�|���dSr)rr-rr�r�_lookupr+r r r!r-Ns zMaildir.removec	Cs,	z|�|�WdSttfyYdSwr)r-r/�FileNotFoundErrorr+r r r!r0Rs�zMaildir.discardcCs�	|�|�}|�|�}|�|�}t|t�r|}n|}tj�|�}|j|vr1|j|�|j�d}nd}|�	|�tj�
|j|�}	tj�
|j|||�}
t|t�r^t�|	tj�
|	�|��f�t�|	|
�dS)Nrir�)r�r)rmr
rrr�r�r�r0r�rr�r�r�r�)rr,r(Zold_subpathZtemp_keyZtemp_subpathZdominant_subpathr�r�Ztmp_path�new_pathr r r!r2Zs&






�zMaildir.__setitem__cCs�	|�|�}ttj�|j|�d��}|jr|�|�}nt|�}Wd�n1s)wYtj�|�\}}|�	|�|j
|vrK|�|�|j
�d�|�tj�
tj�|j|���|S)N�rbri)r��openrrr�rrr
r��
set_subdirr��set_info�set_date�getmtime)rr,Zsubpath�f�msgr�r�r r r!r6us
��

zMaildir.get_messagecCsR	ttj�|j|�|��d��}|���td�Wd�S1s"wYdS)Nr�r`)	r�rrr�rr�rcrtru�rr,r�r r r!r>�s$�zMaildir.get_bytescCs&	ttj�|j|�|��d�}t|�S)Nr�)r�rrr�rr��
_ProxyFiler�r r r!r9�szMaildir.get_filec	csD�	|��|jD]}z|�|�Wn	tyYq	w|Vq	dSr)�_refreshr�r�r/r+r r r!rA�s�
��zMaildir.iterkeyscC�	|��||jvSr)r�r�r+r r r!rN��
zMaildir.__contains__cC�	|��t|j�Sr)r��lenr�r@r r r!rO�r�zMaildir.__len__cC�	dSrr r@r r r!rX�sz
Maildir.flushcCr�rr r@r r r!rY��zMaildir.lockcCr�rr r@r r r!rZ�r�zMaildir.unlockcCr�rr r@r r r!r[�r�z
Maildir.closecCs^	g}t�|j�D]#}t|�dkr,|ddkr,tj�tj�|j|��r,|�|dd��q	|S)N�r�.)r�listdirrr�r�isdirr��append�rrQ�entryr r r!�list_folders�s��zMaildir.list_folderscCs"	ttj�|jd|�|jdd�S)Nr�F�rr)rrrr�rr�r�folderr r r!�
get_folder�s
�zMaildir.get_foldercCs^	tj�|jd|�}t||jd�}tj�|d�}tj�|�s-t�t�|tj	tj
Bd��|S)Nr��rZ
maildirfolder�)rrr�rrrr�r[r��O_CREAT�O_WRONLY)rr�rrQZmaildirfolder_pathr r r!�
add_folder�s�zMaildir.add_foldercCs	tj�|jd|�}t�tj�|d��t�tj�|d��D]}t|�dks-|ddkr3td|��qt�|�D]!}|dkrZ|dkrZ|dkrZtj�tj�||��rZtd||f��q9tj|d	d
�D]#\}}}|D]}t�	tj�||��qi|D]}t�
tj�||��qxqbt�
|�dS)Nr�r�r�r�rzFolder contains message(s): %sr�z%Folder contains subdirectory '%s': %sF)�topdown)rrr�rr�r�rr��walkr-�rmdir)rr�rr��root�dirs�filesr r r!�
remove_folder�s.������zMaildir.remove_foldercCsZ	t��}t�tj�|jd��D]}tj�|jd|�}|tj�|�dkr*t�|�qdS)Nr�i@�)�timerr�rr�rr�r-)r�nowr�rr r r!�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
ybtjd7_zt|�WYSty_YnwYnwtd	|��)
N�/z\057r�z\072z%s.M%sP%sQ%s.%sr�g��.Ar�z&Name clash prevented file creation: %s)r��socket�gethostnamert�intr�getpidr�_countrr�r�statr��_create_carefully�FileExistsErrorr)rr�Zhostnamer�rr r r!r��s2����zMaildir._create_tmpcCs�	t��|jd|jkr0d}|jD]}tj�|j|�}||j|kr&d}||j|<q|s0dSi|_|jD]/}|j|}t�	|�D]"}tj�
||�}tj�|�rRqB|�|j
�d}tj�
||�|j|<qBq6t��|_dS)N�FTr)r�r�r�r�rrr�r�r�r�r�r�r�r�)rZrefreshr��mtimerr��pr�r r r!r�s*


�zMaildir._refreshcCsv	ztj�tj�|j|j|��r|j|WSWn	ty!Ynw|��z|j|WSty:td|�d�w�N�No message with key: %s)rrr�r�rr�r/r�r+r r r!r�&s���zMaildir._lookupcCsN	t|d�s|��|_	z|t|j�WStyYdSty&Yqw)N�
_onetime_keys)rTrAr��next�
StopIterationr/r@r r r!r�4s

�zMaildir.nextr�)r�r�r�r�r"r)r-r0r2r6r>r9rArNrOrXrYrZr[r�r�r�r�r�r�r�r�r�r�r r r r!rs8
*
	
$rc@s�eZdZ	d#dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd$dd �Zd!d"�ZdS)%�_singlefileMailboxNTc
Cs�	t�||||�zt|jd�}Wn7tyH}z+|jtjkr-|r(t|jd�}nt|j��|jtjtj	fvr=t|jd�}n�WYd}~nd}~ww||_
d|_d|_d|_
d|_d|_d|_dS)N�rb+zwb+r�rF)rr"r�rr�r��ENOENTr�EACCES�EROFS�_filer��	_next_key�_pending�
_pending_sync�_locked�_file_length)rrrrr�r�r r r!r"Ds*
��

z_singlefileMailbox.__init__cCs:	|��|�|�|j|j<|jd7_d|_|jdS)Nr�T)r��_append_messager�r�r�r'r r r!r)[s
z_singlefileMailbox.addcCs	|�|�|j|=d|_dSr�)r�r�r�r+r r r!r-es

z_singlefileMailbox.removecCs&	|�|�|�|�|j|<d|_dSr�)r�rr�r�r1r r r!r2ks

z_singlefileMailbox.__setitem__ccs �	|��|j��EdHdSr)r�r�rDr@r r r!rAqs�z_singlefileMailbox.iterkeyscCr�r)r�r�r+r r r!rNvr�z_singlefileMailbox.__contains__cCr�r)r�r�r�r@r r r!rO{r�z_singlefileMailbox.__len__cCs 	|jst|j�d|_dSdSr�)r��
_lock_filer�r@r r r!rY��


�z_singlefileMailbox.lockcCs 	|jrt|j�d|_dSdS�NF)r��_unlock_filer�r@r r r!rZ�rz_singlefileMailbox.unlockc
Cs�	|js|jrt|j�d|_dS|j�dd�|j��}||jkr+td|j|f��t|j	�}zSi}|�
|�t|j�
��D]=}|j|\}}|j�|�|�|�|��}	|j�td||j����}|sin|�|�qX||��f||<|�|�q?|��|_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)	NFrr�z4Size of mailbox file changed (expected %i, found %i)T�r�)�dotlock) r�r��_sync_flushr�rs�tellrr�_create_temporaryr�_pre_mailbox_hook�sortedr�rD�_pre_message_hookrc�minrv�_post_message_hookr[rr-r�r�r��st_mode�chmodr�r�r�r�r)
rZcur_lenZnew_fileZnew_tocr,�start�stopZ	new_startrd�moder r r!rX�sj
	

�



�
�
��z_singlefileMailbox.flushcCr�rr �rr�r r r!r�r�z$_singlefileMailbox._pre_mailbox_hookcCr�rr rr r r!r
�r�z$_singlefileMailbox._pre_message_hookcCr�rr rr r r!r�r�z%_singlefileMailbox._post_message_hookcCs�	z#|��Wz|jr|��W|j��dSW|j��dS|j��wz|jr4|��W|j��wW|j��w|j��wr)rXr�rZr�r[r@r r r!r[�s

��
�z_singlefileMailbox.closecCsJ	|jdur
|��|dur#z|j|WSty"td|�d�wdSr�)r��
_generate_tocr/r+r r r!r��s
��z_singlefileMailbox._lookupcCs�	|j�dd�|j��}t|j�dkr|js|�|j�z|�|j�|�|�}|�	|j�Wnt
y>|j�|��w|j��|j��|_
|S)Nrr�)r�rsr	r�r�r�rr
�_install_messagerr��truncaterXr)rr(ZbeforeZoffsetsr r r!r�s 

�
z"_singlefileMailbox._append_messager�r)r�r�r�r"r)r-r2rArNrOrYrZrXrr
rr[r�rr r r r!r�As$

@

r�c@s@eZdZ	dZdd�Zddd�Zddd�Zdd	d
�Zdd�Zd
S)�	_mboxMMDFTcCsr	|�|�\}}|j�|�|j���td�}|j�||j���}|�|�td��}|�	|dd��
d��|S)N�r`rkr)r�r�rsr�rtrurcr	�_message_factory�set_from�decode)rr,rr�	from_line�stringr�r r r!r6	sz_mboxMMDF.get_messageFcCs	t�|�||��j|d�S)N)�unixfromr;)rr,�from_r r r!r?s
��z_mboxMMDF.get_stringcCsL	|�|�\}}|j�|�|s|j��|j�||j���}|�td�S�Nr`)r�r�rsr�rcr	rtru)rr,r!rrrr r r!r>s
z_mboxMMDF.get_bytescCs>	|�|�\}}|j�|�|s|j��t|j|j��|�Sr)r�r�rsr��_PartialFiler	)rr,r!rrr r r!r9!s
z_mboxMMDF.get_filecCs	d}t|t�r
|�|�}t|t�r4|�d�r4|�d�}|dkr/|d|�}||dd�}n*|}d}n%t|t�rE|���d�}d|}nt|t	j
j�rY|��}|durY|�d�}|durhdt
�t
�����}|j��}|j�|t�|�||j|j�|j��}||fS)Nrjr`rir�rrsFrom MAILER-DAEMON )rmryr_rzr��find�_mboxMMDFMessage�get_fromr\r<r(r	�get_unixfromr��asctime�gmtimer�r	rvrur��
_mangle_from_)rr(r�newlineZauthorrrr r r!r)s2







z_mboxMMDF._install_messageNr�)	r�r�r�r*r6r?r>r9rr r r r!rs



	rc@s0eZdZ	dZdZd	dd�Zdd�Zdd�ZdS)
rTNcC�	t|_t�||||�dSr)rrrr"rr r r!r"O�z
mbox.__init__cCs	|�t�dSr�rvrurr r r!rT�zmbox._post_message_hookcCs�	gg}}d}|j�d�	|j��}|j��}|�d�r?t|�t|�kr7|r2|�|tt��n|�|�|�|�d}n|sS|rM|�|tt��n|�|�n
|tkrZd}nd}qtt	t
||���|_t|j�|_|j��|_
dS)NFrTrj)r�rsr	r�r�r�r�ru�dict�	enumerate�zipr�r�r)r�starts�stopsZlast_was_empty�line_posr�r r r!rXs4






�zmbox._generate_tocr�)r�r�r�r*rwr"rrr r r r!rFs
rc@s0eZdZ	ddd�Zdd�Zdd�Zd	d
�ZdS)rNTcCr,r)rrrr"rr r r!r"}r-z
MMDF.__init__cC�	|�dt�dS�N�r.rr r r!r
��zMMDF._pre_message_hookcCs	|�tdt�dSr7r.rr r r!r�szMMDF._post_message_hookcCs�	gg}}|j�d�d}	|}|j��}|j��}|�dt�rN|�|�	|}|j��}|j��}|dtkrD|�|tt��n	|sL|�|�nq(n|sQnqtt	t
||���|_t|j�|_|j�dd�|j��|_
dS)NrTr8r�)r�rsr�r	r�rur�r�r0r1r2r�r�r)rr3r4�next_posr5r�r r r!r�s:






��
�zMMDF._generate_tocr�)r�r�r�r"r
rrr r r r!rzs
rc@s�eZdZ	d/dd�Zdd�Zdd�Zd	d
�Zdd�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.�ZdS)0rNTcCsv	t�||||�tj�|j�s6|r1t�|jd�t�t�tj�	|jd�tj
tjBtjBd��nt
|j��d|_dS)Nr��
.mh_sequencesi�F)rr"rrr�rr�r[r�r�r��O_EXCLr�rr�rr r r!r"�s�

zMH.__init__cCs�	|��}t|�dkrd}nt|�d}tj�|jt|��}t|�}d}zQ|j	r,t
|�z7z|�||�WntyO|j	rCt
|�t|�d}t�|��wt|t�r[|�||�W|j	rct
|�n	|j	rlt
|�wwW|stt|�|S|s}t|�ww)Nrr�FT)rDr��maxrrr�rryr�r�rr�r�rr�r-rmr�_dump_sequences)rr(rDZnew_keyr�r��closedr r r!r)�sL
�
���
���
�zMH.addc
Csn	tj�|jt|��}zt|d�}Wnty+}z
|jtjkr&t	d|���d}~ww|�
�t�|�dS�Nr�r�)rrr�rryr�r�r�r�r/r[r-)rr,rr�r�r r r!r-�s��z	MH.removec
Cs�	tj�|jt|��}zt|d�}Wnty+}z
|jtjkr&t	d|���d}~wwz?|j
r4t|�z't�t�|tj
tjB��|�||�t|t�rS|�||�W|j
r[t|�n	|j
rdt|�wwWt|�dSt|�wr@)rrr�rryr�r�r�r�r/r�rr[r��O_TRUNCr�rmrr>rr�)rr,r(rr�r�r r r!r2�s6��
���
��zMH.__setitem__c
Cs	z |jrttj�|jt|��d�}n
ttj�|jt|��d�}Wnty:}z
|jtj	kr5t
d|���d}~ww|�&|jrEt|�z
t|�}W|jrRt
|�n	|jr[t
|�wwWd�n1sfwY|����D]
\}}||vr~|�|�qq|S)Nr�r�r�)r�r�rrr�rryr�r�r�r/rrr�
get_sequencesrM�add_sequence)rr,r�r�r�r��key_listr r r!r6�s<���
��
���
�zMH.get_messagec
Cs�	z |jrttj�|jt|��d�}n
ttj�|jt|��d�}Wnty:}z
|jtj	kr5t
d|���d}~ww|�)|jrEt|�z|���
td�W|jrUt|�Wd�S|jret|�ww1siwYdS)Nr�r�r�r`)r�r�rrr�rryr�r�r�r/rrcrtrur�rr,r�r�r r r!r>s0����
��zMH.get_bytesc
CsZ	zttj�|jt|��d�}Wt
|�Sty,}z
|jtjkr't	d|���d}~ww)Nr�r�)r�rrr�rryr�r�r�r/r�rEr r r!r9,s���zMH.get_filecCs 	ttdd�t�|j�D���S)Ncss �|]}|��rt|�VqdSr)�isdigitr�)�.0r�r r r!�	<genexpr>9s��zMH.iterkeys.<locals>.<genexpr>)�iterrrr�rr@r r r!rA7szMH.iterkeyscCs	tj�tj�|jt|���Sr)rrr�r�rryr+r r r!rN<szMH.__contains__cCs	tt|����Sr)r�rCrAr@r r r!rO@�z
MH.__len__cCs8	|jsttj�|jd�d�|_t|j�d|_dSdS)Nr;r�T)r�r�rrr�rr�rr@r r r!rYDs

�zMH.lockcCs.	|jrt|j�t|j�|`d|_dSdSr)r�rr�r�r@r r r!rZKs


�z	MH.unlockcCr�rr r@r r r!rXSr�zMH.flushcCs	|jr
|��dSdSr)r�rZr@r r r!r[Ws�zMH.closecCs>	g}t�|j�D]}tj�tj�|j|��r|�|�q	|Sr)rr�rrr�r�r�r�r r r!r�\s
�zMH.list_folderscCs	ttj�|j|�|jdd�S)NFr��rrrr�rrr�r r r!r�ds�z
MH.get_foldercCs	ttj�|j|�|jd�S)Nr�rKr�r r r!r�is�z
MH.add_foldercCsb	tj�|j|�}t�|�}|dgkrt�tj�|d��n|gkr#ntd|j��t�|�dS)Nr;zFolder not empty: %s)rrr�rr�r-rr�)rr�r�entriesr r r!r�ns

zMH.remove_folderc

s	i}ttj�|jd�ddd��p}t|����|D]^}zM|�d�\}}t�}|��D]$}|��r8|�	t
|��q*dd�|�d�D�\}}	|�t||	d	��q*�fd
d�t
|�D�||<t||�dkrg||=Wqtywtd
|����wWd�|S1s�wY|S)Nr;�r�ASCII��encodingr�css�|]}t|�VqdSr)r�)rG�xr r r!rH���z#MH.get_sequences.<locals>.<genexpr>�-r�csg|]}|�vr|�qSr r )rGr,�Zall_keysr r!�
<listcomp>�s�z$MH.get_sequences.<locals>.<listcomp>rz"Invalid sequence specification: %s)r�rrr�r�setrDr�rFr)r�rW�rangerr�r^r�rstrip)
rZresultsr�r�r��contentsrD�specrrr rTr!rBzs6����
��zMH.get_sequencescCs
	ttj�|jd�ddd�}zqt�t�|jtjtjB��|�	�D]W\}}t
|�dkr,q!|�|d�d}d}tt
|��D])}|d|krO|sNd	}|�d
�n|r]d}|�d||f�n|�d|�|}q=|rs|�t|�d
�q!|�d
�q!Wt|�dSt|�w)Nr;zr+rNrOrr�Fr�TrSz%s %sz %s�
)r�rrr�rr[r�r�rArMr�rvrrVryr�)r�	sequencesr�r�rD�prevZ
completingr,r r r!�
set_sequences�s4
��zMH.set_sequencesc	
Cs:	|��}d}g}|��D]`}|d|kri|�||df�zt�tj�|jt|��tj�|jt|d���Wn#t	t
fy[t�tj�|jt|��tj�|jt|d���Ynwt�tj�|jt|���|d7}q
|d|_
t|�dkr{dS|��D]\}}|D]\}}||vr�|||�|�<q�q|�|�dS)Nrr�)rBrAr�rr�rr�rryr�r�r��unlinkr�r�rM�indexr^)	rr\r]Zchangesr,r�rD�oldr�r r r!�pack�s8���

��zMH.packcCsv	|��}|��}|��D]\}}||vr|�|�q
||vr%||�|�=q
|D]}||vr3|g||<q(|�|�dSr)rBrMr�r`r^)rr(r,Zpending_sequencesZ
all_sequencesr�rD�sequencer r r!r>�s�
�zMH._dump_sequencesr�)r�r�r�r"r)r-r2r6r>r9rArNrOrYrZrXr[r�r�r�r�rBr^rbr>r r r r!r�s0
"rc@s�eZdZ	ehd��Zddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)r>�unseen�resent�answered�	forwardedZfiled�deletedZeditedNTcCs	t�||||�i|_dSr)r�r"�_labelsrr r r!r"�s
zBabyl.__init__cCs*	t�||�}t|t�r|��|j|<|Sr)r�r)rmr
�
get_labelsri)rr(r,r r r!r)�s

z	Babyl.addcCs(	t�||�||jvr|j|=dSdSr)r�r-rir+r r r!r-�s

�zBabyl.removecCs0	t�|||�t|t�r|��|j|<dSdSr)r�r2rmr
rjrir1r r r!r2�s

�zBabyl.__setitem__c
Cs�	|�|�\}}|j�|�|j��t��}	|j��}|dtks%|s&n
|�|�td��qt��}	|j��}|tks@|sAn
|�|�td��q5||j�	�}|j�
|�}|�td�}t|��|�}	|	�
|���||jvrz|	�|j|�|	S�NT�*** EOOH ***r`)r�r�rsr�rnrorurvrtr	rcr
r�set_visibleri�
set_labels)
rr,rr�original_headersr�Zvisible_headers�n�bodyr�r r r!r6�s4

�
�
zBabyl.get_messagec	Cs�	|�|�\}}|j�|�|j��t��}	|j��}|dtks%|s&n
|�|�td��q	|j��}|tks<|s=nq1|�	�}||j�
�}|j�|�}|�td�}||Srk)r�r�rsr�rnrorurvrtrr	rc)	rr,rrror�Zheadersrpr�r r r!r>s*

�
�zBabyl.get_bytescCs	t�|�|��dt��Sr")rnror>rtrur+r r r!r9(�zBabyl.get_filecCs>	|��t�}|j��D]}|�|�q
|�|j�t|�Sr)r�rVrirKrW�difference_update�_special_labelsrC)r�labelsZ
label_listr r r!rj,szBabyl.get_labelscCs>	gg}}|j�d�d}g}	|}|j��}|j��}|dtkrPt|�t|�kr4|�|tt��|�|�dd�|j��dd��d�D�}|�|�n(|dksZ|dtkrlt|�t|�krk|�|tt��n|sx|�|tt��nqtt	t
||���|_tt	|��|_t|j�|_
|j�dd	�|j��|_dS)
NrTscSsg|]
}|��r|���qSr )�strip�rG�labelr r r!rUCs�z'Babyl._generate_toc.<locals>.<listcomp>r��,�r�)r�rsr�r	rur�r�r�r0r1r2r�rir�r)rr3r4r:Zlabel_listsr5r�rur r r!r5s<



���zBabyl._generate_toccCsX	dt}|dt7}|��}dd�|D�}|dd�|�t7}|d7}|�|�dS)NsBABYL OPTIONS:s
Version: 5css�|]}|��VqdSr)r\rwr r r!rHXrRz*Babyl._pre_mailbox_hook.<locals>.<genexpr>sLabels:ryrz)rurjr�rv)rr�Zbabylrur r r!rSszBabyl._pre_mailbox_hookcCr6)N�r.rr r r!r
]r9zBabyl._pre_message_hookcCs	|�td�dS)Nrzr.rr r r!rar9zBabyl._post_message_hookcCsb	|j��}t|t�rYg}g}|��D]}||jvr |�|�q|�|�q|j�d�|D]}|j�d|���q.|j�d�|D]}|j�d|��d�qC|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�rg|j�|d|��d
t	��|j�dt	�|j�|d|��d
t	��|j�||d��d
t	��n�|j�dt	t	�|j�|�d
t	��n�t |d��r t |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)N�1s, s,,� rys1,,FrTr`rlrrarbs

r�rir�rdrerfrgrhrl)%r�r	rmr
rjrtr�rvr\rur<r(r	rnrorprqrrrsr�rt�get_visiblercrzryr{r|r}r~rr_r$rTrdrxr�r�)rr(rZspecial_labelsrurxZorig_bufferZorig_generatorr�Z
vis_bufferZ
vis_generatorrdZ
body_startZoriginal_posZ
first_passrr r r!res�




�
�
�
��
���

zBabyl._install_messager�)r�r�r��	frozensetrtr"r)r-r2r6r>r9rjrrr
rrr r r r!r�s 
	
rc@s(eZdZ	ddd�Zdd�Zdd�ZdS)	r	NcCs�	t|tjj�r|�t�|��t|t�r|�|�dSdSt|t�r-|�t�	|��dSt|t
�r<|�t�|��dSt|tj
�rL|�t�|��dSt|d�r[|�t�|��dS|durhtjj�|�dStdt|���)Nrcrl)rmr<r(r	�_become_message�copyZdeepcopy�_explain_torzr=ryZmessage_from_stringrn�
TextIOWrapperZmessage_from_filerTZmessage_from_binary_filer"r�r�r'r r r!r"�s"
�


zMessage.__init__cCs6	t|dg�}|jD]}||vr|j||j|<q
dS)N�_type_specific_attributes)�getattr�__dict__)rr(Z
type_specificr�r r r!r��s
��zMessage._become_messagecCs	t|t�rdStd��)Nz Cannot convert to specified type)rmr	r�r'r r r!r��s
zMessage._explain_tor)r�r�r�r"r�r�r r r r!r	�s

r	c@sxeZdZ	gd�Zddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)r
)�_subdir�_info�_dateNcCs(	d|_d|_t��|_t�||�dS)Nr�r�)r�r�r�r�r	r"r'r r r!r"�s

zMaildirMessage.__init__cC�	|jSr)r�r@r r r!r��zMaildirMessage.get_subdircCs(	|dks	|dkr||_dStd|��)Nr�r�z!subdir must be 'new' or 'cur': %s)r�r^)rr�r r r!r�s
zMaildirMessage.set_subdircCs 	|j�d�r|jdd�SdS)N�2,r�r�)r�r�r@r r r!�	get_flags
szMaildirMessage.get_flagscCs	dd�t|��|_dS)Nr�r�)r�rr�)r�flagsr r r!�	set_flagsrrzMaildirMessage.set_flagscC�&	|�d�t|���t|�B��dS�Nr��r�r�rVr��r�flagr r r!�add_flag�$zMaildirMessage.add_flagcCs2	|��r|�d�t|���t|���dSdSr�)r�r�r�rVr�r r r!�remove_flags$�zMaildirMessage.remove_flagcCr�r)r�r@r r r!r�!r�zMaildirMessage.get_datecCs0	zt|�|_WdStytd|�d�w)Nzcan't convert to float: %s)�floatr�r^r�)r�dater r r!r�%s�zMaildirMessage.set_datecCr�r)r�r@r r r!r�,r�zMaildirMessage.get_infocCs&	t|t�r||_dStdt|���)Nzinfo must be a string: %s)rmryr�r�r�)r�infor r r!r�0s

zMaildirMessage.set_infocCs�	t|t�r|�|���|�|���|�|���dSt|t�rdt	|���}d|vr1|�
d�|��dkr<|�
d�d|vrE|�
d�d|vrN|�
d�d|vrW|�
d�|�d	t�
|����dSt|t�r�t	|���}d|vrx|�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|���)N�S�Rr��O�T�D�F�A�
MAILER-DAEMONrd�replied�flaggedrhrf�Prg�$Cannot convert to specified type: %s)rmr
r�r�r�r�r�r�r%rVr�rr�r)rrCr
�	add_labelr	r�r�)rr(r�r r r!r�7sV









�



�
�zMaildirMessage._explain_tor)r�r�r�r�r"r�r�r�r�r�r�r�r�r�r�r�r r r r!r
�s
r
c@sXeZdZ	dgZddd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)r%�_fromNcCsX	|�dd�t|tjj�r$|��}|dur$|�d�r$|�|dd��t�||�dS)Nr�TzFrom rk)rrmr<r(r	r'r�r")rr(r r r r!r"hsz_mboxMMDFMessage.__init__cCr�r)r�r@r r r!r&qr�z_mboxMMDFMessage.get_fromcCs6	|dur|dur
t��}|dt�|�7}||_dS)NT� )r�r)r(r�)rr!Ztime_r r r!rus
z_mboxMMDFMessage.set_fromcCs	|�dd�|�dd�S)N�Statusr��X-Status)r5r@r r r!r�}rrz_mboxMMDFMessage.get_flagscCs�	t|�}d\}}dD]}||vr||7}|�|�qdD]}||vr,||7}|�|�q|d�t|��7}z|�d|�WntyM|�d|�Ynwz	|�d|�WdStyg|�d|�YdSw)N)r�r�)r�r�)r�r�r�r�r�r�)rVr-r�r�replace_headerr/Z
add_header)rr�Zstatus_flagsZ
xstatus_flagsr�r r r!r��s0
�
���z_mboxMMDFMessage.set_flagscCr�r�r�r�r r r!r��r�z_mboxMMDFMessage.add_flagcCs:	d|vs	d|vr|�d�t|���t|���dSdS)Nr�r�r�r�r�r r r!r��s$�z_mboxMMDFMessage.remove_flagc	Cs�	t|t�rht|���}d|vr|�d�d|vr|�d�d|vr'|�d�d|vr0|�d�d|vr9|�d�|d	=|d
=d�|����dd��}z|�	t
�t�
|d
���WdSttfygYdSwt|t�r}|�|���|�|���dSt|t�r�t|���}d|vr�|�d�d|vr�|�d�d|vr�|�d�|d	=|d
=dSt|t�r�t|���}d|vr�|�d�d|vr�|�d�d|vr�|�d�|d	=|d
=dSt|t�r�dStdt|���)Nr�r�r�r�r�r�r�r�Zstatuszx-statusr����z%a %b %d %H:%M:%S %Yrdr�r�rhrfr�)rmr
rVr�r�r�r�r&r�r��calendarZtimegmr��strptimer^�
OverflowErrorr%r�rrrCr
r�r	r�r�)rr(r�Z
maybe_dater r r!r��sf





��











�z_mboxMMDFMessage._explain_tor)r�r�r�r�r"r&rr�r�r�r�r�r r r r!r%cs
	
r%c@�eZdZdS)rN�r�r�r�r r r r!r��rc@sFeZdZ	dgZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r�
_sequencesNcCs	g|_t�||�dSr)r�r	r"r'r r r!r"�szMHMessage.__init__cC�	|jdd�Sr)r�r@r r r!rB�r/zMHMessage.get_sequencescC�	t|�|_dSr)rCr�)rr\r r r!r^�r/zMHMessage.set_sequencescC�:	t|t�r||jvr|j�|�dSdStdt|���)Nzsequence type must be str: %s)rmryr�r�r�r��rrcr r r!rC��

�zMHMessage.add_sequencecC�*	z	|j�|�WdStyYdSwr)r�r-r^r�r r r!�remove_sequence���zMHMessage.remove_sequencecCsR	t|t�r6t|���}d|vr|�d�n
|�d�|�d�d|vr)|�d�d|vr4|�d�dSdSt|t�rft|���}d|vrK|�d�n|�d	�d|vrY|�d�d|vrd|�d
�dSdSt|t�ry|��D]}|�|�qodSt|t	�r�t|���}d|vr�|�
d�d|vr�|�
d�dSdSt|t�r�dStdt
|���)
Nrdr�r�r�r�r�r��ROr�r�rfr�)rmr
rVrBr�r�r%rrCr
r�r	r�r�)rr(r\rcr r r!r��sL



�


�
�

�
�zMHMessage._explain_tor)
r�r�r�r�r"rBr^rCr�r�r r r r!r�s
rc@s`eZdZ	ddgZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�ZdS)r
ri�_visibleNcCs 	g|_t�|_t�||�dSr)rir	r�r"r'r r r!r"%szBabylMessage.__init__cCr�r)rir@r r r!rj+r/zBabylMessage.get_labelscCr�r)rCri)rrur r r!rn/r/zBabylMessage.set_labelscCr�)Nzlabel must be a string: %s)rmryrir�r�r��rrxr r r!r�3r�zBabylMessage.add_labelcCr�r)rir-r^r�r r r!�remove_label;r�zBabylMessage.remove_labelcCs	t|j�Sr�r	r�r@r r r!r~Bs
zBabylMessage.get_visiblecCr�rr�)rZvisibler r r!rmFr/zBabylMessage.set_visiblecCsd	|j��D]}||vr|j�|||�q|j|=qdD]}||vr/||jvr/|||j|<qdS)N)ZDateZFromzReply-ToZToZCCZSubject)r�rDr�)r�headerr r r!�update_visibleJs
��zBabylMessage.update_visiblecCsz	t|t�rCt|���}d|vr|�d�n
|�d�|�d�d|vs(d|vr-|�d�d|vr6|�d�d	|vrA|�d
�dSdSt|t�rst|���}d|vrX|�d�n|�d�d	|vrf|�d
�d|vrq|�d�dSdSt|t�r�t|���}d|vr�|�d�d|vr�|�d�dSdSt|t	�r�|�
|���|��D]}|�|�q�dSt|t
�r�dStdt|���)Nrdr�r�rgrer�rfr�rhr�r�r�r�r�r�r�)rmr
rVrjr�r�r%rrCr
rmr~r�r	r�r�)rr(rurxr r r!r�UsR




�


�

�
�
�zBabylMessage._explain_tor)
r�r�r�r�r"rjrnr�r�r~rmr�r�r r r r!r
 s
r
c@r�)rNr�r r r r!rr�rc@s�eZdZ	d%dd�Zd%dd�Zd%dd�Zd%dd	�Zd%d
d�Zdd
�Zdd�Z	d&dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zed#d$��Zee�ZdS)'r�NcCs(	||_|dur|��|_dS||_dSr)r�r	�_pos)rr��posr r r!r"�s

z_ProxyFile.__init__cC�	|�||jj�Sr)�_readr�rc�r�sizer r r!rc�rJz_ProxyFile.readcCr�r)r�r��read1r�r r r!r��rJz_ProxyFile.read1cCr�r)r�r�r�r�r r r!r��rJz_ProxyFile.readlinecCs@	g}|D]}|�|�|dur|t|�8}|dkr|Sq|S)Nr)r�r�)r�sizehintrQr�r r r!�	readlines�s
�z_ProxyFile.readlinesccs�		|��}|sdS|Vqr)r�)rr�r r r!rJ�s��z_ProxyFile.__iter__cCr�r)r�r@r r r!r	�r�z_ProxyFile.tellrcCs6	|dkr|j�|j�|j�||�|j��|_dS)Nr��r�rsr�r	�r�offset�whencer r r!rs�s
z_ProxyFile.seekcCsB	t|d�rzt|jd�r|j��W|`dSW|`dS|`wdS)Nr�r[)rTr�r[r@r r r!r[�s
��z_ProxyFile.closecCs4	|durd}|j�|j�||�}|j��|_|S)Nrir�)rr��read_methodrQr r r!r��sz_ProxyFile._readcCs	|Srr r@r r r!�	__enter__�r�z_ProxyFile.__enter__cGs|��dSr)r[)r�excr r r!�__exit__�sz_ProxyFile.__exit__cC�
|j��Sr)r��readabler@r r r!r���
z_ProxyFile.readablecCr�r)r��writabler@r r r!r��r�z_ProxyFile.writablecCr�r)r��seekabler@r r r!r��r�z_ProxyFile.seekablecCr�r)r�rXr@r r r!rX�r�z_ProxyFile.flushcCs&t|d�sdSt|jd�sdS|jjS)Nr�Tr?F)rTr�r?r@r r r!r?�s

z_ProxyFile.closedr�r)r�r�r�r"rcr�r�r�rJr	rsr[r�r�r�r�r�r�rX�propertyr?r�rr�r r r r!r��s*





		
r�c@s:eZdZ	d
dd�Zdd�Zddd�Zd	d
�Zdd�ZdS)r#NcCs 	t�|||�||_||_dSr)r�r"�_start�_stop)rr�rrr r r!r"�s
z_PartialFile.__init__cCs	t�|�|jSr)r�r	r�r@r r r!r	�rJz_PartialFile.tellrcCs>	|dkr|j|_d}n
|dkr|j|_d}t�|||�dS)Nrr�r�)r�r�r�r�rsr�r r r!rs�sz_PartialFile.seekcCsD	|j|j}|dkr
dS|dus|dks||kr|}t�|||�S)Nrr)r�r�r�r�)rr�r�Z	remainingr r r!r��sz_PartialFile._readcCst|d�r	|`dSdS)Nr�)rTr�r@r r r!r[s
�z_PartialFile.close)NNr�)r�r�r�r"r	rsr�r[r r r r!r#�s


	r#Tc
Cs�	d}z�tr2zt�|tjtjB�Wnty1}z|jtjtjtjfvr,t	d|j
���d}~ww|r�z
t|j
d�}|��Wnty_}z|jtjtjfvrZWYd}~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��)NFzlockf: lock unavailable: %s�.lockTzdot lock unavailable: %s)�fcntl�lockfZLOCK_EXZLOCK_NBr�r�ZEAGAINr�r�rr�r
r[rr�r�r�r�r_r�r-�LOCK_UN)r�rZdotlock_doner�Zpre_lockr r r!rs^����������rcCs>	tr
t�|tj�tj�|jd�rt�|jd�dSdS)Nr�)r�r�r�rrr�r�r-�r�r r r!r9s�rc	CsB	t�|tjtjBtjBd�}zt|d�Wt�|�St�|�w)Nr�r�)rr�r�r<�O_RDWRr[)r�fdr r r!r�@s

r�cCs&	td|tt���t��t��f�S)Nz%s.%s.%s.%s)r�r�r�r�r�rr�)rr r r!r
Hs
�r
cCs*	|��ttd�rt�|���dSdS)N�fsync)rXrTrr��filenor�r r r!rNs

�rcCs	t|�|��dSr)rr[r�r r r!r�Tsr�c@r�)rNr�r r r r!rZr�rc@r�)rNr�r r r r!r]r�rc@r�)rNr�r r r r!r`r�rc@r�)rNr�r r r r!rcr�rc@r�)rNr�r r r r!rfr�r)T)1rr�r�r�r�r�r|r<Z
email.messageZemail.generatorrnr7�typesrr��ImportError�__all__rur\rrr�rrrrrr(r	r
r%rrr
rr�r#rrr�r
rr��	Exceptionrrrrrr r r r!�<module>sp�j8DB4-3z%mqH_e
'*