ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python311/lib64/python3.11/__pycache__/mailbox.cpython-311.pyc

�

�f�3��v�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlZddl
mZ	ddlZn
#e$rdZYnwxYwgd�Zej�d��ZGd�d��ZGd�d	e��ZGd
�de��ZGd�d
e��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�dejj��ZGd�de��ZGd�de��ZGd�de��Z Gd�de��Z!Gd �d!e��Z"Gd"�d#e��Z#Gd$�d%��Z$Gd&�d'e$��Z%d9d)�Z&d*�Z'd+�Z(d,�Z)d-�Z*d.�Z+Gd/�d0e,��Z-Gd1�d2e-��Z.Gd3�d4e-��Z/Gd5�d6e-��Z0Gd7�d8e-��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���eZdZdZd$d�Zd�Zd�Zd�Zd�Zd	�Z	d%d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd%d�Zd�Zd%d�Zd�Zd�Zd�Zd �Z d!�Z!d"Z"d&d#�Z#e$e%��Z&dS)'rz*A group of messages in a particular place.NTc��tj�tj�|����|_||_dS)zInitialize a Mailbox instance.N)�os�path�abspath�
expanduser�_path�_factory��selfr�factory�creates    �./opt/alt/python311/lib64/python3.11/mailbox.py�__init__zMailbox.__init__%s2���W�_�_�R�W�%7�%7��%=�%=�>�>��
���
�
�
�c� �td���)�$Add message and return assigned key.�&Method must be implemented by subclass��NotImplementedError�r�messages  r"�addzMailbox.add*���!�"J�K�K�Kr$c� �td���)�=Remove the keyed message; raise KeyError if it doesn't exist.r'r(�r�keys  r"�removezMailbox.remove.r-r$c�0�|�|��dS�N)r2r0s  r"�__delitem__zMailbox.__delitem__2s�����C�����r$c�T�	|�|��dS#t$rYdSwxYw�z'If the keyed message exists, remove it.N)r2�KeyErrorr0s  r"�discardzMailbox.discard5sA��	��K�K���������	�	�	��D�D�	���s��
'�'c� �td���)�>Replace the keyed message; raise KeyError if it doesn't exist.r'r(�rr1r+s   r"�__setitem__zMailbox.__setitem__<r-r$c�R�	|�|��S#t$r|cYSwxYw)z9Return the keyed message, or default if it doesn't exist.)�__getitem__r8)rr1�defaults   r"�getzMailbox.get@s?��	��#�#�C�(�(�(���	�	�	��N�N�N�	���s��&�&c���|js|�|��Stj|�|����5}|�|��cddd��S#1swxYwYdS)z=Return the keyed message; raise KeyError if it doesn't exist.N)r�get_message�
contextlib�closing�get_file)rr1�files   r"r?zMailbox.__getitem__Gs����}�	+��#�#�C�(�(�(��#�D�M�M�#�$6�$6�7�7�
+�4��}�}�T�*�*�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+�
+�
+s�A&�&A*�-A*c� �td���)�4Return a Message representation or raise a KeyError.r'r(r0s  r"rCzMailbox.get_messageOr-r$c�t�tj|�|�������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_stringr0s  r"�
get_stringzMailbox.get_stringSs-��
�'����s�(;�(;�<�<�F�F�H�H�Hr$c� �td���)z8Return a byte string representation or raise a KeyError.r'r(r0s  r"rNzMailbox.get_bytesZr-r$c� �td���)�6Return a file-like representation or raise a KeyError.r'r(r0s  r"rFzMailbox.get_file^r-r$c� �td���)�Return an iterator over keys.r'r(�rs r"�iterkeyszMailbox.iterkeysbr-r$c�D�t|�����S)zReturn a list of keys.)�listrWrVs r"�keyszMailbox.keysfs���D�M�M�O�O�$�$�$r$c#�tK�|���D] }	||}n#t$rY�wxYw|V��!dS)z%Return an iterator over all messages.N�rWr8�rr1�values   r"�
itervalueszMailbox.itervaluesjsb�����=�=�?�?�	�	�C�
��S�	�����
�
�
���
�����K�K�K�K�	�	��#�
0�0c�*�|���Sr4)r_rVs r"�__iter__zMailbox.__iter__ss����� � � r$c�D�t|�����S)z,Return a list of messages. Memory intensive.)rYr_rVs r"�valueszMailbox.valuesvs���D�O�O�%�%�&�&�&r$c#�xK�|���D]"}	||}n#t$rY�wxYw||fV��#dS)z.Return an iterator over (key, message) tuples.Nr\r]s   r"�	iteritemszMailbox.iteritemszsj�����=�=�?�?�	�	�C�
��S�	�����
�
�
���
������,�����	�	r`c�D�t|�����S)z9Return a list of (key, message) tuples. Memory intensive.)rYrfrVs r"�itemsz
Mailbox.items�s���D�N�N�$�$�%�%�%r$c� �td���)�9Return True if the keyed message exists, False otherwise.r'r(r0s  r"�__contains__zMailbox.__contains__�r-r$c� �td���)�*Return a count of messages in the mailbox.r'r(rVs r"�__len__zMailbox.__len__�r-r$c�^�|���D]}|�|���dS)zDelete all messages.N)rZr9r0s  r"�clearz
Mailbox.clear�s8���9�9�;�;�	�	�C��L�L������	�	r$c�h�	||}n#t$r|cYSwxYw|�|��|S)z3Delete the keyed message and return it, or default.)r8r9)rr1r@�results    r"�popzMailbox.pop�sM��	��#�Y�F�F���	�	�	��N�N�N�	�������S�����
s���c�~�|���D]}||�|��fcStd���)z6Delete an arbitrary (key, message) pair and return it.zNo messages in mailbox)rWrsr8r0s  r"�popitemzMailbox.popitem�sC���=�=�?�?�	5�	5�C�����#���'�'�'�'��3�4�4�4r$c��t|d��r|���}n't|d��r|���}n|}d}|D]\}}	|||<�#t$rd}Y�wxYw|rtd���dS)z4Change the messages that correspond to certain keys.rfrhFTzNo message with key(s)N)�hasattrrfrhr8)r�arg�source�bad_keyr1r+s      r"�updatezMailbox.update�s����3��$�$�	��]�]�_�_�F�F�
�S�'�
"�
"�	��Y�Y�[�[�F�F��F���"�	�	�L�C��
�#��S�	�	���
�
�
�����
�����	5��3�4�4�4�	5�	5s�A�A,�+A,c� �td���)�&Write any pending changes to the disk.r'r(rVs r"�flushz
Mailbox.flush�r-r$c� �td���)�Lock the mailbox.r'r(rVs r"�lockzMailbox.lock�r-r$c� �td���)�#Unlock the mailbox if it is locked.r'r(rVs r"�unlockzMailbox.unlock�r-r$c� �td���)�Flush and close the mailbox.r'r(rVs r"�closez
Mailbox.close�r-r$c�h�	|�d��S#t$rtd���wxYw)Nrz?String input must be ASCII-only; use bytes or a Message instead)�encode�UnicodeError�
ValueErrorr*s  r"�_string_to_byteszMailbox._string_to_bytes�sK��	2��>�>�'�*�*�*���	2�	2�	2��1�2�2�
2�	2���s��1Fc��t|tjj��r�t	j��}tj�||d��}|�|��|�	d��|�
��}|�dt��}|�
|��|jr6|�t��s|�
t��d
Sd
Sd
St|t t"tjf��r�t|tj��r/t'jdt*d��|���}t|t ��r|�|��}|r|�dd��}|�dt��}|�
|��|jr6|�t��s|�
t��d
Sd
Sd
St1|d���r-t1|d��r"t'jd	t*d��|j}d
}	|���}|�d��r|d
d
�dz}n"|�d��r
|d
d�dz}|snW|r"|�d��r
d|dd
�z}|�dt��}|�
|��|}��|jr8|r8|�t��s |�
t��d
Sd
Sd
Sd
St9dt;|��z���)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)�
isinstancerLr+r
�io�BytesIO�	generator�BytesGenerator�flatten�seekr��replace�linesep�write�_append_newline�endswith�str�bytes�StringIO�warnings�warn�DeprecationWarning�getvaluer�rwr��readline�
startswith�	TypeError�type)	rr+�target�mangle_from_r��gen�data�lastline�lines	         r"�
_dump_messagezMailbox._dump_message�s����g�u�}�4�5�5�1	H��Z�\�\�F��/�0�0���q�I�I�C��K�K�� � � ��K�K��N�N�N��;�;�=�=�D��<�<��w�/�/�D��L�L������#�
&�D�M�M�'�,B�,B�
&����W�%�%�%�%�%�
&�
&�
&�
&���#�u�b�k�!:�
;�
;�&	H��'�2�;�/�/�
-��
�*�+=�q�B�B�B�!�*�*�,�,���'�3�'�'�
9��/�/��8�8���
C�!�/�/�*�k�B�B���o�o�e�W�5�5�G��L�L��!�!�!��#�
&�G�,<�,<�W�,E�,E�
&����W�%�%�%�%�%�
&�
&�
&�
&��W�f�
%�
%�	H��w��)�)�
)��
�5�6H�!�M�M�M�!�.���H�

 ��'�'�)�)���=�=��)�)�-�����9�u�,�D�D��]�]�5�)�)�-�����9�u�,�D�����0�D�O�O�H�$=�$=�0�$�t�A�B�B�x�/�D��|�|�E�7�3�3�����T�"�"�"���

 ��#�
&��
&��9J�9J�7�9S�9S�
&����W�%�%�%�%�%�
&�
&�
&�
&�
&�
&��6��g���F�G�G�Gr$�NTr4�F)'�__name__�
__module__�__qualname__�__doc__r#r,r2r5r9r=rAr?rCrPrNrFrWrZr_rbrdrfrhrkrnrprsrur{r~r�r�r�r�r�r��classmethodr�__class_getitem__�r$r"rr"sH������4�4� � � � �
L�L�L�L�L�L�������L�L�L�����+�+�+�L�L�L�I�I�I�L�L�L�L�L�L�L�L�L�%�%�%����!�!�!�'�'�'����&�&�&�L�L�L�L�L�L����
����5�5�5�5�5�5�5�"L�L�L�L�L�L�L�L�L�L�L�L�2�2�2��O�4H�4H�4H�4H�l$��L�1�1���r$rc��eZdZdZdZdd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdZd�Zd�Zd�Zd�ZdS)rzA qmail-style Maildir mailbox.�:NTc�r�t�||||��tj�|jd��tj�|jd��tj�|jd��d�|_tj�|j��sb|rLtj|jd��|j�	��D]}tj|d���nt|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�mkdirrdr�_toc�_toc_mtimes�
_last_read�_skewfactor)r�dirnamer r!rs     r"r#zMaildir.__init__s������w���8�8�8��7�<�<��
�E�2�2��7�<�<��
�E�2�2��7�<�<��
�E�2�2�����
�w�~�~�d�j�)�)�	5��
5�����U�+�+�+� �K�.�.�0�0�*�*�D��H�T�5�)�)�)�)�*�)���4�4�4���	�#$�Q�/�/����������r$c��|���}	|�||��n<#t$r/|���t	j|j���wxYwt|��t|t��r>|�
��}|j|���z}||jkrd}nd}d}tj
�|j���|j��d}tj
�|j|||z��}t|t��rPt	j|jtj
�|j��|���f��		t	j|j|��t	j|j��n1#t,t.f$rt	j|j|��YnwxYwnS#t2$rF}t	j|j��|jt4jkrt9d|z����d}~wwxYw|S)r&�r�rz$Name clash with existing message: %sN)�_create_tmpr��
BaseExceptionr�rr2�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�es        r"r,zMaildir.add$sS���#�#�%�%��	����w��1�1�1�1���	�	�	��N�N�����I�h�m�$�$�$��	����	�H�����g�~�.�.�	��'�'�)�)�F��Z�'�"2�"2�"4�"4�4�F����#�#�����F��F��w����
�.�.�4�4�T�Z�@�@��C���w�|�|�D�J���v�
�>�>���g�~�.�.�	L��H�X�]��g�&�&�x�}�5�5�w�7G�7G�7I�7I�J�
L�
L�
L�

	�
)����
�t�,�,�,��	�(�-�(�(�(�(��#�O�4�
/�
/�
/��	�(�-��.�.�.�.�.�
/�������	�	�	��I�h�m�$�$�$��w�%�,�&�&�(�)O�+/�*0�1�1�1������
	�����s@�-�9A&�!G�;H�+H�H�H�H�
I�AI�Ic��tjtj�|j|�|������dS�r/N)rr2rr�r�_lookupr0s  r"r2zMaildir.removeNs6��
�	�"�'�,�,�t�z�4�<�<��+<�+<�=�=�>�>�>�>�>r$c�b�	|�|��dS#ttf$rYdSwxYwr7)r2r8�FileNotFoundErrorr0s  r"r9zMaildir.discardRsG��	��K�K���������+�,�	�	�	��D�D�	���s��.�.c��|�|��}|�|��}|�|��}t|t��r|}n|}tj�|��}|j|vr)|j|�|j��dz}nd}|�	|��tj�
|j|��}	tj�
|j|||z��}
t|t��rFt	j|	tj�
|	��|���f��t	j|	|
��dS)r;r�r�N)r�r,r�rrrr�r�r�r9r�rr�r�r�r�)rr1r+�old_subpath�temp_key�temp_subpath�dominant_subpathr�r��tmp_path�new_paths           r"r=zMaildir.__setitem__ZsS���l�l�3�'�'���8�8�G�$�$���|�|�H�-�-���g�~�.�.�	+�+��� +������!1�2�2���:�)�)�)��Z�"2�"8�"8���"D�"D�R�"H�H�F�F��F����S�����7�<�<��
�L�9�9���7�<�<��
�F�C�&�L�A�A���g�~�.�.�	G��H�X��g�&�&�x�0�0�'�2B�2B�2D�2D�E�
G�
G�
G�
	�	�(�H�%�%�%�%�%r$c��|�|��}ttj�|j|��d��5}|jr|�|��}nt|��}ddd��n#1swxYwYtj�|��\}}|�	|��|j
|vr3|�|�|j
��d��|�tj�
tj�|j|������|S)rI�rbNr�)r��openrrr�rrrr��
set_subdirr��set_info�set_date�getmtime)rr1�subpath�f�msgr�r�s       r"rCzMaildir.get_messageusG���,�,�s�#�#��
�"�'�,�,�t�z�7�3�3�T�
:�
:�	(�a��}�
(��m�m�A�&�&���$�Q�'�'��		(�	(�	(�	(�	(�	(�	(�	(�	(�	(�	(����	(�	(�	(�	(�
�w�}�}�W�-�-�������v�����:�����L�L����D�J�/�/��3�4�4�4����R�W�%�%�b�g�l�l�4�:�w�&G�&G�H�H�I�I�I��
s�	-B�B�	Bc��ttj�|j|�|����d��5}|����td��cddd��S#1swxYwYdS)�2Return a bytes representation or raise a KeyError.r�r�N)	r�rrr�rr�r�r�r��rr1rs   r"rNzMaildir.get_bytes�s���
�"�'�,�,�t�z�4�<�<��+<�+<�=�=�t�
D�
D�	4���6�6�8�8�#�#�G�U�3�3�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s�-B�B�Bc��ttj�|j|�|����d��}t
|��S)rSr�)r�rrr�rr��
_ProxyFilers   r"rFzMaildir.get_file�s;�������d�j�$�,�,�s�*;�*;�<�<�d�C�C���!�}�}�r$c#�K�|���|jD]-}	|�|��n#t$rY�%wxYw|V��.dS�rUN)�_refreshr�r�r8r0s  r"rWzMaildir.iterkeys�ss�����
�
�����9�	�	�C�
����S�!�!�!�!���
�
�
���
�����I�I�I�I�	�	s�7�
A�Ac�<�|���||jvS�rj)r
r�r0s  r"rkzMaildir.__contains__�s���
�
�����d�i��r$c�R�|���t|j��S�rm)r
�lenr�rVs r"rnzMaildir.__len__�s���
�
�����4�9�~�~�r$c��dS)�"Write any pending changes to disk.Nr�rVs r"r~z
Maildir.flush�s	��	
�r$c��dS)r�Nr�rVs r"r�zMaildir.lock�����r$c��dS)r�Nr�rVs r"r�zMaildir.unlock�rr$c��dS�r�Nr�rVs r"r�z
Maildir.close�rr$c�>�g}tj|j��D]�}t|��dkrk|ddkr_tj�tj�|j|����r|�|dd�����|S)�Return a list of folder names.�r�.N)r�listdirrrr�isdirr��append�rrr�entrys   r"�list_folderszMaildir.list_folders�s������Z��
�+�+�	)�	)�E��5�z�z�A�~�~�%��(�c�/�/��w�}�}�R�W�\�\�$�*�e�<�<�=�=�#2��
�
�e�A�B�B�i�(�(�(���
r$c�|�ttj�|jd|z��|jd���S)z/Return a Maildir instance for the named folder.rF�r r!)rrrr�rr�r�folders  r"�
get_folderzMaildir.get_folder�s9���r�w�|�|�D�J��f��=�=�#�}�#�%�%�%�	%r$c�~�tj�|jd|z��}t	||j���}tj�|d��}tj�|��s?tjtj|tj	tj
zd����|S)z>Create a folder and return a Maildir instance representing it.r�r �
maildirfolder�)rrr�rrrr�r�r��O_CREAT�O_WRONLY)rr$rrr�maildirfolder_paths     r"�
add_folderzMaildir.add_folder�s����w�|�|�D�J��f��5�5����t�}�5�5�5���W�\�\�$��@�@���w�~�~�0�1�1�	��H�R�W�/���b�k�1I����
�
�
��
r$c��tj�|jd|z��}tjtj�|d����tjtj�|d����zD]3}t|��dks|ddkrt
d|z����4tj|��D]f}|dkr^|dkrX|dkrRtj�tj�||����rt
d|�d	|������gtj|d
���D]t\}}}|D]4}tj	tj�||�����5|D]4}tj
tj�||�����5�utj
|��dS)
�-Delete the named folder, which must be empty.rr�r�rrzFolder contains message(s): %sr�zFolder contains subdirectory 'z': F)�topdownN)rrr�rrrrr�walkr2�rmdir)rr$rr�root�dirs�filess       r"�
remove_folderzMaildir.remove_folder�s����w�|�|�D�J��f��5�5���Z�����T�5� 9� 9�:�:��Z�����T�5� 9� 9�:�:�;�	O�	O�E��5�z�z�A�~�~��q��S���#�$D�v�$M�N�N�N�"1��Z��%�%�	5�	5�E���~�~�%�5�.�.�U�e�^�^��w�}�}�R�W�\�\�$��6�6�7�7�6D�#�m�%+�V�V�U�U�%4�5�5�5��!#���u�!=�!=�!=�	4�	4��D�$���
5�
5���	�"�'�,�,�t�U�3�3�4�4�4�4��
4�
4��������d�E�2�2�3�3�3�3�
4�
�������r$c�`�tj��}tjtj�|jd����D]b}tj�|jd|��}|tj�|��z
dkrtj|���cdS)zDelete old files in "tmp".r�i@�N)�timerrrr�rr�r2)r�nowrrs    r"�cleanz
Maildir.clean�s����i�k�k���Z�����T�Z�� ?� ?�@�@�	 �	 �E��7�<�<��
�E�5�9�9�D��R�W�%�%�d�+�+�+�f�4�4��	�$�����	 �	 r$rc	�v�tj��}tj��}d|vr|�dd��}d|vr|�dd��}t	|���dt	|dzdz���dtj���d	tj�d
|��	}t
j	�
|jd|��}	tj|��nG#t$r:txjdz
c_	t|��cYS#t$rYnwxYwYnwxYwt!d|z���)
z=Create a file in the tmp subdirectory and open and return it.�/z\057r�z\072z.Mrg��.A�P�Qrr�z&Name clash prevented file creation: %s)r8�socket�gethostnamer��intr�getpidr�_countrr�r�statr��_create_carefully�FileExistsErrorr)rr9�hostnamer�rs     r"r�zMaildir._create_tmp�sQ���i�k�k���%�'�'���(�?�?��'�'��W�5�5�H��(�?�?��'�'��W�5�5�H�$'��H�H�H�H�c�#��'�C�-�.@�.@�.@�.@�"�)�+�+�+�+�$+�N�N�N�H�H�>���w�|�|�D�J��t�4�4��	��G�D�M�M�M�M�� �	�	�	��N�N�a��N�N�
�(��.�.�.�.�.��"�
�
�
���
������	����!�!I�!%�"&�'�'�	's6�
C"�"D&�D�D&�
D �D&�D � D&�%D&c��tj��|jz
d|jzkrWd}|jD]I}tj�|j|��}||j|krd}||j|<�J|sdSi|_|jD]�}|j|}t	j	|��D]�}tj�
||��}tj�|��r�B|�|j
��d}tj�
||��|j|<����tj��|_dS)z!Update table of contents mapping.�FTNr)r8r�r�r�rrr�r�r�rr�rr�r�)r�refreshr��mtimerr�pr�s        r"r
zMaildir._refreshsE���9�;�;���(�1�t�/?�+?�?�?��G��*�
1�
1����(�(���V�)<�=�=���4�+�F�3�3�3�"�G�+0�� ��(�(��
�����	��&�	>�	>�F��;�v�&�D���D�)�)�
>�
>���G�L�L��u�-�-���7�=�=��#�#����{�{�4�:�.�.�q�1��"$�'�,�,�v�u�"=�"=��	�$���
>��)�+�+����r$c�`�	tj�tj�|j|j|����r
|j|Sn#t$rYnwxYw|���	|j|S#t$rt
d|z��d�wxYw)z=Use TOC to return subpath for given key, or raise a KeyError.�No message with key: %sN)rrr�r�rr�r8r
r0s  r"r�zMaildir._lookup&s���	��w�~�~�b�g�l�l�4�:�t�y��~�F�F�G�G�
&��y��~�%�
&���	�	�	��D�	�����
�
����	F��9�S�>�!���	F�	F�	F��4�s�:�;�;��E�	F���s�AA�
A*�)A*�B�B-c���t|d��s|���|_		|t|j��S#t$rYdSt
$rY�4wxYw)z0Return the next message in a one-time iteration.�
_onetime_keysTN)rwrWrP�next�
StopIterationr8rVs r"rQzMaildir.next4s}���t�_�-�-�	1�!%�����D��	�
��D��!3�4�4�5�5�� �
�
�
��t�t��
�
�
���
���s�A�
A�	A�Ar�)r�r�r�r�r�r#r,r2r9r=rCrNrFrWrkrnr~r�r�r�r r%r-r6r:rCr�r
r�rQr�r$r"rrs�������(�(��E�����((�(�(�T?�?�?����&�&�&�6
�
�
�4�4�4�
���
��� � � �
���

�
�
�������������%�%�%�������& � � ��F�'�'�'�0"&�"&�"&�HF�F�F�
�
�
�
�
r$rc�v�eZdZdZdd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zdd�Zd�ZdS)�_singlefileMailboxzA single-file mailbox.NTc���t�||||��	t|jd��}n�#t$r�}|jt
jkr,|rt|jd��}nJt|j���|jt
jt
j	fvrt|jd��}n�Yd}~nd}~wwxYw||_
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)rrr r!rr�s      r"r#z_singlefileMailbox.__init__Ds�������t�W�f�5�5�5�	��T�Z��'�'�A�A���		�		�		��w�%�,�&�&��9��T�Z��/�/�A�A�,�T�Z�8�8�8���U�\�5�;�7�7�7����T�*�*�������������		������
���	������
�"������ ����s�5�
C�A7B;�;Cc��|���|�|��|j|j<|xjdz
c_d|_|jdz
S)r&rT)r��_append_messager�r[r]r*s  r"r,z_singlefileMailbox.add[sR��������$(�$8�$8��$A�$A��	�$�.�!����!����"����~��!�!r$c�N�|�|��|j|=d|_dS)r/TN)r�r�r\r0s  r"r2z_singlefileMailbox.removees(�����S�����I�c�N���
�
�
r$c�x�|�|��|�|��|j|<d|_dS)r;TN)r�rar�r\r<s   r"r=z_singlefileMailbox.__setitem__ks8�����S�����-�-�g�6�6��	�#����
�
�
r$c#�pK�|���|j���Ed{V��dSr	)r�r�rZrVs r"rWz_singlefileMailbox.iterkeysqs=�����������9�>�>�#�#�#�#�#�#�#�#�#�#�#r$c�<�|���||jvSr)r�r�r0s  r"rkz_singlefileMailbox.__contains__vs���������d�i��r$c�R�|���t|j��Sr)r�rr�rVs r"rnz_singlefileMailbox.__len__{s���������4�9�~�~�r$c�N�|jst|j��d|_dSdS)r�TN)r^�
_lock_filerZrVs r"r�z_singlefileMailbox.lock�s1���|�	 ��t�z�"�"�"��D�L�L�L�	 �	 r$c�N�|jrt|j��d|_dSdS�r�FN)r^�_unlock_filerZrVs r"r�z_singlefileMailbox.unlock�s1���<�	!����$�$�$� �D�L�L�L�	!�	!r$c	�J�|js$|jrt|j��d|_dS|j�J�|j�dd��|j���}||jkrtd|j|fz���t|j
��}	i}|�|��t|j�
����D]�}|j|\}}|j�|��|�|��|���}	|j�t!d||j���z
����}|sn|�|���[||���f||<|�|����|���|_n3#|���t)j|j���xYwt/|��|j���t)j|j
��j}	t)j|j|	��	t)j|j|j
��nH#t8$r;t)j|j
��t)j|j|j
��YnwxYwt;|j
d��|_||_d|_d|_|jrt?|jd�	��dSdS)
rFNrrIz4Size of mailbox file changed (expected %i, found %i)T�rV)�dotlock) r\r]�_sync_flushrZr�r��tellr_r�_create_temporaryr�_pre_mailbox_hook�sortedrZ�_pre_message_hookr��minr��_post_message_hookr�rr2r�r�rD�st_mode�chmodr�rFr�r^rh)
r�cur_len�new_file�new_tocr1�start�stop�	new_startr��modes
          r"r~z_singlefileMailbox.flush�s���}�	��!�
+��D�J�'�'�'�%*��"��F�
�y�$�$�$�	
�
����1�����*�/�/�#�#���d�'�'�'�$�&?�&*�&7��%A�&B�C�C�
C�%�T�Z�0�0��	��G��"�"�8�,�,�,��d�i�n�n�.�.�/�/�
2�
2��"�i��n���t��
����&�&�&��&�&�x�0�0�0�$�M�M�O�O�	�+�!�Z�_�_�S��15��
���8I�8I�1I�.K�.K�L�L�F�!����N�N�6�*�*�*�+�!*�8�=�=�?�?�;�����'�'��1�1�1�1� (�
�
���D����	��N�N�����I�h�m�$�$�$������H�����
�������w�t�z�"�"�*��
�����%�%�%�	1��I�h�m�T�Z�0�0�0�0���	1�	1�	1��I�d�j�!�!�!��I�h�m�T�Z�0�0�0�0�0�	1�����$�*�e�,�,��
���	���
�"����<�	2��t�z�5�1�1�1�1�1�1�	2�	2s �"D6G�0H	�-J
�
AK�Kc��dS)�,Called before writing the mailbox to file f.Nr��rrs  r"rrz$_singlefileMailbox._pre_mailbox_hook�rr$c��dS)�-Called before writing each message to file f.Nr�r�s  r"rtz$_singlefileMailbox._pre_message_hook�rr$c��dS��,Called after writing each message to file f.Nr�r�s  r"rvz%_singlefileMailbox._post_message_hook�rr$c��	|���	|jr|���|j���dS#|j���wxYw#	|jr|���|j���w#|j���wxYwxYwr)r~r^r�rZr�rVs r"r�z_singlefileMailbox.close�s���	#��J�J�L�L�L�
#��<�"��K�K�M�M�M��
� � �"�"�"�"�"���
� � �"�"�"�"�����	
#��<�"��K�K�M�M�M��
� � �"�"�"�"���
� � �"�"�"�"������s.�A+�A
�
A(�+C�-B"�C�"B=�=Cc��|j�|���|�/	|j|S#t$rtd|z��d�wxYwdS)z'Return (start, stop) or raise KeyError.NrN)r��
_generate_tocr8r0s  r"r�z_singlefileMailbox._lookup�so���9����� � � ��?�
J��y��~�%���
J�
J�
J��8�3�>�?�?�T�I�
J�����?s	�,�A
c�6�|j�dd��|j���}t|j��dkr!|js|�|j��	|�|j��|�|��}|�	|j��n)#t$r|j�|���wxYw|j���|j���|_
|S)z;Append message to mailbox and return (start, stop) offsets.rrI)rZr�rprr�r\rrrt�_install_messagervr��truncater~r_)rr+�before�offsetss    r"raz"_singlefileMailbox._append_message�s���
����1��������"�"���t�y�>�>�Q���t�}��

�"�"�4�:�.�.�.�	��"�"�4�:�.�.�.��+�+�G�4�4�G��#�#�D�J�/�/�/�/���	�	�	��J����'�'�'��	����	
�
������ �J�O�O�-�-����s
�/A	B9�9&Cr�r4)r�r�r�r�r#r,r2r=rWrkrnr�r�r~rrrtrvr�r�rar�r$r"rTrTAs������ � �!�!�!�!�."�"�"�������$�$�$�
 � � �
���
 � � �!�!�!�>2�>2�>2�@���������	#�	#�	#�J�J�J�J�����r$rTc�:�eZdZdZdZd�Zd
d�Zd
d�Zd
d�Zd�Z	d	S)�	_mboxMMDFzAn mbox or MMDF mailbox.Tc��|�|��\}}|j�|��|j����t
d���d��}|j�||j���z
��}|�	|�t
d����}|�
|��|�|dd���|S)rIr$rr�r�N)r�rZr�r�r�r��decoder�rp�_message_factory�set_unixfrom�set_from)rr1r|r}�	from_line�stringrs       r"rCz_mboxMMDF.get_message	s����l�l�3�'�'���t��
��������J�'�'�)�)�1�1�'�3�?�?�F�F�w�O�O�	�������
���(9�(9�!9�:�:���#�#�F�N�N�7�E�$B�$B�C�C������#�#�#����Y�q�r�r�]�#�#�#��
r$Fc�z�tj|�||�����|���S)�3Return a string representation or raise a KeyError.)�unixfromrK)rr1�from_s   r"rPz_mboxMMDF.get_strings8���'��N�N�3��&�&�(�(�(1�	�5�	�(A�(A�	Br$c�:�|�|��\}}|j�|��|s|j���|j�||j���z
��}|�td��S)r�r�)r�rZr�r�r�rpr�r�)rr1r�r|r}r�s      r"rNz_mboxMMDF.get_bytess���l�l�3�'�'���t��
��������	"��J���!�!�!�������
���(9�(9�!9�:�:���~�~�g�u�-�-�-r$c��|�|��\}}|j�|��|s|j���t	|j|j���|��S)rS)r�rZr�r��_PartialFilerp)rr1r�r|r}s     r"rFz_mboxMMDF.get_file"sg���l�l�3�'�'���t��
��������	"��J���!�!�!��D�J��
���(9�(9�4�@�@�@r$c��d}t|t��r|�|��}t|t��rM|�d��r8|�d��}|dkr|d|�}||dzd�}n�|}d}n�t|t��r-|����d��}d|z}nJt|tj
j��r+|���}|�|�d��}|�:dtjtj�������z}|j���}|j�|t&z��|�||j|j��|j���}||fS)	z1Format a message and blindly write to self._file.Nr�r�r�rr$rsFrom MAILER-DAEMON )r�r�r�r�r��find�_mboxMMDFMessage�get_fromr�rLr+r
�get_unixfromr8�asctime�gmtimerZrpr�r�r��
_mangle_from_)rr+r��newline�authorr|r}s       r"r�z_mboxMMDF._install_message*s����	��g�s�#�#�	5��+�+�G�4�4�G��g�u�%�%�	6�'�*<�*<�X�*F�*F�	6��l�l�5�)�)�G��"�}�}�#�H�W�H�-�	�!�'�A�+�,�,�/���#�	����
��!1�
2�
2�	6��%�%�'�'�.�.�w�7�7�F� �6�)�I�I�
����!6�
7�
7�	6��,�,�.�.�I��$�%�,�,�W�5�5�	���.���d�k�m�m�1L�1L�1S�1S�1U�1U�U�I��
���!�!���
����W�,�-�-�-����7�D�J��0B�C�C�C��z��� � ���t�}�r$Nr�)
r�r�r�r�r�rCrPrNrFr�r�r$r"r�r�s�������"�"��M�	�	�	�B�B�B�B�
.�.�.�.�A�A�A�A�����r$r�c�.�eZdZdZdZdZdd�Zd�Zd�ZdS)rzA classic mbox mailbox.TNc�X�t|_t�||||��dS)zInitialize an mbox mailbox.N)rr�r�r#rs    r"r#z
mbox.__init__P�*�� +������4��w��7�7�7�7�7r$c�:�|�t��dSr��r�r�r�s  r"rvzmbox._post_message_hookUs��	��������r$c�D�gg}}d}|j�d��	|j���}|j���}|�d��rzt|��t|��krB|r+|�|tt��z
��n|�|��|�|��d}nU|sC|r+|�|tt��z
��n|�|��n|tkrd}nd}��ttt||������|_t|j��|_|j���|_
dS)�0Generate key-to-(start, stop) table of contents.FrTr�N)rZr�rpr�r�rrr��dict�	enumerate�zipr�r[r_)r�starts�stops�last_was_empty�line_posr�s      r"r�zmbox._generate_tocYsx���B������
�������	'��z���(�(�H��:�&�&�(�(�D����x�(�(�
'��u�:�:��F���+�+�%�/����X��G���%<�=�=�=�=�
���X�.�.�.��
�
�h�'�'�'�!&����	
'�!�+��L�L��C��L�L�!8�9�9�9�9��L�L��*�*�*������!%���!&��/	'�0��3�v�u�#5�#5�6�6�7�7��	��T�Y����� �J�O�O�-�-����r$r�)	r�r�r�r�r�r�r#rvr�r�r$r"rrGsX������!�!��M��O�8�8�8�8�
���.�.�.�.�.r$rc�,�eZdZdZdd�Zd�Zd�Zd�ZdS)	r	zAn MMDF mailbox.NTc�X�t|_t�||||��dS)zInitialize an MMDF mailbox.N)rr�r�r#rs    r"r#z
MMDF.__init__~r�r$c�@�|�dtz��dS)r��Nr�r�s  r"rtzMMDF._pre_message_hook�s ��	���#�g�-�.�.�.�.�.r$c�P�|�tdztz��dS)r�r�Nr�r�s  r"rvzMMDF._post_message_hook�s%��	����-�-��7�8�8�8�8�8r$c�.�gg}}|j�d��d}	|}|j���}|j���}|�dt
z��r�|�|��	|}|j���}|j���}|dt
zkr+|�|tt
��z
��n|s|�|��n��n|sn��ttt||������|_t|j��|_|j�dd��|j���|_
dS)r�rTr�rIN)rZr�r�rpr�r�rrr�r�r�r�r[r_)rr�r��next_posr�r�s      r"r�zMMDF._generate_toc�st���B����
���������	��H��:�&�&�(�(�D��z���(�(�H����2�W�<�=�=�

��
�
�h�'�'�'�	�'�H��:�.�.�0�0�D�#�z���0�0�H��2�W�<�<�<����X��G���%<�=�=�=��!�����X�.�.�.��	���
��#	�$��3�v�u�#5�#5�6�6�7�7��	��T�Y������
����1���� �J�O�O�-�-����r$r�)r�r�r�r�r#rtrvr�r�r$r"r	r	{s[��������8�8�8�8�
/�/�/�9�9�9�.�.�.�.�.r$r	c��eZdZdZdd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)rzAn MH mailbox.NTc���t�||||��tj�|j��s�|r�tj|jd��tjtjtj�	|jd��tj
tjztjzd����nt|j���d|_dS)zInitialize an MH instance.r��
.mh_sequencesi�FN)rr#rrr�rr�r�r�r�r*�O_EXCLr+rr^rs    r"r#zMH.__init__�s�������t�W�f�5�5�5��w�~�~�d�j�)�)�	5��
5�����U�+�+�+���������d�j�/�!J�!J�!#��b�i�!7�"�+�!E�u�N�N�O�O�O�O�)���4�4�4�����r$c��|���}t|��dkrd}nt|��dz}tj�|jt|����}t|��}d}	|j	rt|��		|�||��nJ#t$r=|j	rt|��t|��d}tj|���wxYwt!|t"��r|�||��|j	rt|��n#|j	rt|��wwxYw|st|��n#|st|��wwxYw|S)r&rrFT)rZr�maxrrr�rr�rEr^rhr�r�rkr�r2r�r
�_dump_sequences)rr+rZ�new_keyr�r�closeds       r"r,zMH.add�s����y�y�{�{���t�9�9��>�>��G�G��$�i�i�!�m�G��7�<�<��
�C��L�L�9�9���h�'�'����	��|�
��1�
�
�
�
$�	��&�&�w��2�2�2�2��$�����|�(�$�Q������N�N�N�!�F��I�h�'�'�'�������g�y�1�1�;��(�(��'�:�:�:��<�$� ��O�O�O����<�$� ��O�O�O�O�$�����
��A�������
��A�����
�����s7�E*�B0�/D<�0AC7�7.D<�%E*�<E�E*�*E>c�P�tj�|jt	|����}	t|d��}|���tj|��dS#t$r-}|j	tj
krtd|z����d}~wwxYw)r/rVrNN)rrr�rr�r�r�r2r�r�rWr8)rr1rrr�s     r"r2z	MH.remove�s����w�|�|�D�J��C���1�1��		��T�5�!�!�A�
�G�G�I�I�I��I�d�O�O�O�O�O���	�	�	��w�%�,�&�&��8�3�>�?�?�?������		���s�A.�.
B%�8(B � B%c���tj�|jt	|����}	t|d��}n:#t$r-}|jtjkrtd|z����d}~wwxYw	|j
rt|��	tjtj|tj
tjz����|�||��t!|t"��r|�||��|j
rt'|��n#|j
rt'|��wwxYwt)|��dS#t)|��wxYw)r;rVrNN)rrr�rr�r�r�r�rWr8r^rhr�r+�O_TRUNCr�r�r
r�rkr�)rr1r+rrr�s      r"r=zMH.__setitem__�sU���w�|�|�D�J��C���1�1��	��T�5�!�!�A�A���	�	�	��w�%�,�&�&��8�3�>�?�?�?������		����
	��|�
��1�
�
�
�
$������r�{�R�Z�'?�@�@�A�A�A��"�"�7�A�.�.�.��g�y�1�1�7��(�(��#�6�6�6��<�$� ��O�O�O����<�$� ��O�O�O�O�$����
��N�N�N�N�N��K��N�N�N�N���s<�A�
A<�(A7�7A<�E�A?D-�E�-E�E�E+c��	|jrAttj�|jt
|����d��}n@ttj�|jt
|����d��}n:#t$r-}|jtj	krtd|z����d}~wwxYw|5|jrt|��	t|��}|jrt|��n#|jrt|��wwxYwddd��n#1swxYwY|������D]\}}||vr|�|���|S)rIrVr�rNN)r^r�rrr�rr�r�r�rWr8rhr
rk�
get_sequencesrh�add_sequence)rr1rr�rr��key_lists       r"rCzMH.get_message�s���		��|�
C������d�j�#�c�(�(�;�;�U�C�C��������d�j�#�c�(�(�;�;�T�B�B�����	�	�	��w�%�,�&�&��8�3�>�?�?�?������		����
�	$�	$��|�
��1�
�
�
�
$���l�l���<�$� ��O�O�O����<�$� ��O�O�O�O�$����
	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�#�0�0�2�2�8�8�:�:�	'�	'�N�D�(��h���� � ��&�&�&���
sB�BB�
C�(B=�=C�D-�D�.D-�D�D-�-D1�4D1c��	|jrAttj�|jt
|����d��}n@ttj�|jt
|����d��}n:#t$r-}|jtj	krtd|z����d}~wwxYw|5|jrt|��	|����
td��|jrt|��cddd��S#|jrt|��wwxYw#1swxYwYdS)rrVr�rNNr�)r^r�rrr�rr�r�r�rWr8rhr�r�r�rk�rr1rr�s    r"rNzMH.get_bytess���		��|�
C������d�j�#�c�(�(�;�;�U�C�C��������d�j�#�c�(�(�;�;�T�B�B�����	�	�	��w�%�,�&�&��8�3�>�?�?�?������		����
�	$�	$��|�
��1�
�
�
�
$��v�v�x�x�'�'���7�7��<�$� ��O�O�O�	$�	$�	$�	$�	$�	$�	$�	$���<�$� ��O�O�O�O�$����
	$�	$�	$�	$����	$�	$�	$�	$�	$�	$sB�BB�
C�(B=�=C�E
�,D.�E
�.E�E
�
E�Ec��	ttj�|jt|����d��}n:#t$r-}|jtjkrtd|z����d}~wwxYwt|��S)rSr�rNN)r�rrr�rr�r�r�rWr8rr�s    r"rFzMH.get_file-s���	��R�W�\�\�$�*�c�#�h�h�7�7��>�>�A�A���	�	�	��w�%�,�&�&��8�3�>�?�?�?������		����
�!�}�}�s�AA�
A:�
(A5�5A:c�|�ttd�tj|j��D������S)rUc3�\K�|]'}|����t|��V��(dSr4)�isdigitrA)�.0rs  r"�	<genexpr>zMH.iterkeys.<locals>.<genexpr>:sH����:�:�%�).�����:�3�u�:�:�:�:�:�:�:�:r$)�iterrsrrrrVs r"rWzMH.iterkeys8sG���F�:�:�2�:�d�j�3I�3I�:�:�:�:�:�;�;�	;r$c��tj�tj�|jt|������Sr)rrr�r�rr�r0s  r"rkzMH.__contains__=s.���w�~�~�b�g�l�l�4�:�s�3�x�x�@�@�A�A�Ar$c�^�tt|�������Sr)rrYrWrVs r"rnz
MH.__len__As ���4��
�
���(�(�)�)�)r$c��|jsUttj�|jd��d��|_t|j��d|_dSdS)r�r�rVTN)r^r�rrr�rrZrhrVs r"r�zMH.lockEsT���|�	 ��b�g�l�l�4�:��G�G��O�O�D�J��t�z�"�"�"��D�L�L�L�	 �	 r$c�z�|jr3t|j��t|j��|`d|_dSdSrj)r^rkrZr�rVs r"r�z	MH.unlockLsF���<�	!����$�$�$���
�#�#�#��
� �D�L�L�L�		!�	!r$c��dS)r}Nr�rVs r"r~zMH.flushTrr$c�@�|jr|���dSdSr)r^r�rVs r"r�zMH.closeXs'���<�	��K�K�M�M�M�M�M�	�	r$c���g}tj|j��D]Y}tj�tj�|j|����r|�|���Z|S)r)rrrrrr�rrs   r"r zMH.list_folders]sb�����Z��
�+�+�	%�	%�E��w�}�}�R�W�\�\�$�*�e�<�<�=�=�
%��
�
�e�$�$�$���
r$c�v�ttj�|j|��|jd���S)z+Return an MH instance for the named folder.Fr"�rrrr�rrr#s  r"r%z
MH.get_folderes4���"�'�,�,�t�z�6�2�2��-��7�7�7�	7r$c�t�ttj�|j|��|j���S)z:Create a folder and return an MH instance representing it.r'r�r#s  r"r-z
MH.add_folderjs2���"�'�,�,�t�z�6�2�2��-�)�)�)�	)r$c�P�tj�|j|��}tj|��}|dgkr3tjtj�|d����n|gkrnt
d|jz���tj|��dS)r/r�zFolder not empty: %sN)rrr�rrr2rr2)rr$r�entriess    r"r6zMH.remove_folderos����w�|�|�D�J��/�/���*�T�"�"����'�'�'��I�b�g�l�l�4��9�9�:�:�:�:�
��]�]��� 6��� C�D�D�D�
�������r$c
�H�
�i}ttj�|jd��dd���5}t|������
|D�]+}	|�d��\}}t��}|���D]�}|���r#|�	t|�����9d�|�d��D��\}}	|�t||	dz�������
fd	�t|��D��||<t||��d
kr||=��#t$r%t!d|���z���wxYw	ddd��n#1swxYwY|S)
z=Return a name-to-key-list dictionary to define each sequence.r��r�ASCII��encodingr�c3�4K�|]}t|��V��dSr4)rA)r��xs  r"r�z#MH.get_sequences.<locals>.<genexpr>�s(����*K�*K�a�3�q�6�6�*K�*K�*K�*K�*K�*Kr$�-rc���g|]}|�v�|��	Sr�r�)r�r1�all_keyss  �r"�
<listcomp>z$MH.get_sequences.<locals>.<listcomp>�s)���%=�%=�%=�S�,/�8�O�O�&)�,;�O�Or$rz"Invalid sequence specification: %sN)r�rrr�r�setrZr�r�r,rAr{�rangersrr�r�rstrip)r�resultsrr�r��contentsrZ�specr|r}r�s          @r"r�zMH.get_sequences{s������
�"�'�,�,�t�z�?�;�;�S�7�
S�
S�
S�	5�WX��4�9�9�;�;�'�'�H��
5�
5��5�%)�Z�Z��_�_�N�D�(��5�5�D� (��� 0� 0�@�@���<�<�>�>�@� �H�H�S��Y�Y�/�/�/�/�*K�*K�4�:�:�c�?�?�*K�*K�*K�K�E�4� �K�K��e�T�A�X�(>�(>�?�?�?�?�%=�%=�%=�%=�F�4�L�L�%=�%=�%=�G�D�M��7�4�=�)�)�Q�.�.�#�D�M���!�5�5�5�%�&J�&*�k�k�m�m�'4�5�5�5�5����
5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5�	5����	5�	5�	5�	5�&�s*�'F�!C6E�F�/F�F�F�Fc�D�ttj�|jd��dd���}	tjtj|jtjtjz����|�	��D]�\}}t|��dkr�|�|dz��d}d}tt|����D]^}|d	z
|kr|sd
}|�d��n7|rd}|�|�d|����n|�d
|z��|}�_|r&|�t|��dz����|�d����	t|��dS#t|��wxYw)z:Set sequences using the given name-to-key-list dictionary.r�zr+r�r�rr�NFrTr�� z %s�
)r�rrr�rr�r�r+r�rhrr�rsr�r�r�)r�	sequencesrr�rZ�prev�
completingr1s        r"�
set_sequenceszMH.set_sequences�s��������d�j�/�:�:�D�7�S�S�S��	��H�R�W�Q�V�R�[�2�:�%=�>�>�?�?�?�'�o�o�/�/�
"�
"�
��d��t�9�9��>�>������s�
�#�#�#���"�
�!�#�d�)�)�,�,�
�
�C��Q�w�$���)�)�)-�J��G�G�C�L�L�L��#�-�%*�
����4�4�4��� 5�6�6�6�6�������,�,�,��D�D��"��G�G�C��I�I��,�-�-�-�-��G�G�D�M�M�M�M�)
"�,
��N�N�N�N�N��K��N�N�N�N���s�EF�Fc�8�|���}d}g}|���D�]y}|dz
|k�rg|�||dzf��	tjtj�|jt|����tj�|jt|dz������tj	tj�|jt|������n�#ttf$r{tjtj�|jt|����tj�|jt|dz������YnwxYw|dz
}��{|dz|_
t|��dkrdS|���D])\}}|D]!\}}||vr|||�|��<�"�*|�|��dS)z?Re-name messages to eliminate numbering gaps. Invalidates keys.rrN)r�rWrrr�rr�rr��unlinkr�r�r�r[rrh�indexr�)	rr�r��changesr1r�r��oldr�s	         r"�packzMH.pack�s����&�&�(�(�	������=�=�?�?�	�	�C��Q�w�$�������T�A�X��/�/�/�B��G�B�G�L�L���S��X�X�>�>��G�L�L���S����]�]�C�C�E�E�E��I�b�g�l�l�4�:�s�3�x�x�@�@�A�A�A�A��	'��8�G�G�G��I�b�g�l�l�4�:�s�3�x�x�@�@� �g�l�l�4�:�s�4�!�8�}�}�E�E�G�G�G�G�G�G����

