Sh3ll
OdayForums


Server : Apache
System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : nobody ( 99)
PHP Version : 8.1.23
Disable Function : NONE
Directory :  /opt/alt/python38/lib64/python3.8/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/alt/python38/lib64/python3.8/__pycache__/mailbox.cpython-38.opt-2.pyc
U

��,aE3�@sNddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
Z
ddlZzddlZWne
k
r�dZYnXdddddddd	d
ddd
dddddgZej�d�ZGdd�d�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�dejj�ZGdd	�d	e�ZGd d!�d!e�ZGd"d
�d
e�ZGd#d�de�ZGd$d�de�ZGd%d
�d
e�Z Gd&d'�d'�Z!Gd(d)�d)e!�Z"d<d+d,�Z#d-d.�Z$d/d0�Z%d1d2�Z&d3d4�Z'd5d6�Z(Gd7d�de)�Z*Gd8d�de*�Z+Gd9d�de*�Z,Gd:d�de*�Z-Gd;d�de*�Z.dS)=�N�Mailbox�Maildir�mbox�MH�Babyl�MMDF�Message�MaildirMessage�mboxMessage�	MHMessage�BabylMessage�MMDFMessage�Error�NoSuchMailboxError�
NotEmptyError�ExternalClashError�FormatError�asciic@seZdZdBdd�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.�ZdDd/d0�Zd1d2�ZdEd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Z d?Z!dFd@dA�Z"dS)GrNTcCs tj�tj�|��|_||_dS�N)�os�path�abspath�
expanduser�_path�_factory��selfr�factory�create�r�,/opt/alt/python38/lib64/python3.8/mailbox.py�__init__$szMailbox.__init__cCstd��dS�Nz&Method must be implemented by subclass��NotImplementedError�r�messagerrr �add)szMailbox.addcCstd��dSr"r#�r�keyrrr �remove-szMailbox.removecCs|�|�dSr)r*r(rrr �__delitem__1szMailbox.__delitem__cCs(z|�|�Wntk
r"YnXdSr)r*�KeyErrorr(rrr �discard4szMailbox.discardcCstd��dSr"r#�rr)r&rrr �__setitem__;szMailbox.__setitem__cCs*z|�|�WStk
r$|YSXdSr)�__getitem__r,)rr)�defaultrrr �get?szMailbox.getc
CsB|js|�|�St�|�|���}|�|�W5QR�SQRXdSr)r�get_message�
contextlib�closing�get_file)rr)�filerrr r0Fs
zMailbox.__getitem__cCstd��dSr"r#r(rrr r3NszMailbox.get_messagecCst�|�|����Sr��email�message_from_bytes�	get_bytesZ	as_stringr(rrr �
get_stringRszMailbox.get_stringcCstd��dSr"r#r(rrr r;YszMailbox.get_bytescCstd��dSr"r#r(rrr r6]szMailbox.get_filecCstd��dSr"r#�rrrr �iterkeysaszMailbox.iterkeyscCst|���Sr)�listr>r=rrr �keyseszMailbox.keysc	cs>|��D]0}z||}Wntk
r0YqYnX|VqdSr�r>r,�rr)�valuerrr �
itervaluesis
zMailbox.itervaluescCs|��Sr)rDr=rrr �__iter__rszMailbox.__iter__cCst|���Sr)r?rDr=rrr �valuesuszMailbox.valuesc	csB|��D]4}z||}Wntk
r0YqYnX||fVqdSrrArBrrr �	iteritemsys
zMailbox.iteritemscCst|���Sr)r?rGr=rrr �items�sz
Mailbox.itemscCstd��dSr"r#r(rrr �__contains__�szMailbox.__contains__cCstd��dSr"r#r=rrr �__len__�szMailbox.__len__cCs|��D]}|�|�qdSr)r@r-r(rrr �clear�sz
Mailbox.clearcCs4z||}Wntk
r$|YSX|�|�|Sr)r,r-)rr)r1�resultrrr �pop�s