�A�I�D�D�������w�<�<�1����F�'�o�o�/�/�	8�	8�N�D�(�#�
8�
8���S��(�?�?�47�H�X�^�^�C�0�0�1��
8�	
���9�%�%�%�%�%s�A8D�B	F�Fc�:�|���}|���}|���D]9\}}||vr|�|���||vr||�|��=�:|D]}||vr|g||<�
|�|��dS)z;Inspect a new MHMessage and update sequences appropriately.N)r�rhrr�r�)rr+r1�pending_sequences�
all_sequencesr�r��sequences        r"r�zMH._dump_sequences�s���#�1�1�3�3���*�*�,�,�
�+�1�1�3�3�	2�	2�N�D�(��(�(�(�����$�$�$�$������X�^�^�C�0�0�1��)�	0�	0�H��}�,�,�+.�%�
�h�'�����=�)�)�)�)�)r$r�)r�r�r�r�r#r,r2r=rCrNrFrWrkrnr�r�r~r�r r%r-r6r�r�rr�r�r$r"rr�sm��������
�
�
�
� � � �D������0���2$�$�$�*	�	�	�;�;�;�
B�B�B�*�*�*� � � �!�!�!�������
���7�7�7�
)�)�)�

�
�
����0���:&�&�&�4*�*�*�*�*r$rc�|�eZdZdZehd���Zdd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�ZdS)rzAn Rmail-style Babyl mailbox.>�filed�edited�resent�unseen�deleted�answered�	forwardedNTc�N�t�||||��i|_dS)zInitialize a Babyl mailbox.N)rTr#�_labelsrs    r"r#zBabyl.__init__�s'���#�#�D�$���@�@�@�����r$c��t�||��}t|t��r|���|j|<|S)r&)rTr,r�r�
get_labelsr)rr+r1s   r"r,z	Babyl.add�sF�� �$�$�T�7�3�3���g�|�,�,�	5� '� 2� 2� 4� 4�D�L����
r$c�b�t�||��||jvr
|j|=dSdSr�)rTr2rr0s  r"r2zBabyl.remove�s=���!�!�$��,�,�,��$�,�����S�!�!�!��r$c��t�|||��t|t��r|���|j|<dSdS)r;N)rTr=r�rrrr<s   r"r=zBabyl.__setitem__�sT���&�&�t�S�'�:�:�:��g�|�,�,�	5� '� 2� 2� 4� 4�D�L�����	5�	5r$c���|�|��\}}|j�|��|j���t	j��}	|j���}|dtzks|sn/|�|�td�����Yt	j��}	|j���}|tks|sn/|�|�td�����V||j�	��z
}|dksJ�|j�
|��}|�td��}t|���|z��}	|	�
|�����||jvr |	�|j|��|	S)rIT�*** EOOH ***r�r)r�rZr�r�r�r�r�r�r�rpr�rr��set_visibler�
set_labels)
rr1r|r}�original_headersr��visible_headers�n�bodyrs
          r"rCzBabyl.get_message�s����l�l�3�'�'���t��
��������
�������:�<�<��	A��:�&�&�(�(�D����0�0�0��0���"�"�4�<�<���#?�#?�@�@�@�		A�
�*�,�,��	@��:�&�&�(�(�D��w���d����!�!�$�,�,�w��">�">�?�?�?�		@�
�4�:�?�?�$�$�$���A�v�v�v�v��z���q�!�!���|�|�G�U�+�+���+�4�4�6�6��=�>�>������0�0�2�2�3�3�3��$�,����N�N�4�<��,�-�-�-��
r$c��|�|��\}}|j�|��|j���t	j��}	|j���}|dtzks|sn/|�|�td�����Y	|j���}|tks|sn�(|�	��}||j�
��z
}|dksJ�|j�|��}|�td��}||zS)r�Trr�r)r�rZr�r�r�r�r�r�r�r�rpr�)	rr1r|r}rr��headersrr�s	         r"rNzBabyl.get_bytess7���l�l�3�'�'���t��
��������
�������:�<�<��	A��:�&�&�(�(�D����0�0�0��0���"�"�4�<�<���#?�#?�@�@�@�		A�
	��:�&�&�(�(�D��w���d���	�#�+�+�-�-���4�:�?�?�$�$�$���A�v�v�v�v��z���q�!�!���|�|�G�U�+�+����~�r$c��tj|�|���dt����S)rSr�)r�r�rNr�r�r0s  r"rFzBabyl.get_file)s.���z�$�.�.��-�-�5�5�e�W�E�E�F�F�Fr$c��|���t��}|j���D]}|�|���|�|j��t|��S)z4Return a list of user-defined labels in the mailbox.)r�r�rrdr{�difference_update�_special_labelsrY)r�labels�
label_lists   r"rzBabyl.get_labels-sm�������������,�-�-�/�/�	&�	&�J��M�M�*�%�%�%�%�� � ��!5�6�6�6��F�|�|�r$c��gg}}|j�d��d}g}	|}|j���}|j���}|dtzkr�t|��t|��kr*|�|tt��z
��|�|��d�|j���dd��d��D��}|�|��n�|dks|dtzkrKt|��t|��kr*|�|tt��z
��n-|s+|�|tt��z
��n���ttt||������|_tt|����|_t|j��|_
|j�dd	��|j���|_dS)
r�rTsc�^�g|]*}|����|�����+Sr�)�strip�r��labels  r"r�z'Babyl._generate_toc.<locals>.<listcomp>Ds<��:�:�:�E�+0�;�;�=�=�:�%�+�+�-�-�:�:�:r$rN�,�rI)rZr�r�rpr�rrr�r�r�r�r�rr[r_)rr�r�r��label_listsr�r�r"s        r"r�zBabyl._generate_toc6s����B����
�����������	��H��:�&�&�(�(�D��z���(�(�H��{�W�,�,�,��u�:�:��F���+�+��L�L��C��L�L�!8�9�9�9��
�
�h�'�'�'�:�:�+/�:�+>�+>�+@�+@����+D�+J�+J�4�+P�+P�:�:�:���"�"�6�*�*�*�*�����D�G�g�,=�$=�$=��u�:�:��F���+�+��L�L��C��L�L�!8�9�9�9���
����X��G���4�5�5�5��#	�$��3�v�u�#5�#5�6�6�7�7��	��I�k�2�2�3�3����T�Y������
����1���� �J�O�O�-�-����r$c���dtz}|dtzz
}|���}d�|D��}|dd�|��ztzz
}|dz
}|�|��dS)r�sBABYL OPTIONS:s
Version: 5c3�>K�|]}|���V��dSr4)r�r's  r"r�z*Babyl._pre_mailbox_hook.<locals>.<genexpr>Ys*����5�5�U�%�,�,�.�.�5�5�5�5�5�5r$sLabels:r)r*N)r�rr�r�)rr�babylr"s    r"rrzBabyl._pre_mailbox_hookTsz��!�G�+��
���(�(�����"�"��5�5�f�5�5�5��
��d�i�i��/�/�/�'�9�9��
����	��������r$c�@�|�dtz��dS)r��Nr�r�s  r"rtzBabyl._pre_message_hook^s��	����'�!�"�"�"�"�"r$c�@�|�tdz��dS)r�r*Nr�r�s  r"rvzBabyl._post_message_hookbs��	����'�!�"�"�"�"�"r$c��|j���}t|t���rg}g}|���D]6}||jvr|�|���!|�|���7|j�d��|D]1}|j�d|���z���2|j�d��|D]4}|j�d|���zdz���5|j�t��n"|j�dtz��t|tjj���rKtj��}tj�|dd��}|�|��|�d��	|���}|j�|�d
t����|d
ks|sn�Q|j�dtz��t|t��r�tj��}	tj�|	dd��}
|
�|�����	|	���}|j�|�d
t����|d
ks|sn�Qng|�d��	|���}|j�|�d
t����|d
ks|sn�Q	|�d��}|sn4|j�|�d
t�����L�n�t|t.t0tjf���r�t|tj��r/t5jd
t8d��|���}t|t0��r|�|��}|�d��dz}|dz
dkr�|j�|d|��d
t����|j�dtz��|j�|d|��d
t����|j�||d��d
t�����nU|j�dtztz��|j�|�d
t�����n�tA|d���r�tA|d��r"t5jdt8d��|j!}|���}
d	}	|���}|�"d��r|dd�d
z}n"|�"d��r
|dd�d
z}|j�|�d
t����|d
ks|s=|r:d}|j�dtz��|�|
��nn��	|���}|sn�|�"d��r|dd�tz}nO|�"d��r|dd�tz}n'|�"d
��r|dd�tz}|j�|����ntGdtI|��z���|j���}||fS)z0Write message contents and return (start, stop).�1s, s,,� r)s1,,FrTr�rrmr�r�s