zMailbox.popcCs*|��D]}||�|�fStd��dS)NzNo messages in mailbox)r>rMr,r(rrr �popitem�szMailbox.popitemc	Cstt|d�r|��}nt|d�r(|��}n|}d}|D].\}}z|||<Wq4tk
r`d}Yq4Xq4|rptd��dS)NrGrHFTzNo message with key(s))�hasattrrGrHr,)r�arg�sourceZbad_keyr)r&rrr �update�s



zMailbox.updatecCstd��dSr"r#r=rrr �flush�sz
Mailbox.flushcCstd��dSr"r#r=rrr �lock�szMailbox.lockcCstd��dSr"r#r=rrr �unlock�szMailbox.unlockcCstd��dSr"r#r=rrr �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�}|�
|�|j�r�|�t��s�|�
t�n�t|d��r�t|d��r2t�d	td�|j}d}|��}|�d
��r\|dd�d}n|�d��rx|dd
�d}|�s��q�|�r�|�d��r�d|dd�}|�dt�}|�
|�|}�q6|j�r�|�r�|�t��s�|�
t�ntdt|���dS)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 instead�
����
����From s>From ��Invalid message type: %s)�
isinstancer9r&r�io�BytesIO�	generator�BytesGenerator�flatten�seekr^�replace�linesep�write�_append_newline�endswith�str�bytes�StringIO�warnings�warn�DeprecationWarning�getvaluerZrOr_�readline�
startswith�	TypeError�type)	rr&�targetZmangle_from_r_�gen�dataZlastline�linerrr �
_dump_message�s`


�


�
zMailbox._dump_message)NT)N)N)N)F)#�__name__�
__module__�__qualname__r!r'r*r+r-r/r2r0r3r<r;r6r>r@rDrErFrGrHrIrJrKrMrNrRrSrTrUrVrZrrr�rrrr r!s@

		
	
c@s�eZdZdZd5dd�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�s�|r�t�|jd�|j�	�D]}t�|d�qln
t
|j��i|_ddd�|_d|_
d|_dS)	N�tmp�new�cur)r�r�r��r)r�r�g�������?)rr!rr�joinr�_paths�exists�mkdirrFr�_toc�_toc_mtimes�
_last_read�_skewfactor)r�dirnamerrrrrr r!
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�|jtjk�rftd|��n�W5d}~XYnX|S)N�r�rz$Name clash with existing message: %s)�_create_tmpr��
BaseExceptionrVrr*�name�_sync_closerhr	�
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�errr r'!sF


��zMaildir.addcCs t�tj�|j|�|���dSr)rr*rr�r�_lookupr(rrr r*KszMaildir.removec	Cs,z|�|�Wnttfk
r&YnXdSr)r*r,�FileNotFoundErrorr(rrr r-OszMaildir.discardcCs�|�|�}|�|�}|�|�}t|t�r.|}n|}tj�|�}|j|kr`|j|�|j�d}nd}|�	|�tj�
|j|�}	tj�
|j|||�}
t|t�r�t�|	tj�
|	�|��f�t�|	|
�dS)Nrdr�)r�r'rhr	rrr�r�r�r-r�rr�r�r�r�)rr)r&Zold_subpathZtemp_keyZtemp_subpathZdominant_subpathr�r�Ztmp_path�new_pathrrr r/Ws$






�zMaildir.__setitem__c	Cs�|�|�}ttj�|j|�d�� }|jr4|�|�}nt|�}W5QRXtj�|�\}}|�	|�|j
|kr�|�|�|j
�d�|�tj�
tj�|j|���|S)N�rbrd)r��openrrr�rrr	r��
set_subdirr��set_info�set_date�getmtime)rr)Zsubpath�f�msgr�r�rrr r3rs


zMaildir.get_messagec
CsDttj�|j|�|��d��}|���td�W5QR�SQRXdS)Nr�r[)	r�rrr�rr�r^rorp�rr)r�rrr r;�szMaildir.get_bytescCs$ttj�|j|�|��d�}t|�S)Nr�)r�rrr�rr��
_ProxyFiler�rrr r6�szMaildir.get_filec	csF|��|jD]2}z|�|�Wntk
r8YqYnX|VqdSr)�_refreshr�r�r,r(rrr r>�s

zMaildir.iterkeyscCs|��||jkSr)r�r�r(rrr rI�szMaildir.__contains__cCs|��t|j�Sr)r��lenr�r=rrr rJ�szMaildir.__len__cCsdSrrr=rrr rS�sz
Maildir.flushcCsdSrrr=rrr rT�szMaildir.lockcCsdSrrr=rrr rU�szMaildir.unlockcCsdSrrr=rrr rV�sz
Maildir.closecCs\g}t�|j�D]F}t|�dkr|ddkrtj�tj�|j|��r|�|dd��q|S)N�r�.)r�listdirrr�r�isdirr��append�rrL�entryrrr �list_folders�s�zMaildir.list_folderscCs ttj�|jd|�|jdd�S)Nr�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)Nr��rZ
maildirfolder�)rrr�rrrr�rVr��O_CREAT�O_WRONLY)rr�rrLZmaildirfolder_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)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�filesrrr �
remove_folder�s&���zMaildir.remove_foldercCsXt��}t�tj�|jd��D]4}tj�|jd|�}|tj�|�dkrt�|�qdS)Nr�i@�)�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	|��dS)
N�/z\057r�z\072z%s.M%sP%sQ%s.%sr�g��.Ar�z&Name clash prevented file creation: %s)r��socket�gethostnamero�intr�getpidr�_countrr�r�statr��_create_carefully�FileExistsErrorr)rr�Zhostnamer�rrrr r��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)N�FTr)r�r�r�r�rrr�r�r�r�r�r�r�r�)rZrefreshr��mtimerr��pr�rrr r��s&


zMaildir._refreshcCs�z.tj�tj�|j|j|��r,|j|WSWntk
rBYnX|��z|j|WStk
rztd|�d�YnXdS�N�No message with key: %s)rrr�r�rr�r,r�r(rrr r�#szMaildir._lookupcCsXt|d�s|��|_z|t|j�WStk
r:YdStk
rPYqYqXqdS)N�
_onetime_keys)rOr>r��next�
StopIterationr,r=rrr r�1s

zMaildir.next)NT)r�r�r�r�r!r'r*r-r/r3r;r6r>rIrJrSrTrUrVr�r�r�r�r�r�r�r�r�r�rrrr rs4
*
	
$c@s�eZdZd#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�}Wnntk
r�}zP|jtjkr\|rPt|jd�}q~t|j��n"|jtjtj	fkr|t|jd�}n�W5d}~XYnX||_
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�rrr r!As$z_singlefileMailbox.__init__cCs8|��|�|�|j|j<|jd7_d|_|jdS)Nr�T)r��_append_messager�r�r�r%rrr r'Xs
z_singlefileMailbox.addcCs|�|�|j|=d|_dS�NT)r�r�r�r(rrr r*bs
z_singlefileMailbox.removecCs$|�|�|�|�|j|<d|_dSr�)r�r�r�r�r.rrr r/hs
z_singlefileMailbox.__setitem__ccs|��|j��EdHdSr)r�r�r@r=rrr r>nsz_singlefileMailbox.iterkeyscCs|��||jkSr)r�r�r(rrr rIssz_singlefileMailbox.__contains__cCs|��t|j�Sr)r�r�r�r=rrr rJxsz_singlefileMailbox.__len__cCs|jst|j�d|_dSr�)r��
_lock_filer�r=rrr rT}s
z_singlefileMailbox.lockcCs|jrt|j�d|_dS�NF)r��_unlock_filer�r=rrr rU�s
z_singlefileMailbox.unlockc
Cs�|js |jrt|j�d|_dS|j�dd�|j��}||jkrTtd|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|j	d�|_||_d|_d|_|j�r�t|jdd�dS)NFrr�z4Size of mailbox file changed (expected %i, found %i)�r�)�dotlock) r�r��_sync_flushr�rn�tellr�r�_create_temporaryr�_pre_mailbox_hook�sortedr�r@�_pre_message_hookr^�minrq�_post_message_hookrVrr*r�r�r��st_mode�chmodr�r�r�r�r�)
rZcur_lenZnew_fileZnew_tocr)�start�stopZ	new_startr_�moderrr rS�s`
	

�



�
z_singlefileMailbox.flushcCsdSrr�rr�rrr r��sz$_singlefileMailbox._pre_mailbox_hookcCsdSrrrrrr r��sz$_singlefileMailbox._pre_message_hookcCsdSrrrrrr r�sz%_singlefileMailbox._post_message_hookcCs4z|��W5z|jr|��W5|j��XXdSr)r�rVr�rUrSr=rrr rV�sz_singlefileMailbox.closecCsN|jdkr|��|dk	rJz|j|WStk
rHtd|�d�YnXdSr�)r��
_generate_tocr,r(rrr r��s
z_singlefileMailbox._lookupcCs�|j�dd�|j��}t|j�dkr8|js8|�|j�z&|�|j�|�|�}|�	|j�Wn"t
k
r�|j�|��YnX|j��|j��|_
|S)Nrr�)r�rnr�r�r�r�r�r��_install_messagerr��truncaterSr�)rr&ZbeforeZoffsetsrrr r��s


z"_singlefileMailbox._append_message)NT)N)r�r�r�r!r'r*r/r>rIrJrTrUrSr�r�rrVr�r�rrrr r�>s 

@

r�c@s>eZdZdZdd�Zddd�Zddd�Zdd	d
�Zdd�Zd
S)�	_mboxMMDFTcCsp|�|�\}}|j�|�|j���td�}|j�||j���}|�|�td��}|�	|dd��
d��|S)N�r[rfr)r�r�rnr{rorpr^r��_message_factory�set_from�decode)rr)rr�	from_line�stringr�rrr r3sz_mboxMMDF.get_messageFcCst�|�||��j|d�S)N)�unixfromr8)rr)�from_rrr r<s