rIr�Nr�r�r�r�r�r�r�)%rZrpr�rrr!rr�r�r�rLr+r
r�r�r�r�r�r�r�r��get_visibler�r�r�r�r�r�r�r�r�r�rwr�r�r�r�)rr+r|�special_labelsr"r(�orig_buffer�orig_generatorr��
vis_buffer�
vis_generatorr��
body_start�original_pos�
first_passr}s                r"r�zBabyl._install_messagefsK���
���!�!���g�|�,�,�	/��N��F� �+�+�-�-�
)�
)���D�0�0�0�"�)�)�%�0�0�0�0��M�M�%�(�(�(�(��J���T�"�"�"�'�
9�
9���
� � �������!7�8�8�8�8��J���U�#�#�#��
?�
?���
� � �������!6��!=�>�>�>�>��J���W�%�%�%�%��J���V�g�-�.�.�.��g�u�}�4�5�5�S	H��*�,�,�K�"�_�;�;�K��PQ�R�R�N��"�"�7�+�+�+����Q����
�"�+�+�-�-���
� � ����e�W�!=�!=�>�>�>��5�=�=��=��	
�

�J���_�w�6�7�7�7��'�<�0�0�
��Z�\�\�
� %�� >� >�z�5�RS� T� T�
��%�%�g�&9�&9�&;�&;�<�<�<��%�.�.�0�0�D��J�$�$�T�\�\�%��%A�%A�B�B�B��u�}�}�D�}��	��� � ��#�#�#��&�/�/�1�1�D��J�$�$�T�\�\�%��%A�%A�B�B�B��u�}�}�D�}��	�

A�$�)�)�$�/�/������
� � �����w�!?�!?�@�@�@�	
A��
��%��b�k�!:�
;�
;�3	H��'�2�;�/�/�
-��
�*�+=�q�B�B�B�!�*�*�,�,���'�3�'�'�
9��/�/��8�8�� ���g�.�.��2�J��A�~��#�#��
� � ���*��!5�!=�!=�e�W�!M�!M�N�N�N��
� � ��7�!:�;�;�;��
� � ���*��!5�!=�!=�e�W�!M�!M�N�N�N��
� � �����!5�!=�!=�e�W�!M�!M�N�N�N�N��
� � ��7�!:�W�!D�E�E�E��
� � ������!@�!@�A�A�A�A�
�W�j�
)�
)�#	H��w��)�)�
)��
�5�6H�!�M�M�M�!�.��"�<�<�>�>�L��J�
��'�'�)�)���=�=��)�)�-�����9�u�,�D�D��]�]�5�)�)�-�����9�u�,�D��
� � ����e�W�!=�!=�>�>�>��5�=�=��=�!��%*�
��
�(�(��7�)B�C�C�C����\�2�2�2�2��
�
'��'�'�)�)������=�=��)�)�/�����9�w�.�D�D��]�]�5�)�)�/�����9�w�.�D�D��]�]�5�)�)�/�����9�w�.�D��
� � ��&�&�&�
'���6��g���F�G�G�G��z��� � ���t�}�r$r�)r�r�r�r��	frozensetr!r#r,r2r=rCrNrFrr�rrrtrvr�r�r$r"rr�s������'�'��i�!B�!B�!B�C�C�O�����
���"�"�"�5�5�5����8���,G�G�G����.�.�.�<���#�#�#�#�#�#�i�i�i�i�ir$rc�&�eZdZdZdd�Zd�Zd�ZdS)r
z0Message with mailbox-format-specific properties.Nc�h�t|tjj��rU|�tj|����t|t��r|�|��dSdSt|t��r)|�tj	|����dSt|t��r)|�tj|����dSt|tj
��r)|�tj|����dSt|d��r)|�tj|����dS|�&tjj�|��dSt%dt'|��z���)zInitialize a Message instance.r�Nr�)r�rLr+r
�_become_message�copy�deepcopy�_explain_tor�rMr��message_from_stringr��
TextIOWrapper�message_from_filerw�message_from_binary_filer#r�r�r*s  r"r#zMessage.__init__�s����g�u�}�4�5�5�	H�� � ���w�!7�!7�8�8�8��'�7�+�+�
*��#�#�D�)�)�)�)�)�
*�
*�
���
'�
'�	H�� � ��!9�'�!B�!B�C�C�C�C�C�
���
%�
%�		H�� � ��!:�7�!C�!C�D�D�D�D�D�
���!1�
2�
2�	H�� � ��!8��!A�!A�B�B�B�B�B�
�W�f�
%�
%�	H�� � ��!?��!H�!H�I�I�I�I�I�
�_��M�!�*�*�4�0�0�0�0�0��6��g���F�G�G�Gr$c�n�t|dg��}|jD]}||vr|j||j|<�dS)z0Assume the non-format-specific state of message.�_type_specific_attributesN)�getattr�__dict__)rr+�
type_specificr�s    r"rAzMessage._become_message�sP����)D�b�I�I�
��$�	=�	=�D��=�(�(�&-�&6�t�&<��
�d�#��	=�	=r$c�N�t|t��rdStd���)z:Copy format-specific state to message insofar as possible.Nz Cannot convert to specified type)r�r
r�r*s  r"rDzMessage._explain_to�s)���g�w�'�'�	@��F��>�?�?�?r$r4)r�r�r�r�r#rArDr�r$r"r
r
�sU������:�:�H�H�H�H�&=�=�=�@�@�@�@�@r$r
c�d�eZdZdZgd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�ZdS)rz)Message with Maildir-specific properties.)�_subdir�_info�_dateNc��d|_d|_tj��|_t�||��dS)z%Initialize a MaildirMessage instance.r�r�N)rPrQr8rRr
r#r*s  r"r#zMaildirMessage.__init__�s9�������
��Y�[�[��
�����w�'�'�'�'�'r$c��|jS)zReturn 'new' or 'cur'.)rPrVs r"r�zMaildirMessage.get_subdirs
���|�r$c�P�|dks|dkr	||_dStd|z���)zSet subdir to 'new' or 'cur'.r�r�z!subdir must be 'new' or 'cur': %sN)rPr�)rr�s  r"r�zMaildirMessage.set_subdirs2���U�?�?�f��o�o�!�D�L�L�L��@�6�I�J�J�Jr$c�X�|j�d��r|jdd�SdS)�*Return as a string the flags that are set.�2,rINr�)rQr�rVs r"�	get_flagszMaildirMessage.get_flagss/���:� � ��&�&�	��:�a�b�b�>�!��2r$c�Z�dd�t|����z|_dS)�)Set the given flags and unset all others.rXr�N)r�rsrQ)r�flagss  r"�	set_flagszMaildirMessage.set_flagss$���B�G�G�F�5�M�M�2�2�2��
�
�
r$c��|�d�t|�����t|��z����dS�z.Set the given flag(s) without changing others.r�N�r]r�r�rY�r�flags  r"�add_flagzMaildirMessage.add_flag�C�����r�w�w�s�4�>�>�#3�#3�4�4�s�4�y�y�@�A�A�B�B�B�B�Br$c���|���rY|�d�t|�����t|��z
����dSdS)�7Unset the given string flag(s) without changing others.r�N)rYr]r�r�ras  r"�remove_flagzMaildirMessage.remove_flagsb���>�>���	G��N�N�2�7�7�3�t�~�~�'7�'7�#8�#8�3�t�9�9�#D�E�E�F�F�F�F�F�	G�	Gr$c��|jS)z<Return delivery date of message, in seconds since the epoch.)rRrVs r"r�zMaildirMessage.get_date"�
���z�r$c�r�	t|��|_dS#t$rtd|z��d�wxYw)z9Set delivery date of message, in seconds since the epoch.zcan't convert to float: %sN)�floatrRr�r�)r�dates  r"r�zMaildirMessage.set_date&sN��	K��t���D�J�J�J���	K�	K�	K��8�4�?�@�@�d�J�	K���s��6c��|jS)z%Get the message's "info" as a string.)rQrVs r"r�zMaildirMessage.get_info-rir$c�|�t|t��r	||_dStdt	|��z���)z Set the message's "info" string.zinfo must be a string: %sN)r�r�rQr�r�)r�infos  r"r�zMaildirMessage.set_info1s:���d�C� � �	F��D�J�J�J��7�$�t�*�*�D�E�E�Er$c���t|t��rw|�|�����|�|�����|�|�����dSt|t��r�t|�����}d|vr|�
d��|���dkr|�
d��d|vr|�
d��d|vr|�
d��d|vr|�
d��|�d	tj
|�������dSt|t��rpt|�����}d|vr|�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$��rdSt'dt)|��z���)z;Copy Maildir-specific state to message insofar as possible.�S�Rr��O�T�D�F�A�
MAILER-DAEMONr
�replied�flaggedrrr=r
�$Cannot convert to specified type: %sN)r�rr]rYr�r�r�r�r�r�rcr�r8r�r
r�r�	add_labelr
r�r�)rr+r\s   r"rDzMaildirMessage._explain_to8s����g�~�.�.�'	+����d�n�n�.�.�/�/�/����t���0�0�1�1�1����T�]�]�_�_�-�-�-�-�-�
��!1�
2�
2�#	+�����(�(�)�)�E��e�|�|�� � ��%�%�%���� � �E�)�)�� � ��%�%�%��e�|�|�� � ��%�%�%��e�|�|�� � ��%�%�%��e�|�|�� � ��%�%�%����_�d�k�$�-�-�/�/�.J�.J�K�K�K�K�K�
���
+�
+�	+�����(�(�)�)�E��%����$�$�X�.�.�.��e�|�|��$�$�Y�/�/�/��e�|�|��$�$�Y�/�/�/�/�/��|�
���
.�
.�	+�����(�(�)�)�E��%����!�!�(�+�+�+��e�|�|��!�!�)�,�,�,��e�|�|��!�!�*�-�-�-��e�|�|��!�!�+�.�.�.�.�.��|�
���
)�
)�	+��D��B� ��M�M�*�+�+�
+r$r4)r�r�r�r�rJr#r�r�rYr]rcrgr�r�r�r�rDr�r$r"rr�s�������3�3� =� =� =��(�(�(�(����K�K�K����3�3�3�C�C�C�G�G�G�
���K�K�K����F�F�F�)+�)+�)+�)+�)+r$rc�L�eZdZdZdgZdd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�ZdS)
r�z/Message with mbox- or MMDF-specific properties.�_fromNc�6�|�dd��t|tjj��rH|���}|�2|�d��r|�|dd���t�||��dS)z'Initialize an mboxMMDFMessage instance.rxTNzFrom r�)r�r�rLr+r
r�r�r#)rr+r�s   r"r#z_mboxMMDFMessage.__init__is����
�
�o�t�,�,�,��g�u�}�4�5�5�	,��+�+�-�-�H��#��(;�(;�G�(D�(D�#��
�
�h�q�r�r�l�+�+�+�����w�'�'�'�'�'r$c��|jS)z Return contents of "From " line.)r~rVs r"r�z_mboxMMDFMessage.get_fromrrir$c�z�|�1|durtj��}|dtj|��zz
}||_dS)z>Set "From " line, formatting and appending time_ if specified.NTr�)r8r�r�r~)rr��time_s   r"r�z_mboxMMDFMessage.set_fromvs@������}�}���
�
���S�4�<��.�.�.�.�E���
�
�
r$c�\�|�dd��|�dd��zS)rW�Statusr��X-Status)rArVs r"rYz_mboxMMDFMessage.get_flags~s)���x�x��"�%�%�����R�(@�(@�@�@r$c��t|��}d\}}dD] }||vr||z
}|�|���!dD] }||vr||z
}|�|���!|d�t|����z
}	|�d|��n&#t
$r|�d|��YnwxYw	|�d|��dS#t
$r|�d|��YdSwxYw)r[)r�r�)rrrs)rurvrwr�r�r�N)r�r2r�rs�replace_headerr8�
add_header)rr\�status_flags�
xstatus_flagsrbs     r"r]z_mboxMMDFMessage.set_flags�sI���E�
�
��&,�#��m��	#�	#�D��u�}�}���$�����T�"�"�"��#�	#�	#�D��u�}�}���%�
����T�"�"�"����������/�/�/�
�	4�����,�7�7�7�7���	4�	4�	4��O�O�H�l�3�3�3�3�3�	4����	7����
�M�:�:�:�:�:���	7�	7�	7��O�O�J�
�6�6�6�6�6�6�	7���s$�B� B;�:B;�?C� C;�:C;c��|�d�t|�����t|��z����dSr_r`ras  r"rcz_mboxMMDFMessage.add_flag�rdr$c���d|vsd|vrY|�d�t|�����t|��z
����dSdS)rfr�r�r�Nr`ras  r"rgz_mboxMMDFMessage.remove_flag�s`���t���z�T�1�1��N�N�2�7�7�3�t�~�~�'7�'7�#8�#8�3�t�9�9�#D�E�E�F�F�F�F�F� 2�1r$c��t|t���r:t|�����}d|vr|�d��d|vr|�d��d|vr|�d��d|vr|�d��d|vr|�d��|d	=|d
=d�|������dd
���}	|�	tjtj
|d������d
S#ttf$rYd
SwxYwt|t ��rP|�|�����|�|�����d
St|t&��rtt|�����}d|vr|�d��d|vr|�d��d|vr|�d��|d	=|d
=d
St|t*��rtt|�����}d|vr|�d��d|vr|�d��d|vr|�d��|d	=|d
=d
St|t.��rd
St1dt3|��z���)zACopy mbox- or MMDF-specific state to message insofar as possible.rsr�rvrwrrrqrurt�statuszx-statusr����Nz%a %b %d %H:%M:%S %Yr
ryrzrrr{)r�rr�rYr�rcr�r�r�r��calendar�timegmr8�strptimer��
OverflowErrorr�r]r�r
r�rr|r
r�r�)rr+r\�
maybe_dates    r"rDz_mboxMMDFMessage._explain_to�s/���g�~�.�.�/	+�����(�(�)�)�E��e�|�|��"�"�5�)�)�)��e�|�|�� � ��%�%�%��e�|�|�� � ��%�%�%��e�|�|�� � ��%�%�%��e�|�|�� � ��%�%�%���!��
�#����$�-�-�/�/�"7�"7�"9�"9�"�#�#�">�?�?�J�
�� � �����z�6L�2N�2N�"O�"O�P�P�P�P�P���
�.�
�
�
����
����
��!1�
2�
2�	+����d�n�n�.�.�/�/�/����T�]�]�_�_�-�-�-�-�-�
���
+�
+�	+�����(�(�)�)�E��%����$�$�X�.�.�.��e�|�|��$�$�Y�/�/�/��e�|�|��$�$�Y�/�/�/���!��
�#�#�#�
���
.�
.�	+�����(�(�)�)�E��%����!�!�(�+�+�+��e�|�|��!�!�)�,�,�,��e�|�|��!�!�*�-�-�-���!��
�#�#�#�
���
)�
)�	+��D��B� ��M�M�*�+�+�
+s�=:D9�9E�
Er4)
r�r�r�r�rJr#r�r�rYr]rcrgrDr�r$r"r�r�ds�������9�9�!(�	��(�(�(�(��������A�A�A�7�7�7�,C�C�C�G�G�G�
1+�1+�1+�1+�1+r$r�c��eZdZdZdS)rz&Message with mbox-specific properties.N�r�r�r�r�r�r$r"rr��������0�0�0�0r$rc�>�eZdZdZdgZd
d�Zd�Zd�Zd�Zd�Z	d	�Z
dS)r
z$Message with MH-specific properties.�
_sequencesNc�J�g|_t�||��dS)z!Initialize an MHMessage instance.N)r�r
r#r*s  r"r#zMHMessage.__init__�s%���������w�'�'�'�'�'r$c� �|jdd�S)z4Return a list of sequences that include the message.N)r�rVs r"r�zMHMessage.get_sequences�s����q�q�q�!�!r$c�.�t|��|_dS)z3Set the list of sequences that include the message.N)rYr�)rr�s  r"r�zMHMessage.set_sequences�s���y�/�/����r$c��t|t��r'||jvr|j�|��dSdSt	dt|��z���)z8Add sequence to list of sequences including the message.zsequence type must be str: %sN)r�r�r�rr�r��rrs  r"r�zMHMessage.add_sequence�sb���h��$�$�	N��t��.�.���&�&�x�0�0�0�0�0�/�.��;�d�8�n�n�L�M�M�Mr$c�^�	|j�|��dS#t$rYdSwxYw)zARemove sequence from the list of sequences including the message.N)r�r2r�r�s  r"�remove_sequencezMHMessage.remove_sequence�sE��	��O�"�"�8�,�,�,�,�,���	�	�	��D�D�	������
,�,c�b�t|t��r�t|�����}d|vr|�d��n*|�d��|�d��d|vr|�d��d|vr|�d��d
Sd
St|t��r�t|�����}d|vr|�d��n|�d	��d|vr|�d��d|vr|�d
��d
Sd
St|t��r.|���D]}|�|���d
St|t��rWt|�����}d|vr|�
d��d|vr|�
d��d
Sd
St|t��rd
Stdt|��z���)z6Copy MH-specific state to message insofar as possible.r
r�rqrzrvryrr�ROrsrwrr{N)r�rr�r�r�rcr�r
r�rr|r
r�r�)rr+r�rs    r"rDzMHMessage._explain_to�sp���g�~�.�.�"	+��D�.�.�0�0�1�1�I��9�$�$��"�"�5�)�)�)�)��"�"�5�)�)�)�� � ��%�%�%��I�%�%�� � ��%�%�%��I�%�%�� � ��%�%�%�%�%�&�%�
��!1�
2�
2�	+��D�.�.�0�0�1�1�I��y�(�(�� � ��&�&�&�&�� � ��%�%�%��I�%�%�� � ��%�%�%��I�%�%�� � ��%�%�%�%�%�&�%�
���
+�
+�
	+� �.�.�0�0�
/�
/���$�$�X�.�.�.�.�
/�
/�
���
.�
.�
	+��D�.�.�0�0�1�1�I��9�$�$��!�!�(�+�+�+��I�%�%��!�!�*�-�-�-�-�-�&�%�
���
)�
)�	+��D��B� ��M�M�*�+�+�
+r$r4)r�r�r�r�rJr#r�r�r�r�rDr�r$r"r
r
�s�������.�.�!-���(�(�(�(�
"�"�"�*�*�*�N�N�N����$+�$+�$+�$+�$+r$r
c�R�eZdZdZddgZdd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
dS)rz'Message with Babyl-specific properties.r�_visibleNc�p�g|_t��|_t�||��dS)z#Initialize a BabylMessage instance.N)rr
r�r#r*s  r"r#zBabylMessage.__init__&s0������	�	��
�����w�'�'�'�'�'r$c� �|jdd�S)z'Return a list of labels on the message.N)rrVs r"rzBabylMessage.get_labels,s���|�A�A�A��r$c�.�t|��|_dS)z&Set the list of labels on the message.N)rYr)rr"s  r"rzBabylMessage.set_labels0s���F�|�|����r$c��t|t��r'||jvr|j�|��dSdSt	dt|��z���)z+Add label to list of labels on the message.zlabel must be a string: %sN)r�r�rrr�r��rr(s  r"r|zBabylMessage.add_label4sb���e�S�!�!�	H��D�L�(�(���#�#�E�*�*�*�*�*�)�(��8�4��;�;�F�G�G�Gr$c�^�	|j�|��dS#t$rYdSwxYw)z4Remove label from the list of labels on the message.N)rr2r�r�s  r"�remove_labelzBabylMessage.remove_label<sE��	��L����&�&�&�&�&���	�	�	��D�D�	���r�c�*�t|j��S)z3Return a Message representation of visible headers.�r
r�rVs r"r5zBabylMessage.get_visibleCs���t�}�%�%�%r$c�.�t|��|_dS)z2Set the Message representation of visible headers.Nr�)r�visibles  r"rzBabylMessage.set_visibleGs����(�(��
�
�
r$c���|j���D]0}||vr"|j�|||���(|j|=�1dD]}||vr||jvr|||j|<� dS)z9Update and/or sensibly generate a set of visible headers.)�Date�FromzReply-To�To�CC�SubjectN)r�rZr�)r�headers  r"�update_visiblezBabylMessage.update_visibleKs����m�(�(�*�*�	*�	*�F���~�~��
�,�,�V�T�&�\�B�B�B�B��M�&�)�)�I�	5�	5�F���~�~�&��
�"=�"=�(,�V���
�f�%��	5�	5r$c���t|t��r�t|�����}d|vr|�d��n*|�d��|�d��d|vsd|vr|�d��d|vr|�d��d	|vr|�d
��dSdSt|t��r�t|�����}d|vr|�d��n|�d��d	|vr|�d
��d|vr|�d��dSdSt|t��rWt|�����}d|vr|�d��d|vr|�d��dSdSt|t��rU|�
|�����|���D]}|�|���dSt|t��rdStdt|��z���)z9Copy Babyl-specific state to message insofar as possible.r
r�rqr
r	r=rrrrrtr�rsrurwryr{N)r�rr�rr�rcr�r
r�rrr5r|r
r�r�)rr+r"r(s    r"rDzBabylMessage._explain_toVs����g�~�.�.�%	+�����*�*�+�+�F��6�!�!��"�"�5�)�)�)�)��"�"�5�)�)�)�� � ��%�%�%��f�$�$��F�(:�(:�� � ��%�%�%��V�#�#�� � ��%�%�%��F�"�"�� � ��%�%�%�%�%�#�"�
��!1�
2�
2�	+�����*�*�+�+�F��v�%�%�� � ��&�&�&�&�� � ��%�%�%��F�"�"�� � ��%�%�%��V�#�#�� � ��%�%�%�%�%�$�#�
���
+�
+�	+�����*�*�+�+�F��6�!�!��$�$�X�.�.�.��V�#�#��$�$�Y�/�/�/�/�/�$�#�
���
.�
.�	+����� 0� 0� 2� 2�3�3�3����*�*�
)�
)���!�!�%�(�(�(�(�
)�
)�
���
)�
)�	+��D��B� ��M�M�*�+�+�
+r$r4)r�r�r�r�rJr#rrr|r�r5rr�rDr�r$r"rr!s�������1�1�!*�J� 7��(�(�(�(����$�$�$�H�H�H����&�&�&�)�)�)�	5�	5�	5�'+�'+�'+�'+�'+r$rc��eZdZdZdS)rz&Message with MMDF-specific properties.Nr�r�r$r"rr�r�r$rc��eZdZdZdd�Zdd�Zdd�Zdd�Zdd�Zd�Z	d	�Z
dd�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zed���Zee��ZdS)rzA read-only wrapper of a file.Nc�\�||_|�|���|_dS||_dS)zInitialize a _ProxyFile.N)rZrp�_pos)rr�poss   r"r#z_ProxyFile.__init__�s,����
��;������D�I�I�I��D�I�I�Ir$c�B�|�||jj��S�zRead bytes.)�_readrZr��r�sizes  r"r�z_ProxyFile.read�s���z�z�$��
��0�0�0r$c�B�|�||jj��Sr�)r�rZ�read1r�s  r"r�z_ProxyFile.read1�s���z�z�$��
� 0�1�1�1r$c�B�|�||jj��S)zRead a line.)r�rZr�r�s  r"r�z_ProxyFile.readline�s���z�z�$��
� 3�4�4�4r$c�v�g}|D]3}|�|��|�|t|��z}|dkrn�4|S)zRead multiple lines.Nr)rr)r�sizehintrrr�s    r"�	readlinesz_ProxyFile.readlines�sR�����	�	�D��M�M�$�����#��C��I�I�%���q�=�=��E���
r$c#�BK�	|���}|sdS|V��)zIterate over lines.TN)r�)rr�s  r"rbz_ProxyFile.__iter__�s3����	��=�=�?�?�D��
����J�J�J�		r$c��|jS)zReturn the position.)r�rVs r"rpz_ProxyFile.tell�s
���y�r$rc���|dkr|j�|j��|j�||��|j���|_dS)zChange position.rN�rZr�r�rp�r�offset�whences   r"r�z_ProxyFile.seek�sN���Q�;�;��J�O�O�D�I�&�&�&��
�����'�'�'��J�O�O�%�%��	�	�	r$c��t|d��r:	t|jd��r|j���|`dS#|`wxYwdS)zClose the file.rZr�N)rwrZr�rVs r"r�z_ProxyFile.close�sa���4��!�!�	�
��4�:�w�/�/�'��J�$�$�&�&�&��J�J�J��D�J�����	�	s�.A�Ac��|�d}|j�|j��||��}|j���|_|S)z"Read size bytes using read_method.Nr�r�)rr��read_methodrrs    r"r�z_ProxyFile._read�sI���<��D��
����	�"�"�"���T�"�"���J�O�O�%�%��	��
r$c��|S)z$Context management protocol support.r�rVs r"�	__enter__z_ProxyFile.__enter__�s���r$c�.�|���dSr4)r�)r�excs  r"�__exit__z_ProxyFile.__exit__�s���
�
�����r$c�4�|j���Sr4)rZ�readablerVs r"r�z_ProxyFile.readable�����z�"�"�$�$�$r$c�4�|j���Sr4)rZ�writablerVs r"r�z_ProxyFile.writable�r�r$c�4�|j���Sr4)rZ�seekablerVs r"r�z_ProxyFile.seekable�r�r$c�4�|j���Sr4)rZr~rVs r"r~z_ProxyFile.flush�s���z���!�!�!r$c�l�t|d��sdSt|jd��sdS|jjS)NrZTr�F)rwrZr�rVs r"r�z_ProxyFile.closed�s=���t�W�%�%�	��4��t�z�8�,�,�	��5��z� � r$r4�r)r�r�r�r�r#r�r�r�r�rbrpr�r�r�r�r�r�r�r�r~�propertyr�r�rr�r�r$r"rr�sQ������(�(�����1�1�1�1�2�2�2�2�5�5�5�5�	�	�	�	�������&�&�&�&�������������%�%�%�%�%�%�%�%�%�"�"�"��!�!��X�!�$��L�1�1���r$rc�4�eZdZdZd	d�Zd�Zd
d�Zd�Zd�ZdS)r�z&A read-only wrapper of part of a file.Nc�Z�t�|||��||_||_dS)zInitialize a _PartialFile.N)rr#�_start�_stop)rrr|r}s    r"r#z_PartialFile.__init__�s,�����D�!�U�+�+�+������
�
�
r$c�F�t�|��|jz
S)z*Return the position with respect to start.)rrpr�rVs r"rpz_PartialFile.tell�s�����t�$�$�t�{�2�2r$rc��|dkr|j|_d}n|dkr|j|_d}t�|||��dS)z8Change position, possibly with respect to start or stop.rrrIN)r�r�r�rr�r�s   r"r�z_PartialFile.seek�sN���Q�;�;���D�I��F�F�
�q�[�[��
�D�I��F�����f�f�-�-�-�-�-r$c��|j|jz
}|dkrdS|�|dks||kr|}t�|||��S)z;Read size bytes using read_method, honoring start and stop.rr$)r�r�rr�)rr�r��	remainings    r"r�z_PartialFile._readsR���J���*�	���>�>��3��<�4�!�8�8�t�i�'7�'7��D�����d�K�8�8�8r$c�.�t|d��r|`dSdS)NrZ)rwrZrVs r"r�z_PartialFile.close	s)���4��!�!�	��
�
�
�	�	r$)NNr�)	r�r�r�r�r#rpr�r�r�r�r$r"r�r��so������0�0�����3�3�3�.�.�.�.�9�9�9�����r$r�Tc��d}	tr�	tj|tjtjz��nT#t$rG}|jt
jt
jt
jfvrtd|j
z����d}~wwxYw|�r"	t|j
dz��}|���n8#t$r+}|jt
jt
jfvrYd}~dS�d}~wwxYw		tj|j
|j
dz��d}tj|j
��n;#t t"f$r'tj|j
|j
dz��d}YnwxYwdSdS#t&$r1tj|j
��td|j
z���wxYwdS#trtj|tj��|rtj|j
dz���xYw)z(Lock file f using lockf and dot locking.Fzlockf: lock unavailable: %sN�.lockTzdot lock unavailable: %s)�fcntl�lockf�LOCK_EX�LOCK_NBr�r��EAGAINrXrYrr�rqr�rr�r�r�r�r�rFr2�LOCK_UN)rrn�dotlock_doner��pre_locks     r"rhrhsD���L�%��	�
���A�u�}�u�}�<�=�=�=�=���
�
�
��7�u�|�U�\�5�;�G�G�G�,�-J�-.�V�.4�5�5�5������
�����	1�
�,�Q�V�g�-=�>�>����� � � � ���
�
�
��7�u�|�U�[�9�9�9��F�F�F�F�F������	
����

1�-��G�H�M�1�6�G�+;�<�<�<�#'�L�
�I�h�m�,�,�,�,��	'��8�(�(�(��I�h�m�Q�V�g�-=�>�>�>�#'�L�L�L�(����-�,�!�L��#�
1�
1�
1��	�(�-�(�(�(�(�)C�)*��*0�1�1�1�
1����%	1�	1��,��	*��K��5�=�)�)�)��	(��I�a�f�w�&�'�'�'�
���s��F4�,9�F4�
B
�AB�B
�
F4�+B=�<F4�=
C2�C-�&F4�,C-�-C2�2F4�7$D5�E4�55E-�*E4�,E-�-E4�4;F/�/F4�4AG;c���trtj|tj��tj�|jdz��rtj|jdz��dSdS)z*Unlock file f using lockf and dot locking.r�N)r�r�r�rrr�r�r2�rs r"rkrk:sb���&�
��A�u�}�%�%�%�	�w�~�~�a�f�w�&�'�'�$�
�	�!�&�7�"�#�#�#�#�#�$�$r$c���tj|tjtjztjzd��}	t|d��tj|��S#tj|��wxYw)zCCreate a file if it doesn't exist and open for reading and writing.r)rV)rr�r*r��O_RDWRr�)r�fds  r"rErEAsX��	���r�z�B�I�-��	�9�5�	A�	A�B���D�%� � �
�����������������s�A � A6c
��t|�dttj�����dtj���dtj������S)zBCreate a temp file based on path and open for reading and writing.r)rErAr8r?r@rrB)rs r"rqrqIsR���d�d�d�C��	���4D�4D�4D�4D�.4�.@�.B�.B�.B�.B�.0�i�k�k�k�;�<�<�<r$c��|���ttd��r(tj|�����dSdS)z0Ensure changes to file f are physically on disk.�fsyncN)r~rwrr��filenor�s r"roroOsI���G�G�I�I�I��r�7����
�������������r$c�L�t|��|���dS)z:Close file f, ensuring all changes are physically on disk.N)ror�r�s r"r�r�Us����N�N�N��G�G�I�I�I�I�Ir$c��eZdZdZdS)rz"Raised for module-specific errors.Nr�r�r$r"rr[s������,�,�,�,r$rc��eZdZdZdS)rz:The specified mailbox does not exist and won't be created.Nr�r�r$r"rr^s������D�D�D�Dr$rc��eZdZdZdS)rz>The specified mailbox is not empty and deletion was requested.Nr�r�r$r"rras������H�H�H�Hr$rc��eZdZdZdS)rz)Another process caused an action to fail.Nr�r�r$r"rrd�������3�3�3�3r$rc��eZdZdZdS)rz)A file appears to have an invalid format.Nr�r�r$r"rrgrr$r)T)2r�rr8r�r?r�rBr�rL�
email.message�email.generatorr�rD�typesrr��ImportError�__all__r�r�rrrTr�rr	rrr+r
rr�rr
rrrr�rhrkrErqror��	Exceptionrrrrrr�r$r"�<module>r
s}��J�J�
�	�	�	���������
�
�
�
�������������������������	�	�	�	�������������L�L�L�L�������E�E�E�����A�A�A��

�*�
�
�G�
$�
$��f2�f2�f2�f2�f2�f2�f2�f2�Rs�s�s�s�s�g�s�s�s�l	���������F@�@�@�@�@�"�@�@�@�F1.�1.�1.�1.�1.�9�1.�1.�1.�h*.�*.�*.�*.�*.�9�*.�*.�*.�Zn*�n*�n*�n*�n*��n*�n*�n*�b	v�v�v�v�v��v�v�v�r"@�"@�"@�"@�"@�e�m�#�"@�"@�"@�Jj+�j+�j+�j+�j+�W�j+�j+�j+�Zn+�n+�n+�n+�n+�w�n+�n+�n+�b1�1�1�1�1�"�1�1�1�E+�E+�E+�E+�E+��E+�E+�E+�P\+�\+�\+�\+�\+�7�\+�\+�\+�~1�1�1�1�1�"�1�1�1�b2�b2�b2�b2�b2�b2�b2�b2�J$�$�$�$�$�:�$�$�$�N(�(�(�(�T$�$�$����<�<�<�������-�-�-�-�-�I�-�-�-�E�E�E�E�E��E�E�E�I�I�I�I�I�E�I�I�I�4�4�4�4�4��4�4�4�4�4�4�4�4�%�4�4�4�4�4s�?�A	�A	

Zerion Mini Shell 1.0