��z_mboxMMDF.get_stringcCsJ|�|�\}}|j�|�|s(|j��|j�||j���}|�td�S�Nr[)r�r�rnr{r^r�rorp)rr)rrrrrrr r;s
z_mboxMMDF.get_bytescCs<|�|�\}}|j�|�|s(|j��t|j|j��|�Sr)r�r�rnr{�_PartialFiler�)rr)rrrrrr r6s

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)Nrer[rdr�rrsFrom MAILER-DAEMON )rhrtrZrur|�find�_mboxMMDFMessage�get_fromrWr9r&r�get_unixfromr��asctime�gmtimer�r�rqrpr��
_mangle_from_)rr&r�newlineZauthorrrrrr r	&s0







z_mboxMMDF._install_messageN)F)F)F)	r�r�r�rr3r<r;r6r	rrrr rs


	
rc@s.eZdZdZdZd	dd�Zdd�Zdd�ZdS)
rTNcCst|_t�||||�dSr)r
r
rr!rrrr r!Lsz
mbox.__init__cCs|�t�dSr�rqrprrrr rQszmbox._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)NFrreT)r�rnr�r{r|r�r�rp�dict�	enumerate�zipr�r�r�)r�starts�stopsZlast_was_empty�line_posr�rrr rUs.






zmbox._generate_toc)NT)r�r�r�rrrr!rrrrrr rCs

c@s.eZdZddd�Zdd�Zdd�Zd	d
�ZdS)rNTcCst|_t�||||�dSr)r
r
rr!rrrr r!zsz
MMDF.__init__cCs|�dt�dS�N�rrrrr r�szMMDF._pre_message_hookcCs|�tdt�dSr%rrrrr r�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)Nrr&r�)r�rnr{r�r|rpr�r�rr r!r�r�r�)rr"r#�next_posr$r�rrr r�s.






zMMDF._generate_toc)NT)r�r�r�r!r�rrrrrr rws
c@s�eZdZd/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)0rNTcCstt�||||�tj�|j�sj|r`t�|jd�t�t�tj�	|jd�tj
tjBtjBd��n
t
|j��d|_dS)Nr��
.mh_sequencesi�F)rr!rrr�rr�rVr�r�r��O_EXCLr�rr�rrrr r!�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)Nrr�FT)r@r��maxrrr�rrtr�r�r�r�r�r�r�r*rhr�_dump_sequences)rr&r@Znew_keyr�r��closedrrr r'�s6


zMH.addc
Csxtj�|jt|��}zt|d�}Wn>tk
r`}z |jtjkrNt	d|��n�W5d}~XYnX|�
�t�|�dS�Nr�r�)rrr�rrtr�r�r�r�r,rVr*)rr)rr�r�rrr r*�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
|�XdSr-)rrr�rrtr�r�r�r�r,r�r�r�r�rVr��O_TRUNCr�rhrr+)rr)r&rr�r�rrr r/�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)Nr�r�r�)r�r�rrr�rrtr�r�r�r,r�r�r�
get_sequencesrH�add_sequence)rr)r�r�r�r��key_listrrr r3�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)Nr�r�r�r[)r�r�rrr�rrtr�r�r�r,r�r�r^rorp�rr)r�r�rrr r;s zMH.get_bytesc
Csfzttj�|jt|��d�}Wn>tk
r\}z |jtjkrJt	d|��n�W5d}~XYnXt
|�S)Nr�r�)r�rrr�rrtr�r�r�r,r�r2rrr r6)szMH.get_filecCsttdd�t�|j�D���S)Ncss|]}|��rt|�VqdSr)�isdigitr�)�.0r�rrr �	<genexpr>6s�zMH.iterkeys.<locals>.<genexpr>)�iterr�rr�rr=rrr r>4szMH.iterkeyscCstj�tj�|jt|���Sr)rrr�r�rrtr(rrr rI9szMH.__contains__cCstt|����Sr)r�r?r>r=rrr rJ=sz
MH.__len__cCs2|js.ttj�|jd�d�|_t|j�d|_dS)Nr(r�T)r�r�rrr�rr�r�r=rrr rTAs
zMH.lockcCs(|jr$t|j�t|j�|`d|_dSr�)r�r�r�r�r=rrr rUHs


z	MH.unlockcCsdSrrr=rrr rSPszMH.flushcCs|jr|��dSr)r�rUr=rrr rVTszMH.closecCs<g}t�|j�D]&}tj�tj�|j|��r|�|�q|Sr)rr�rrr�r�r�r�rrr r�Ys
zMH.list_folderscCsttj�|j|�|jdd�S)NFr��rrrr�rrr�rrr r�as�z
MH.get_foldercCsttj�|j|�|jd�S)Nr�r7r�rrr r�fs�z
MH.add_foldercCs`tj�|j|�}t�|�}|dgkr:t�tj�|d��n|gkrDntd|j��t�|�dS)Nr(zFolder not empty: %s)rrr�rr�r*rr�)rr�r�entriesrrr r�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)Nr(�r�ASCII��encodingr�css|]}t|�VqdSr)r�)r4�xrrr r5�sz#MH.get_sequences.<locals>.<genexpr>�-r�csg|]}|�kr|�qSrr)r4r)�Zall_keysrr �
<listcomp>�s�z$MH.get_sequences.<locals>.<listcomp>rz"Invalid sequence specification: %s)r�rrr�r�setr@r�r3r'r�rR�ranger�r�rYr�rstrip)
rZresultsr�r�r��contentsr@�specrrrr?r r/ws(
�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)Nr(zr+r:r;rr�Fr�Tr>z%s %sz %s�
)r�rrr�rr�rVr�r�r.rHr�rqr�rArt)r�	sequencesr�r�r@�prevZ
completingr)rrr �
set_sequences�s.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]"\}}||k�r
|||�|�<�q
q�|�|�dS)Nrr�)r/r>r�rr�rr�rrtr�r�r��unlinkr�r�rH�indexrI)	rrGrHZchangesr)r�r1�oldr�rrr �pack�s0��



zMH.packcCst|��}|��}|��D]0\}}||kr4|�|�q||kr||�|�=q|D]}||krN|g||<qN|�|�dSr)r/rHr�rKrI)rr&r)Zpending_sequencesZ
all_sequencesr�r1�sequencerrr r+�szMH._dump_sequences)NT)r�r�r�r!r'r*r/r3r;r6r>rIrJrTrUrSrVr�r�r�r�r/rIrMr+rrrr r�s,
"c@s�eZdZedddddddh�Zd$d
d�Zdd
�Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd d!�Zd"d#�ZdS)%r�unseen�deletedZfiled�answered�	forwardedZedited�resentNTcCst�||||�i|_dSr)r�r!�_labelsrrrr r!�szBabyl.__init__cCs(t�||�}t|t�r$|��|j|<|Sr)r�r'rhr�
get_labelsrT)rr&r)rrr r'�s
z	Babyl.addcCs"t�||�||jkr|j|=dSr)r�r*rTr(rrr r*�s
zBabyl.removecCs*t�|||�t|t�r&|��|j|<dSr)r�r/rhrrUrTr.rrr r/�s
zBabyl.__setitem__c
Cs�|�|�\}}|j�|�|j��t��}|j��}|dtks\|sHq\|�|�td��q,t��}|j��}|tks�|s|q�|�|�td��qd||j�	�}|j�
|�}|�td�}t|��|�}	|	�
|���||jkr�|	�|j|�|	S�N�*** EOOH ***r[)r�r�rnr{rirjrprqror�r^rrz�set_visiblerT�
set_labels)
rr)rr�original_headersr�Zvisible_headers�nZbodyr�rrr r3�s*



zBabyl.get_messagec	Cs�|�|�\}}|j�|�|j��t��}|j��}|dtks\|sHq\|�|�td��q,|j��}|tksv|s\qvq\|�	�}||j�
�}|j�|�}|�td�}||SrV)r�r�rnr{rirjrprqrorzr�r^)	rr)rrrZr�Zheadersr[r�rrr r;s 


zBabyl.get_bytescCst�|�|��dt��Sr)rirjr;rorpr(rrr r6%szBabyl.get_filecCs<|��t�}|j��D]}|�|�q|�|j�t|�Sr)r�rArTrFrR�difference_update�_special_labelsr?)r�labelsZ
label_listrrr rU)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)	NrscSsg|]}|��r|���qSr)�strip�r4�labelrrr r@@s�z'Babyl._generate_toc.<locals>.<listcomp>r��,�r�)r�rnr{r�rpr�r�r�rr r!r�rTr�r�)rr"r#r'Zlabel_listsr$r�r^rrr r2s4



�zBabyl._generate_toccCsVdt}|dt7}|��}dd�|D�}|dd�|�t7}|d7}|�|�dS)NsBABYL OPTIONS:s
Version: 5css|]}|��VqdSr)rWr`rrr r5Usz*Babyl._pre_mailbox_hook.<locals>.<genexpr>sLabels:rbrc)rprUr�rq)rr�Zbabylr^rrr r�PszBabyl._pre_mailbox_hookcCs|�dt�dS)N�rrrrr r�ZszBabyl._pre_message_hookcCs|�td�dS)Nrcrrrrr r^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	k�s,|s��q,q�|j�d
t	�t|t��r�t
��}	t
j�|	dd�}
|
�|���|	��}|j�|�d	t	��|d	k�s�|�sn�q�qnn>|�d�|��}|j�|�d	t	��|d	k�s�|�s��q�q�|�d�}|�s��qf|j�|�d	t	���q�nTt|ttt
jf��rt|t
j��rJt�dtd
�|��}t|t��r`|�|�}|�d�d}|ddk�r�|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	k�s�|�sF|�r�d}|j�d
t	�|�|
�n�qڐqF|��}|�s�qf|�"d��r
|dd�t	}n:|�"d��r(|dd�t	}n|�"d	��rD|dd�t	}|j�|��q�nt#dt$|���|j��}||fS)N�1s, s,,� rbs1,,Frr[rWr�r\r]s

r�rdr{r_r`Trarbrcrg)%r�r�rhrrUr]r�rqrWrpr9r&rrirjrkrlrmrnr{ro�get_visibler^rurtrvrwrxryrzrZrrOr_rsr}r~)rr&rZspecial_labelsr^raZorig_bufferZorig_generatorr�Z
vis_bufferZ
vis_generatorr_Z
body_startZoriginal_posZ
first_passrrrr r	bs�







�
�
zBabyl._install_message)NT)r�r�r��	frozensetr]r!r'r*r/r3r;r6rUrr�r�rr	rrrr r�s$
�
	
c@s&eZdZddd�Zdd�Zdd�ZdS)	rNcCs�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)Nr^rg)rhr9r&r�_become_message�copyZdeepcopy�_explain_torur:rtZmessage_from_stringri�
TextIOWrapperZmessage_from_filerOZmessage_from_binary_filer!r}r~r%rrr r!�s



zMessage.__init__cCs4t|dg�}|jD]}||kr|j||j|<qdS)N�_type_specific_attributes)�getattr�__dict__)rr&Z
type_specificr�rrr ri�s
zMessage._become_messagecCst|t�rdStd��dS)Nz Cannot convert to specified type)rhrr}r%rrr rk�s
zMessage._explain_to)N)r�r�r�r!rirkrrrr r�s
c@sxeZdZdddgZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)r	�_subdir�_info�_dateNcCs&d|_d|_t��|_t�||�dS)Nr�r�)rprqr�rrrr!r%rrr r!�s
zMaildirMessage.__init__cCs|jSr)rpr=rrr r��szMaildirMessage.get_subdircCs(|dks|dkr||_ntd|��dS)Nr�r�z!subdir must be 'new' or 'cur': %s)rprY)rr�rrr r�szMaildirMessage.set_subdircCs"|j�d�r|jdd�SdSdS)N�2,r�r�)rqr|r=rrr �	get_flags
szMaildirMessage.get_flagscCsdd�t|��|_dS)Nrsr�)r�r�rq)r�flagsrrr �	set_flagsszMaildirMessage.set_flagscCs$|�d�t|���t|�B��dS�Nr��rvr�rArt�r�flagrrr �add_flagszMaildirMessage.add_flagcCs,|��r(|�d�t|���t|���dSrw)rtrvr�rAryrrr �remove_flagszMaildirMessage.remove_flagcCs|jSr)rrr=rrr r�szMaildirMessage.get_datecCs6zt|�|_Wn"tk
r0td|�d�YnXdS)Nzcan't convert to float: %s)�floatrrrYr})r�daterrr r�"szMaildirMessage.set_datecCs|jSr)rqr=rrr r�)szMaildirMessage.get_infocCs&t|t�r||_ntdt|���dS)Nzinfo must be a string: %s)rhrtrqr}r~)r�inforrr r�-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|k�r|�d�d|k�r�|�d�n�t|t��r�t	|���}d|k�rD|�d
�d|k�rX|�d
�d|k�rl|�d�d|k�r�|�d�nt|t��r�ntdt|���dS)N�S�Rr��O�T�D�F�A�
MAILER-DAEMONrO�replied�flaggedrPrQ�PrR�$Cannot convert to specified type: %s)rhr	rvrtr�r�r�r�rrAr{rr�rrr0r�	add_labelrr}r~)rr&rurrr rk4sP

















�zMaildirMessage._explain_to)N)r�r�r�rmr!r�r�rtrvr{r|r�r�r�r�rkrrrr r	�s

c@sVeZdZdgZddd�Zdd�Zddd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)r�_fromNcCsV|�dd�t|tjj�rF|��}|dk	rF|�d�rF|�|dd��t�||�dS)Nr�TzFrom rf)rrhr9r&rrr|r!)rr&rrrr r!esz_mboxMMDFMessage.__init__cCs|jSr)r�r=rrr rnsz_mboxMMDFMessage.get_fromcCs4|dk	r*|dkrt��}|dt�|�7}||_dS)NT� )r�rrr�)rrZtime_rrr rrs
z_mboxMMDFMessage.set_fromcCs|�dd�|�dd�S)N�Statusr��X-Status)r2r=rrr rtzsz_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)N)r�r�)r�r�)r�r�r�r�r�r�)rAr*r�r��replace_headerr,Z
add_header)rruZstatus_flagsZ
xstatus_flagsrzrrr rv~s&z_mboxMMDFMessage.set_flagscCs$|�d�t|���t|�B��dSrwrxryrrr r{�sz_mboxMMDFMessage.add_flagcCs4d|ksd|kr0|�d�t|���t|���dS)Nr�r�r�rxryrrr r|�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�YnX�n
t|t�r�|�|���|�|���n�t|t��rZt|���}d|k�r$|�d�d|k�r8|�d�d|k�rL|�d�|d	=|d
=n�t|t��r�t|���}d|k�r�|�d�d|k�r�|�d�d|k�r�|�d�|d	=|d
=nt|t��r�ntdt|���dS)Nr�r�r�r�r�r�r�r�Zstatuszx-statusr����z%a %b %d %H:%M:%S %YrOr�r�rPrQr�)rhr	rArtr�r{r�rr�r��calendarZtimegmr��strptimerY�
OverflowErrorrrvrrr0rr�rr}r~)rr&ruZ
maybe_daterrr rk�sb





�













�z_mboxMMDFMessage._explain_to)N)N)r�r�r�rmr!rrrtrvr{r|rkrrrr r`s
	
rc@seZdZdS)r
N�r�r�r�rrrr r
�sc@sDeZdZdgZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r�
_sequencesNcCsg|_t�||�dSr)r�rr!r%rrr r!�szMHMessage.__init__cCs|jdd�Sr)r�r=rrr r/�szMHMessage.get_sequencescCst|�|_dSr)r?r�)rrGrrr rI�szMHMessage.set_sequencescCs6t|t�r"||jkr2|j�|�ntdt|���dS)Nzsequence type must be str: %s)rhrtr�r�r}r~�rrNrrr r0�s

zMHMessage.add_sequencecCs*z|j�|�Wntk
r$YnXdSr)r�r*rYr�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|k�r|�
d�d|k�rB|�
d�nt|t��r2ntdt
|���dS)
NrOr�r�r�r�r�r��ROr�r�rQr�)rhr	rAr/r�r{rrr0rr�rr}r~)rr&rGrNrrr rk�sB










�zMHMessage._explain_to)N)
r�r�r�rmr!r/rIr0r�rkrrrr r�s
c@s^eZdZddgZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�ZdS)rrT�_visibleNcCsg|_t�|_t�||�dSr)rTrr�r!r%rrr r!"szBabylMessage.__init__cCs|jdd�Sr)rTr=rrr rU(szBabylMessage.get_labelscCst|�|_dSr)r?rT)rr^rrr rY,szBabylMessage.set_labelscCs6t|t�r"||jkr2|j�|�ntdt|���dS)Nzlabel must be a string: %s)rhrtrTr�r}r~�rrarrr r�0s

zBabylMessage.add_labelcCs*z|j�|�Wntk
r$YnXdSr)rTr*rYr�rrr �remove_label8szBabylMessage.remove_labelcCs
t|j�Sr�rr�r=rrr rg?szBabylMessage.get_visiblecCst|�|_dSrr�)rZvisiblerrr rXCszBabylMessage.set_visiblecCsb|j��D](}||kr*|j�|||�q
|j|=q
dD]$}||kr8||jkr8|||j|<q8dS)N)ZDateZFromzReply-ToZToZCCZSubject)r�r@r�)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|k�r|�d�d|k�rn|�d�nTt|t	��rP|�
|���|��D]}|�|��q<nt|t
��r^ntdt|���dS)NrOr�r�rRrSr�rQr�rPr�r�r�r�r�r�r�)rhr	rArUr�r{rrr0rrXrgr�rr}r~)rr&r^rarrr rkRsH










�zBabylMessage._explain_to)N)
r�r�r�rmr!rUrYr�r�rgrXr�rkrrrr rs
c@seZdZdS)r
Nr�rrrr r
|sc@s�eZdZd%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$��ZdS)+r�NcCs$||_|dkr|��|_n||_dSr)r�r��_pos)rr��posrrr r!�sz_ProxyFile.__init__cCs|�||jj�Sr)�_readr�r^�r�sizerrr r^�sz_ProxyFile.readcCs|�||jj�Sr)r�r��read1r�rrr r��sz_ProxyFile.read1cCs|�||jj�Sr)r�r�r{r�rrr r{�sz_ProxyFile.readlinecCs<g}|D].}|�|�|dk	r|t|�8}|dkrq8q|S)Nr)r�r�)r�sizehintrLr�rrr �	readlines�s
z_ProxyFile.readlinesccs|��}|sdS|VqdSr)r{)rr�rrr rE�sz_ProxyFile.__iter__cCs|jSr)r�r=rrr r��sz_ProxyFile.tellrcCs4|dkr|j�|j�|j�||�|j��|_dS)Nr��r�rnr�r��r�offset�whencerrr rn�sz_ProxyFile.seekcCs0t|d�r,zt|jd�r"|j��W5|`XdS)Nr�rV)rOr�rVr=rrr rV�s

z_ProxyFile.closecCs2|dkrd}|j�|j�||�}|j��|_|S)Nrdr�)rr��read_methodrLrrr r��sz_ProxyFile._readcCs|Srrr=rrr �	__enter__�sz_ProxyFile.__enter__cGs|��dSr)rV)r�excrrr �__exit__�sz_ProxyFile.__exit__cCs
|j��Sr)r��readabler=rrr r��sz_ProxyFile.readablecCs
|j��Sr)r��writabler=rrr r��sz_ProxyFile.writablecCs
|j��Sr)r��seekabler=rrr r��sz_ProxyFile.seekablecCs
|j��Sr)r�rSr=rrr rS�sz_ProxyFile.flushcCs&t|d�sdSt|jd�sdS|jjS)Nr�Tr,F)rOr�r,r=rrr r,�s

z_ProxyFile.closed)N)N)N)N)N)r)r�r�r�r!r^r�r{r�rEr�rnrVr�r�r�r�r�r�rS�propertyr,rrrr r��s$





		r�c@s8eZdZd
dd�Zdd�Zddd�Zd	d
�Zdd�ZdS)rNcCst�|||�||_||_dSr)r�r!�_start�_stop)rr�rrrrr r!�sz_PartialFile.__init__cCst�|�|jSr)r�r�r�r=rrr r��sz_PartialFile.tellrcCs<|dkr|j|_d}n|dkr*|j|_d}t�|||�dS)Nrr�r�)r�r�r�r�rnr�rrr rn�sz_PartialFile.seekcCsB|j|j}|dkrdS|dks0|dks0||kr4|}t�|||�S)Nrr)r�r�r�r�)rr�r�Z	remainingrrr r��sz_PartialFile._readcCst|d�r|`dS)Nr�)rOr�r=rrr rVs
z_PartialFile.close)NN)r)r�r�r�r!r�rnr�rVrrrr r�s



	rTc
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
��YnXWn8t�r�t�|tj�|�r�t
�|j
d��YnXdS)NFzlockf: lock unavailable: %s�.lockTzdot lock unavailable: %s)�fcntl�lockfZLOCK_EXZLOCK_NBr�r�ZEAGAINr�r�rr�r�rVrr�r�r�r�rJr�r*�LOCK_UN)r�r�Zdotlock_doner�Zpre_lockrrr r�
sL�
�r�cCs8trt�|tj�tj�|jd�r4t�|jd�dS)Nr�)r�r�r�rrr�r�r*�r�rrr r�4sr�c	Cs<t�|tjtjBtjBd�}zt|d�W�St�|�XdS)Nr�r�)rr�r�r)�O_RDWRrV)r�fdrrr r�;sr�cCs$td|tt���t��t��f�S)Nz%s.%s.%s.%s)r�r�r�r�r�rr�)rrrr r�Cs�r�cCs$|��ttd�r t�|���dS)N�fsync)rSrOrr��filenor�rrr r�Is
r�cCst|�|��dSr)r�rVr�rrr r�Osr�c@seZdZdS)rNr�rrrr rUsc@seZdZdS)rNr�rrrr rXsc@seZdZdS)rNr�rrrr r[sc@seZdZdS)rNr�rrrr r^sc@seZdZdS)rNr�rrrr ras)T)/rr�r�r�r�rjrwr9Z
email.messageZemail.generatorrir4r��ImportError�__all__rprWrrr�rrrrrr&rr	rr
rrr
r�rr�r�r�r�r�r��	Exceptionrrrrrrrrr �<module>	s�
�h8DB4-3z%mqH_c'
*

ZeroDay Forums Mini