Your IP : 18.118.208.127


Current Path : /opt/alt/python311/lib64/python3.11/__pycache__/
Upload File :
Current File : //opt/alt/python311/lib64/python3.11/__pycache__/mailbox.cpython-311.opt-2.pyc

�

c��f�3��t�	ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
Z
ddlZddlm
Z
	ddlZn
#e$rdZYnwxYwgd�Zej�d��ZGd�d��ZGd�de��ZGd	�d
e��ZGd�de��ZGd
�de��ZGd�de��ZGd�de��ZGd�de��ZGd�dejj��ZGd�de��ZGd�de��ZGd�de��ZGd�de��Z Gd�d e��Z!Gd!�d"e��Z"Gd#�d$��Z#Gd%�d&e#��Z$d8d(�Z%d)�Z&d*�Z'd+�Z(d,�Z)d-�Z*Gd.�d/e+��Z,Gd0�d1e,��Z-Gd2�d3e,��Z.Gd4�d5e,��Z/Gd6�d7e,��Z0dS)9�N)�GenericAlias)�Mailbox�Maildir�mbox�MH�Babyl�MMDF�Message�MaildirMessage�mboxMessage�	MHMessage�BabylMessage�MMDFMessage�Error�NoSuchMailboxError�
NotEmptyError�ExternalClashError�FormatError�asciic���eZdZ	d#d�Zd�Zd�Zd�Zd�Zd�Zd$d	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd$d�Zd�Zd$d�Zd�Zd�Zd�Zd�Zd �Z d!Z!d%d"�Z"e#e$��Z%dS)&rNTc��	tj�tj�|����|_||_dS�N)�os�path�abspath�
expanduser�_path�_factory��selfr�factory�creates    �./opt/alt/python311/lib64/python3.11/mailbox.py�__init__zMailbox.__init__%s5��,��W�_�_�R�W�%7�%7��%=�%=�>�>��
���
�
�
�c�"�	td����Nz&Method must be implemented by subclass��NotImplementedError�r �messages  r#�addzMailbox.add*s��2�!�"J�K�K�Kr%c�"�	td���r'r(�r �keys  r#�removezMailbox.remove.s��K�!�"J�K�K�Kr%c�0�|�|��dSr)r0r.s  r#�__delitem__zMailbox.__delitem__2s�����C�����r%c�V�		|�|��dS#t$rYdSwxYwr)r0�KeyErrorr.s  r#�discardzMailbox.discard5sD��5�	��K�K���������	�	�	��D�D�	���s��
(�(c�"�	td���r'r(�r r/r+s   r#�__setitem__zMailbox.__setitem__<s��L�!�"J�K�K�Kr%c�T�		|�|��S#t$r|cYSwxYwr)�__getitem__r4)r r/�defaults   r#�getzMailbox.get@sB��G�	��#�#�C�(�(�(���	�	�	��N�N�N�	���s��'�'c���	|js|�|��Stj|�|����5}|�|��cddd��S#1swxYwYdSr)r�get_message�
contextlib�closing�get_file)r r/�files   r#r:zMailbox.__getitem__Gs���K��}�	+��#�#�C�(�(�(��#�D�M�M�#�$6�$6�7�7�
+�4��}�}�T�*�*�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+�
+����
+�
+�
+�
+�
+�
+s�A'�'A+�.A+c�"�	td���r'r(r.s  r#r>zMailbox.get_messageOs��B�!�"J�K�K�Kr%c�v�	tj|�|�������Sr��email�message_from_bytes�	get_bytes�	as_stringr.s  r#�
get_stringzMailbox.get_stringSs2��	*��'����s�(;�(;�<�<�F�F�H�H�Hr%c�"�	td���r'r(r.s  r#rHzMailbox.get_bytesZs��F�!�"J�K�K�Kr%c�"�	td���r'r(r.s  r#rAzMailbox.get_file^s��D�!�"J�K�K�Kr%c�"�	td���r'r(�r s r#�iterkeyszMailbox.iterkeysbs��+�!�"J�K�K�Kr%c�F�	t|�����Sr)�listrOrNs r#�keyszMailbox.keysfs��$��D�M�M�O�O�$�$�$r%c#�vK�	|���D] }	||}n#t$rY�wxYw|V��!dSr�rOr4�r r/�values   r#�
itervalueszMailbox.itervaluesjse����3��=�=�?�?�	�	�C�
��S�	�����
�
�
���
�����K�K�K�K�	�	��$�
1�1c�*�|���Sr)rWrNs r#�__iter__zMailbox.__iter__ss����� � � r%c�F�	t|�����Sr)rQrWrNs r#�valueszMailbox.valuesvs��:��D�O�O�%�%�&�&�&r%c#�zK�	|���D]"}	||}n#t$rY�wxYw||fV��#dSrrTrUs   r#�	iteritemszMailbox.iteritemszsm����<��=�=�?�?�	�	�C�
��S�	�����
�
�
���
������,�����	�	rXc�F�	t|�����Sr)rQr^rNs r#�itemsz
Mailbox.items�s��G��D�N�N�$�$�%�%�%r%c�"�	td���r'r(r.s  r#�__contains__zMailbox.__contains__�s��G�!�"J�K�K�Kr%c�"�	td���r'r(rNs r#�__len__zMailbox.__len__�s��8�!�"J�K�K�Kr%c�`�	|���D]}|�|���dSr)rRr5r.s  r#�clearz
Mailbox.clear�s;��"��9�9�;�;�	�	�C��L�L������	�	r%c�j�		||}n#t$r|cYSwxYw|�|��|Sr)r4r5)r r/r;�results    r#�popzMailbox.pop�sP��A�	��#�Y�F�F���	�	�	��N�N�N�	�������S�����
s���c��	|���D]}||�|��fcStd���)NzNo messages in mailbox)rOrir4r.s  r#�popitemzMailbox.popitem�sF��D��=�=�?�?�	5�	5�C�����#���'�'�'�'��3�4�4�4r%c��	t|d��r|���}n't|d��r|���}n|}d}|D]\}}	|||<�#t$rd}Y�wxYw|rtd���dS)Nr^r`FTzNo message with key(s))�hasattrr^r`r4)r �arg�source�bad_keyr/r+s      r#�updatezMailbox.update�s���B��3��$�$�	��]�]�_�_�F�F�
�S�'�
"�
"�	��Y�Y�[�[�F�F��F���"�	�	�L�C��
�#��S�	�	���
�
�
�����
�����	5��3�4�4�4�	5�	5s�A�A-�,A-c�"�	td���r'r(rNs r#�flushz
Mailbox.flush�s��4�!�"J�K�K�Kr%c�"�	td���r'r(rNs r#�lockzMailbox.lock�s���!�"J�K�K�Kr%c�"�	td���r'r(rNs r#�unlockzMailbox.unlock�s��1�!�"J�K�K�Kr%c�"�	td���r'r(rNs r#�closez
Mailbox.close�s��*�!�"J�K�K�Kr%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��dSdSdSt|t t"tjf��r�t|tj��r/t'jdt*d��|���}t|t ��r|�|��}|r|�dd��}|�dt��}|�
|��|jr6|�t��s|�
t��dSdSdSt1|d���r-t1|d��r"t'jd	t*d��|j}d}	|���}|�d��r|dd�dz}n"|�d
��r
|dd�dz}|snW|r"|�d��r
d|dd�z}|�dt��}|�
|��|}��|jr8|r8|�t��s |�
t��dSdSdSdSt9dt;|��z���)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)�
isinstancerFr+r
�io�BytesIO�	generator�BytesGenerator�flatten�seekr��replace�linesep�write�_append_newline�endswith�str�bytes�StringIO�warnings�warn�DeprecationWarning�getvaluer~rmr��readline�
startswith�	TypeError�type)	r r+�target�mangle_from_r��gen�data�lastline�lines	         r#�
_dump_messagezMailbox._dump_message�s���3��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%�NTr�F)&�__name__�
__module__�__qualname__r$r,r0r2r5r8r<r:r>rJrHrArOrRrWrZr\r^r`rbrdrfrirkrqrsrurwryr~r�r��classmethodr�__class_getitem__�r%r#rr"sE������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��eZdZ	dZdd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdZd�Zd�Zd�Zd�ZdS)r�:NTc�t�	t�||||��tj�|jd��tj�|jd��tj�|jd��d�|_tj�|j��sb|rLtj|jd��|j�	��D]}tj|d���nt|j���i|_ddd�|_d|_
d|_dS)	N�tmp�new�cur)r�r�r��r)r�r�g�������?)rr$rr�joinr�_paths�exists�mkdirr\r�_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)N�r�rz$Name clash with existing message: %s)�_create_tmpr��
BaseExceptionryrr0�name�_sync_closer�r�
get_subdir�colon�get_infor�basename�splitr�r�utime�getatime�get_date�link�AttributeError�PermissionError�rename�OSError�errno�EEXISTr)r r+�tmp_file�subdir�suffix�uniq�dest�es        r#r,zMaildir.add$sV��2��#�#�%�%��	����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|�|������dSr)rr0rr�r�_lookupr.s  r#r0zMaildir.removeNs9��K�
�	�"�'�,�,�t�z�4�<�<��+<�+<�=�=�>�>�>�>�>r%c�d�		|�|��dS#ttf$rYdSwxYwr)r0r4�FileNotFoundErrorr.s  r#r5zMaildir.discardRsJ��5�	��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)Nr�r�)r�r,r�rrrr�r�r�r5r�rr�r�r�r�)r r/r+�old_subpath�temp_key�temp_subpath�dominant_subpathr�r��tmp_path�new_paths           r#r8zMaildir.__setitem__ZsV��L��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)N�rbr�)r��openrrr�rrrr��
set_subdirr��set_info�set_date�getmtime)r r/�subpath�f�msgr�r�s       r#r>zMaildir.get_messageusJ��B��,�,�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)Nr�r�)	r�rrr�rr�r�r�r��r r/r�s   r#rHzMaildir.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)Nr�)r�rrr�rr��
_ProxyFiler�s   r#rAzMaildir.get_file�s>��D������d�j�$�,�,�s�*;�*;�<�<�d�C�C���!�}�}�r%c#�K�	|���|jD]-}	|�|��n#t$rY�%wxYw|V��.dSr)�_refreshr�r�r4r.s  r#rOzMaildir.iterkeys�sv����+��
�
�����9�	�	�C�
����S�!�!�!�!���
�
�
���
�����I�I�I�I�	�	s�8�
A�Ac�>�	|���||jvSr)r�r�r.s  r#rbzMaildir.__contains__�s��G��
�
�����d�i��r%c�T�	|���t|j��Sr)r��lenr�rNs r#rdzMaildir.__len__�s ��8��
�
�����4�9�~�~�r%c��	dSrr�rNs r#rsz
Maildir.flush�s��0�	
�r%c��	dSrr�rNs r#ruzMaildir.lock�s
����r%c��	dSrr�rNs r#rwzMaildir.unlock�s
��1��r%c��	dSrr�rNs r#ryz
Maildir.close�s
��*��r%c�@�	g}tj|j��D]�}t|��dkrk|ddkr_tj�tj�|j|����r|�|dd�����|S)N�r�.)r�listdirrr�r�isdirr��append�r rh�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)NrF�r!r")rrrr�rr�r �folders  r#�
get_folderzMaildir.get_folder�s<��=��r�w�|�|�D�J��f��=�=�#�}�#�%�%�%�	%r%c��	tj�|jd|z��}t	||j���}tj�|d��}tj�|��s?tjtj|tj	tj
zd����|S)Nr�r!�
maildirfolder�)rrr�rrrr�ryr��O_CREAT�O_WRONLY)r rrrh�maildirfolder_paths     r#�
add_folderzMaildir.add_folder�s���L��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
|��dS)Nrr�r�rrzFolder contains message(s): %sr�zFolder contains subdirectory 'z': F)�topdown)rrr�rrr�rr�walkr0�rmdir)r r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�b�	tj��}tjtj�|jd����D]b}tj�|jd|��}|tj�|��z
dkrtj|���cdS)Nr�i@�)�timerrrr�rr�r0)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	�x�	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���)
N�/z\057r�z\072z.Mrg��.A�P�Qrr�z&Name clash prevented file creation: %s)r�socket�gethostnamer��intr�getpidr�_countrr�r�statr��_create_carefully�FileExistsErrorr)r r �hostnamer�rs     r#r�zMaildir._create_tmp�sT��K��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)N�FTr)rr�r�r�rrr�r�r�rr�rr�r�)r �refreshr��mtimerr�pr�s        r#r�zMaildir._refreshsH��/��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�b�		tj�tj�|j|j|����r
|j|Sn#t$rYnwxYw|���	|j|S#t$rt
d|z��d�wxYw�N�No message with key: %s)rrr�r�rr�r4r�r.s  r#r�zMaildir._lookup&s���K�	��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)N�
_onetime_keys)rmrOr8�next�
StopIterationr4rNs r#r9zMaildir.next4s���>��t�_�-�-�	1�!%�����D��	�
��D��!3�4�4�5�5�� �
�
�
��t�t��
�
�
���
���s�A�
A �	A �A r�)r�r�r�r�r$r,r0r5r8r>rHrArOrbrdrsrurwryrr
rrr!r*r�r�r�r9r�r%r#rrs�������(��E�����((�(�(�T?�?�?����&�&�&�6
�
�
�4�4�4�
���
��� � � �
���

�
�
�������������%�%�%�������& � � ��F�'�'�'�0"&�"&�"&�HF�F�F�
�
�
�
�
r%rc�t�eZdZ	dd�Zd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zdd�Zd�ZdS)�_singlefileMailboxNTc���	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)N�rb+zwb+r�rF)rr$r�rr�r��ENOENTr�EACCES�EROFS�_filer��	_next_key�_pending�
_pending_sync�_locked�_file_length)r rr!r"r�r�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�6�
C�A7B<�<Cc��	|���|�|��|j|j<|xjdz
c_d|_|jdz
S)NrT)r��_append_messager�rCrEr*s  r#r,z_singlefileMailbox.add[sU��2�������$(�$8�$8��$A�$A��	�$�.�!����!����"����~��!�!r%c�P�	|�|��|j|=d|_dSr�)r�r�rDr.s  r#r0z_singlefileMailbox.removees+��K����S�����I�c�N���
�
�
r%c�z�	|�|��|�|��|j|<d|_dSr�)r�rIr�rDr7s   r#r8z_singlefileMailbox.__setitem__ks;��L����S�����-�-�g�6�6��	�#����
�
�
r%c#�rK�	|���|j���Ed{V��dSr)r�r�rRrNs r#rOz_singlefileMailbox.iterkeysqs@����+��������9�>�>�#�#�#�#�#�#�#�#�#�#�#r%c�>�	|���||jvSr)r�r�r.s  r#rbz_singlefileMailbox.__contains__vs��G��������d�i��r%c�T�	|���t|j��Sr)r�r�r�rNs r#rdz_singlefileMailbox.__len__{s ��8��������4�9�~�~�r%c�P�	|jst|j��d|_dSdSr�)rF�
_lock_filerBrNs r#ruz_singlefileMailbox.lock�s4����|�	 ��t�z�"�"�"��D�L�L�L�	 �	 r%c�P�	|jrt|j��d|_dSdS�NF)rF�_unlock_filerBrNs r#rwz_singlefileMailbox.unlock�s4��1��<�	!����$�$�$� �D�L�L�L�	!�	!r%c	�:�	|js$|jrt|j��d|_dS|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)	NFrr0z4Size of mailbox file changed (expected %i, found %i)T�r>)�dotlock) rDrE�_sync_flushrBr��tellrGr�_create_temporaryr�_pre_mailbox_hook�sortedr�rR�_pre_message_hookr��minr��_post_message_hookryrr0r�r�r+�st_mode�chmodr�r-r�rFrP)
r �cur_len�new_file�new_tocr/�start�stop�	new_startr��modes
          r#rsz_singlefileMailbox.flush�s��0��}�	��!�
+��D�J�'�'�'�%*��"��F�	
�
����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
�	K
c��	dSrr��r r�s  r#rZz$_singlefileMailbox._pre_mailbox_hook��
��:��r%c��	dSrr�ris  r#r\z$_singlefileMailbox._pre_message_hook�s
��;��r%c��	dSrr�ris  r#r^z%_singlefileMailbox._post_message_hook�rjr%c��		|���	|jr|���|j���dS#|j���wxYw#	|jr|���|j���w#|j���wxYwxYwr)rsrFrwrBryrNs r#ryz_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�wxYwdSr5)r��
_generate_tocr4r.s  r#r�z_singlefileMailbox._lookup�sr��5��9����� � � ��?�
J��y��~�%���
J�
J�
J��8�3�>�?�?�T�I�
J�����?s	�-�Ac�8�	|j�dd��|j���}t|j��dkr!|js|�|j��	|�|j��|�|��}|�	|j��n)#t$r|j�|���wxYw|j���|j���|_
|S)Nrr0)rBr�rXr�r�rDrZr\�_install_messager^r��truncatersrG)r r+�before�offsetss    r#rIz"_singlefileMailbox._append_message�s��I��
����1��������"�"���t�y�>�>�Q���t�}��

�"�"�4�:�.�.�.�	��"�"�4�:�.�.�.��+�+�G�4�4�G��#�#�D�J�/�/�/�/���	�	�	��J����'�'�'��	����	
�
������ �J�O�O�-�-����s
�0A	B:�:&C r�r)r�r�r�r$r,r0r8rOrbrdrurwrsrZr\r^ryr�rIr�r%r#r<r<As������ �!�!�!�!�."�"�"�������$�$�$�
 � � �
���
 � � �!�!�!�>2�>2�>2�@���������	#�	#�	#�J�J�J�J�����r%r<c�8�eZdZ	dZd�Zd	d�Zd	d�Zd	d�Zd�ZdS)
�	_mboxMMDFTc��	|�|��\}}|j�|��|j����t
d���d��}|j�||j���z
��}|�	|�t
d����}|�
|��|�|dd���|S)Nr%rr�r�)r�rBr�r�r�r��decoder�rX�_message_factory�set_unixfrom�set_from)r r/rdre�	from_line�stringr�s       r#r>z_mboxMMDF.get_message	s���B��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�|�	tj|�||�����|���S)N)�unixfromrE)r r/�from_s   r#rJz_mboxMMDF.get_strings;��A��'��N�N�3��&�&�(�(�(1�	�5�	�(A�(A�	Br%c�<�	|�|��\}}|j�|��|s|j���|j�||j���z
��}|�td��S�Nr�)r�rBr�r�r�rXr�r�)r r/r�rdrer}s      r#rHz_mboxMMDF.get_bytess���A��l�l�3�'�'���t��
��������	"��J���!�!�!�������
���(9�(9�!9�:�:���~�~�g�u�-�-�-r%c��	|�|��\}}|j�|��|s|j���t	|j|j���|��Sr)r�rBr�r��_PartialFilerX)r r/r�rdres     r#rAz_mboxMMDF.get_file"sj��D��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)Nr�r�r�rr%rsFrom MAILER-DAEMON )r�r�r~r�r��find�_mboxMMDFMessage�get_fromr{rFr+r
�get_unixfromr�asctime�gmtimerBrXr�r�r��
_mangle_from_)r r+r|�newline�authorrdres       r#rqz_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>rJrHrArqr�r%r#rvrvs~������"��M�	�	�	�B�B�B�B�
.�.�.�.�A�A�A�A�����r%rvc�,�eZdZ	dZdZdd�Zd�Zd�ZdS)rTNc�Z�	t|_t�||||��dSr)rryrvr$rs    r#r$z
mbox.__init__P�-��)� +������4��w��7�7�7�7�7r%c�<�	|�t��dSr�r�r�ris  r#r^zmbox._post_message_hookUs��:�	��������r%c�F�	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)NFrTr�)rBr�rXr�r�r�rr��dict�	enumerate�zipr�rCrG)r �starts�stops�last_was_empty�line_posr�s      r#rozmbox._generate_tocYs{��>��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^ror�r%r#rrGsU������!��M��O�8�8�8�8�
���.�.�.�.�.r%rc�*�eZdZ	dd�Zd�Zd�Zd�ZdS)r	NTc�Z�	t|_t�||||��dSr)rryrvr$rs    r#r$z
MMDF.__init__~r�r%c�B�	|�dtz��dS�N�r�ris  r#r\zMMDF._pre_message_hook�s#��;�	���#�g�-�.�.�.�.�.r%c�R�	|�tdztz��dSr�r�ris  r#r^zMMDF._post_message_hook�s(��:�	����-�-��7�8�8�8�8�8r%c�0�	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)NrTr�r0)rBr�r�rXr�r�rr�r�r�r�r�rCrG)r r�r��next_posr�r�s      r#rozMMDF._generate_toc�sw��>��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\r^ror�r%r#r	r	{sX�������8�8�8�8�
/�/�/�9�9�9�.�.�.�.�.r%r	c��eZdZ	dd�Zd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)rNTc���	t�||||��tj�|j��s�|r�tj|jd��tjtjtj�	|jd��tj
tjztjzd����nt|j���d|_dS)Nr��
.mh_sequencesi�F)rr$rrr�rr�ryr�r�r�O_EXCLrrrFrs    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)NrrFT)rRr��maxrrr�rr�r,rFrPr�r�rSr�r0r�r
�_dump_sequences)r r+rR�new_keyr�r��closeds       r#r,zMH.add�s���2��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+�B1�0D=�1AC8�8.D=�&E+�=E�E+�+E?c�R�	tj�|jt	|����}	t|d��}|���tj|��dS#t$r-}|j	tj
krtd|z����d}~wwxYw�Nr>r6)rrr�rr�r�ryr0r�r�r?r4)r r/rr�r�s     r#r0z	MH.remove�s���K��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&�9(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)|��wxYwr�)rrr�rr�r�r�r�r?r4rFrPryr�O_TRUNCr�r�r
r�rSr�)r r/r+rr�r�s      r#r8zMH.__setitem__�sX��L��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=�(A8�8A=�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)Nr>r�r6)rFr�rrr�rr�r�r�r?r4rPr
rS�
get_sequencesr`�add_sequence)r r/r�r�r�r��key_lists       r#r>zMH.get_message�s���B�		��|�
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.�.D2�5D2c��		|jrAttj�|jt
|����d��}n@ttj�|jt
|����d��}n:#t$r-}|jtj	krtd|z����d}~wwxYw|5|jrt|��	|����
td��|jrt|��cddd��S#|jrt|��wwxYw#1swxYwYdS)Nr>r�r6r�)rFr�rrr�rr�r�r�r?r4rPr�r�r�rS�r r/r�r�s    r#rHz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)Nr�r6)r�rrr�rr�r�r�r?r4r�r�s    r#rAzMH.get_file-s���D�	��R�W�\�\�$�*�c�#�h�h�7�7��>�>�A�A���	�	�	��w�%�,�&�&��8�3�>�?�?�?������		����
�!�}�}�s�AA�
A;�(A6�6A;c�~�	ttd�tj|j��D������S)Nc3�\K�|]'}|����t|��V��(dSr)�isdigitr()�.0rs  r#�	<genexpr>zMH.iterkeys.<locals>.<genexpr>:sH����:�:�%�).�����:�3�u�:�:�:�:�:�:�:�:r%)�iterr[rrrrNs r#rOzMH.iterkeys8sJ��+��F�:�:�2�:�d�j�3I�3I�:�:�:�:�:�;�;�	;r%c��	tj�tj�|jt|������Sr)rrr�r�rr�r.s  r#rbzMH.__contains__=s1��G��w�~�~�b�g�l�l�4�:�s�3�x�x�@�@�A�A�Ar%c�`�	tt|�������Sr)r�rQrOrNs r#rdz
MH.__len__As#��8��4��
�
���(�(�)�)�)r%c��	|jsUttj�|jd��d��|_t|j��d|_dSdS)Nr�r>T)rFr�rrr�rrBrPrNs r#ruzMH.lockEsW����|�	 ��b�g�l�l�4�:��G�G��O�O�D�J��t�z�"�"�"��D�L�L�L�	 �	 r%c�|�	|jr3t|j��t|j��|`d|_dSdSrR)rFrSrBr�rNs r#rwz	MH.unlockLsI��1��<�	!����$�$�$���
�#�#�#��
� �D�L�L�L�		!�	!r%c��	dSrr�rNs r#rszMH.flushTs
��4��r%c�B�	|jr|���dSdSr)rFrwrNs r#ryzMH.closeXs*��*��<�	��K�K�M�M�M�M�M�	�	r%c���	g}tj|j��D]Y}tj�tj�|j|����r|�|���Z|Sr)rrrrrr�rrs   r#rzMH.list_folders]se��,����Z��
�+�+�	%�	%�E��w�}�}�R�W�\�\�$�*�e�<�<�=�=�
%��
�
�e�$�$�$���
r%c�x�	ttj�|j|��|jd���S)NFr
�rrrr�rrrs  r#r
z
MH.get_folderes7��9��"�'�,�,�t�z�6�2�2��-��7�7�7�	7r%c�v�	ttj�|j|��|j���S)Nrr�rs  r#rz
MH.add_folderjs5��H��"�'�,�,�t�z�6�2�2��-�)�)�)�	)r%c�R�	tj�|j|��}tj|��}|dgkr3tjtj�|d����n|gkrnt
d|jz���tj|��dS)Nr�zFolder not empty: %s)rrr�rrr0rr)r rr�entriess    r#rzMH.remove_folderos���;��w�|�|�D�J��/�/���*�T�"�"����'�'�'��I�b�g�l�l�4��9�9�:�:�:�:�
��]�]��� 6��� C�D�D�D�
�������r%c
�J�
�	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	ddd��n#1swxYwY|S)Nr��r�ASCII��encodingr�c3�4K�|]}t|��V��dSr)r()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�r/�all_keyss  �r#�
<listcomp>z$MH.get_sequences.<locals>.<listcomp>�s)���%=�%=�%=�S�,/�8�O�O�&)�,;�O�Or%rz"Invalid sequence specification: %s)r�rrr�r�setrRr�r�r,r(rq�ranger[r�r}r�rstrip)r �resultsr�r�r��contentsrR�specrdrer�s          @r#r�zMH.get_sequences{s����K���
�"�'�,�,�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�F�	ttj�|jd��dd���}	tjtj|jtjtjz����|�	��D]�\}}t|��dkr�|�|dz��d}d}tt|����D]^}|dz
|kr|sd	}|�d
��n7|rd}|�|�d|����n|�d|z��|}�_|r&|�t|��d
z����|�d
����	t|��dS#t|��wxYw)Nr�zr+r�r�rr�FrTr�� z %s�
)r�rrr�rryr�rr�r`r�r�r[r�r�r�)r �	sequencesr�r�rR�prev�
completingr/s        r#�
set_sequenceszMH.set_sequences�s���H������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�F c�:�	|���}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)Nrr)r�rOrrr�rr�rr��unlinkr�r�r�rCr�r`�indexr�)	r r�r��changesr/r�r��oldr�s	         r#�packzMH.pack�s��M��&�&�(�(�	������=�=�?�?�	�	�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||<�
|�|��dSr)r�r`rr�r�)r r+r/�pending_sequences�
all_sequencesr�r��sequences        r#r�zMH._dump_sequences�s���I�#�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,r0r8r>rHrArOrbrdrurwrsryrr
rrr�r�r�r�r�r%r#rr�sj�������
�
�
�
� � � �D������0���2$�$�$�*	�	�	�;�;�;�
B�B�B�*�*�*� � � �!�!�!�������
���7�7�7�
)�)�)�

�
�
����0���:&�&�&�4*�*�*�*�*r%rc�z�eZdZ	ehd���Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�ZdS)r>�filed�edited�resent�unseen�deleted�answered�	forwardedNTc�P�	t�||||��i|_dSr)r<r$�_labelsrs    r#r$zBabyl.__init__�s*��)��#�#�D�$���@�@�@�����r%c��	t�||��}t|t��r|���|j|<|Sr)r<r,r�r�
get_labelsr�)r r+r/s   r#r,z	Babyl.add�sI��2� �$�$�T�7�3�3���g�|�,�,�	5� '� 2� 2� 4� 4�D�L����
r%c�d�	t�||��||jvr
|j|=dSdSr)r<r0r�r.s  r#r0zBabyl.remove�s@��K��!�!�$��,�,�,��$�,�����S�!�!�!��r%c��	t�|||��t|t��r|���|j|<dSdSr)r<r8r�rr�r�r7s   r#r8zBabyl.__setitem__�sW��L��&�&�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
}|j�
|��}|�td��}t|���|z��}	|	�
|�����||jvr |	�|j|��|	S�NT�*** EOOH ***r�)r�rBr�r�r�r�r�r�r�rXr�rr��set_visibler��
set_labels)
r r/rdre�original_headersr��visible_headers�n�bodyr�s
          r#r>zBabyl.get_message�s���B��l�l�3�'�'���t��
��������
�������:�<�<��	A��:�&�&�(�(�D����0�0�0��0���"�"�4�<�<���#?�#?�@�@�@�		A�
�*�,�,��	@��:�&�&�(�(�D��w���d����!�!�$�,�,�w��">�">�?�?�?�		@�
�4�:�?�?�$�$�$���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
}|j�|��}|�td��}||zSr�)r�rBr�r�r�r�r�r�r�r�rXr�)	r r/rdrer�r��headersrr�s	         r#rHzBabyl.get_bytess-��A��l�l�3�'�'���t��
��������
�������:�<�<��	A��:�&�&�(�(�D����0�0�0��0���"�"�4�<�<���#?�#?�@�@�@�		A�
	��:�&�&�(�(�D��w���d���	�#�+�+�-�-���4�:�?�?�$�$�$���z���q�!�!���|�|�G�U�+�+����~�r%c��	tj|�|���dt����Sr�)r�r�rHr�r�r.s  r#rAzBabyl.get_file)s1��D��z�$�.�.��-�-�5�5�e�W�E�E�F�F�Fr%c��	|���t��}|j���D]}|�|���|�|j��t|��Sr)r�r�r�r\rq�difference_update�_special_labelsrQ)r �labels�
label_lists   r#r�zBabyl.get_labels-sp��B������������,�-�-�/�/�	&�	&�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)	NrTsc�^�g|]*}|����|�����+Sr�)�strip�r��labels  r#r�z'Babyl._generate_toc.<locals>.<listcomp>Ds<��:�:�:�E�+0�;�;�=�=�:�%�+�+�-�-�:�:�:r%r�,�r0)rBr�r�rXr�r�rr�r�r�r�r�r�rCrG)r r�r�r��label_listsr�r�r	s        r#rozBabyl._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)NsBABYL OPTIONS:s
Version: 5c3�>K�|]}|���V��dSr)r{rs  r#r�z*Babyl._pre_mailbox_hook.<locals>.<genexpr>Ys*����5�5�U�%�,�,�.�.�5�5�5�5�5�5r%sLabels:rr)r�r�r�r�)r r��babylr	s    r#rZzBabyl._pre_mailbox_hookTs}��:�!�G�+��
���(�(�����"�"��5�5�f�5�5�5��
��d�i�i��/�/�/�'�9�9��
����	��������r%c�B�	|�dtz��dS)N�r�ris  r#r\zBabyl._pre_message_hook^s"��;�	����'�!�"�"�"�"�"r%c�B�	|�tdz��dS)Nrr�ris  r#r^zBabyl._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)N�1s, s,,� rs1,,FrTr�r�rUr�r�s

r0r�r�r�r�r�r�r�r�)%rBrXr�rr�rrr�r{r�rFr+r
r�r�r�r�r�r�r�r��get_visibler�r�r�r�r�r�r�r�r~r�rmr�r�r�r�)r r+rd�special_labelsr	r�orig_buffer�orig_generatorr��
vis_buffer�
vis_generatorr��
body_start�original_pos�
first_passres                r#rqzBabyl._install_messagefsN��>��
���!�!���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��	frozensetrr$r,r0r8r>rHrAr�rorZr\r^rqr�r%r#rr�s������'��i�!B�!B�!B�C�C�O�����
���"�"�"�5�5�5����8���,G�G�G����.�.�.�<���#�#�#�#�#�#�i�i�i�i�ir%rc�$�eZdZ	dd�Zd�Zd�ZdS)r
Nc�j�	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���)Nr�r�)r�rFr+r
�_become_message�copy�deepcopy�_explain_tor�rGr��message_from_stringr��
TextIOWrapper�message_from_filerm�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�p�	t|dg��}|jD]}||vr|j||j|<�dS)N�_type_specific_attributes)�getattr�__dict__)r r+�
type_specificr�s    r#r(zMessage._become_message�sS��>���)D�b�I�I�
��$�	=�	=�D��=�(�(�&-�&6�t�&<��
�d�#��	=�	=r%c�P�	t|t��rdStd���)Nz Cannot convert to specified type)r�r
r�r*s  r#r+zMessage._explain_to�s,��H��g�w�'�'�	@��F��>�?�?�?r%r)r�r�r�r$r(r+r�r%r#r
r
�sR������:�H�H�H�H�&=�=�=�@�@�@�@�@r%r
c�b�eZdZ	gd�Zdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�ZdS)r)�_subdir�_info�_dateNc��	d|_d|_tj��|_t�||��dS)Nr�r�)r7r8rr9r
r$r*s  r#r$zMaildirMessage.__init__�s<��3������
��Y�[�[��
�����w�'�'�'�'�'r%c��	|jSr)r7rNs r#r�zMaildirMessage.get_subdirs
��$��|�r%c�R�	|dks|dkr	||_dStd|z���)Nr�r�z!subdir must be 'new' or 'cur': %s)r7r})r r�s  r#r�zMaildirMessage.set_subdirs5��+��U�?�?�f��o�o�!�D�L�L�L��@�6�I�J�J�Jr%c�Z�	|j�d��r|jdd�SdS)N�2,r0r�)r8r�rNs r#�	get_flagszMaildirMessage.get_flagss2��8��:� � ��&�&�	��:�a�b�b�>�!��2r%c�\�	dd�t|����z|_dS)Nr>r�)r�r[r8)r �flagss  r#�	set_flagszMaildirMessage.set_flagss'��7��B�G�G�F�5�M�M�2�2�2��
�
�
r%c��	|�d�t|�����t|��z����dS�Nr��rBr�r�r?�r �flags  r#�add_flagzMaildirMessage.add_flag�F��<����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
����dSdSrD)r?rBr�r�rFs  r#�remove_flagzMaildirMessage.remove_flagse��E��>�>���	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��	|jSr)r9rNs r#r�zMaildirMessage.get_date"s
��J��z�r%c�t�		t|��|_dS#t$rtd|z��d�wxYw)Nzcan't convert to float: %s)�floatr9r}r�)r �dates  r#r�zMaildirMessage.set_date&sQ��G�	K��t���D�J�J�J���	K�	K�	K��8�4�?�@�@�d�J�	K���s��7c��	|jSr)r8rNs r#r�zMaildirMessage.get_info-s
��3��z�r%c�~�	t|t��r	||_dStdt	|��z���)Nzinfo must be a string: %s)r�r�r8r�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���)N�S�Rr��O�T�D�F�A�
MAILER-DAEMONr��replied�flaggedr�r�r$r��$Cannot convert to specified type: %s)r�rrBr?r�r�r�r�r�r�rHr{rr�r
r�r�	add_labelr
r�r�)r r+rAs   r#r+zMaildirMessage._explain_to8s���I��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%r)r�r�r�r1r$r�r�r?rBrHrKr�r�r�r�r+r�r%r#rr�s�������3� =� =� =��(�(�(�(����K�K�K����3�3�3�C�C�C�G�G�G�
���K�K�K����F�F�F�)+�)+�)+�)+�)+r%rc�J�eZdZ	dgZdd�Zd�Zdd�Zd�Zd�Zd�Z	d	�Z
d
�ZdS)r��_fromNc�8�	|�dd��t|tjj��rH|���}|�2|�d��r|�|dd���t�||��dS)Nr[TzFrom r�)r{r�rFr+r
r�r�r$)r r+rs   r#r$z_mboxMMDFMessage.__init__is���5��
�
�o�t�,�,�,��g�u�}�4�5�5�	,��+�+�-�-�H��#��(;�(;�G�(D�(D�#��
�
�h�q�r�r�l�+�+�+�����w�'�'�'�'�'r%c��	|jSr)rarNs r#r�z_mboxMMDFMessage.get_fromrs
��.��z�r%c�|�	|�1|durtj��}|dtj|��zz
}||_dS)NTr�)rr�r�ra)r r��time_s   r#r{z_mboxMMDFMessage.set_fromvsC��L�����}�}���
�
���S�4�<��.�.�.�.�E���
�
�
r%c�^�	|�dd��|�dd��zS)N�Statusr��X-Status)r<rNs r#r?z_mboxMMDFMessage.get_flags~s,��8��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)N)r�r�)rUrV)rXrYrZr�rgrh)r�r0r�r[�replace_headerr4�
add_header)r rA�status_flags�
xstatus_flagsrGs     r#rBz_mboxMMDFMessage.set_flags�sL��7��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����dSrDrErFs  r#rHz_mboxMMDFMessage.add_flag�rIr%c���	d|vsd|vrY|�d�t|�����t|��z
����dSdS)Nrgrhr�rErFs  r#rKz_mboxMMDFMessage.remove_flag�sc��E��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
������dS#ttf$rYdSwxYwt|t ��rP|�|�����|�|�����dSt|t&��rtt|�����}d|vr|�d��d|vr|�d��d|vr|�d��|d	=|d
=dSt|t*��rtt|�����}d|vr|�d��d|vr|�d��d|vr|�d��|d	=|d
=dSt|t.��rdSt1dt3|��z���)NrVr�rYrZrUrTrXrW�statuszx-statusr����z%a %b %d %H:%M:%S %Yr�r\r]r�r�r^)r�rr�r?r�rHr�r�r�r��calendar�timegmr�strptimer}�
OverflowErrorr�rBr{r
r�rr_r
r�r�)r r+rA�
maybe_dates    r#r+z_mboxMMDFMessage._explain_to�s2��O��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�>:D:�:E�Er)r�r�r�r1r$r�r{r?rBrHrKr+r�r%r#r�r�ds�������9�!(�	��(�(�(�(��������A�A�A�7�7�7�,C�C�C�G�G�G�
1+�1+�1+�1+�1+r%r�c��eZdZdS)rN�r�r�r�r�r%r#rr��������0�0r%rc�<�eZdZ	dgZd	d�Zd�Zd�Zd�Zd�Zd�Z	dS)
r
�
_sequencesNc�L�	g|_t�||��dSr)r|r
r$r*s  r#r$zMHMessage.__init__�s(��/��������w�'�'�'�'�'r%c�"�	|jdd�Sr)r|rNs r#r�zMHMessage.get_sequences�s��B���q�q�q�!�!r%c�0�	t|��|_dSr)rQr|)r r�s  r#r�zMHMessage.set_sequences�s��A��y�/�/����r%c��	t|t��r'||jvr|j�|��dSdSt	dt|��z���)Nzsequence type must be str: %s)r�r�r|rr�r��r r�s  r#r�zMHMessage.add_sequence�se��F��h��$�$�	N��t��.�.���&�&�x�0�0�0�0�0�/�.��;�d�8�n�n�L�M�M�Mr%c�`�		|j�|��dS#t$rYdSwxYwr)r|r0r}r�s  r#�remove_sequencezMHMessage.remove_sequence�sH��O�	��O�"�"�8�,�,�,�,�,���	�	�	��D�D�	������
-�-c�d�	t|t��r�t|�����}d|vr|�d��n*|�d��|�d��d|vr|�d��d|vr|�d��dSdSt|t��r�t|�����}d|vr|�d��n|�d	��d|vr|�d��d|vr|�d
��dSdSt|t��r.|���D]}|�|���dSt|t��rWt|�����}d|vr|�
d��d|vr|�
d��dSdSt|t��rdStdt|��z���)
Nr�r�rTr]rYr\rU�ROrVrZr�r^)r�rr�r�r�rHr�r
r�rr_r
r�r�)r r+r�r�s    r#r+zMHMessage._explain_to�ss��D��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%r)
r�r�r�r1r$r�r�r�r�r+r�r%r#r
r
�s�������.�!-���(�(�(�(�
"�"�"�*�*�*�N�N�N����$+�$+�$+�$+�$+r%r
c�P�eZdZ	ddgZd
d�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�ZdS)rr��_visibleNc�r�	g|_t��|_t�||��dSr)r�r
r�r$r*s  r#r$zBabylMessage.__init__&s3��1�����	�	��
�����w�'�'�'�'�'r%c�"�	|jdd�Sr)r�rNs r#r�zBabylMessage.get_labels,s��5��|�A�A�A��r%c�0�	t|��|_dSr)rQr�)r r	s  r#r�zBabylMessage.set_labels0s��4��F�|�|����r%c��	t|t��r'||jvr|j�|��dSdSt	dt|��z���)Nzlabel must be a string: %s)r�r�r�rr�r��r rs  r#r_zBabylMessage.add_label4se��9��e�S�!�!�	H��D�L�(�(���#�#�E�*�*�*�*�*�)�(��8�4��;�;�F�G�G�Gr%c�`�		|j�|��dS#t$rYdSwxYwr)r�r0r}r�s  r#�remove_labelzBabylMessage.remove_label<sH��B�	��L����&�&�&�&�&���	�	�	��D�D�	���r�c�,�	t|j��Sr�r
r�rNs r#rzBabylMessage.get_visibleCs��A��t�}�%�%�%r%c�0�	t|��|_dSrr�)r �visibles  r#r�zBabylMessage.set_visibleGs��@���(�(��
�
�
r%c���	|j���D]0}||vr"|j�|||���(|j|=�1dD]}||vr||jvr|||j|<� dS)N)�Date�FromzReply-To�To�CC�Subject)r�rRrj)r �headers  r#�update_visiblezBabylMessage.update_visibleKs���G��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���)Nr�r�rTr�r�r$r�rUr�rWr�rVrXrZr\r^)r�rr�r�r�rHr�r
r�rr�rr_r
r�r�)r r+r	rs    r#r+zBabylMessage._explain_toVs���G��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%r)
r�r�r�r1r$r�r�r_r�rr�r�r+r�r%r#rr!s�������1�!*�J� 7��(�(�(�(����$�$�$�H�H�H����&�&�&�)�)�)�	5�	5�	5�'+�'+�'+�'+�'+r%rc��eZdZdS)rNryr�r%r#rr�rzr%rc��eZdZ	dd�Zdd�Zdd�Zdd�Zdd�Zd�Zd�Z	dd
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�Zed���Zee��ZdS)r�Nc�^�	||_|�|���|_dS||_dSr)rBrX�_pos)r r��poss   r#r$z_ProxyFile.__init__�s/��&���
��;������D�I�I�I��D�I�I�Ir%c�D�	|�||jj��Sr)�_readrBr��r �sizes  r#r�z_ProxyFile.read�s����z�z�$��
��0�0�0r%c�D�	|�||jj��Sr)r�rB�read1r�s  r#r�z_ProxyFile.read1�s����z�z�$��
� 0�1�1�1r%c�D�	|�||jj��Sr)r�rBr�r�s  r#r�z_ProxyFile.readline�s����z�z�$��
� 3�4�4�4r%c�x�	g}|D]3}|�|��|�|t|��z}|dkrn�4|S)Nr)rr�)r �sizehintrhr�s    r#�	readlinesz_ProxyFile.readlines�sU��"����	�	�D��M�M�$�����#��C��I�I�%���q�=�=��E���
r%c#�DK�		|���}|sdS|V��r)r�)r r�s  r#rZz_ProxyFile.__iter__�s6����!�	��=�=�?�?�D��
����J�J�J�		r%c��	|jSr)r�rNs r#rXz_ProxyFile.tell�s
��"��y�r%rc���	|dkr|j�|j��|j�||��|j���|_dS)Nr�rBr�r�rX�r �offset�whences   r#r�z_ProxyFile.seek�sQ����Q�;�;��J�O�O�D�I�&�&�&��
�����'�'�'��J�O�O�%�%��	�	�	r%c��	t|d��r:	t|jd��r|j���|`dS#|`wxYwdS)NrBry)rmrBryrNs r#ryz_ProxyFile.close�sd����4��!�!�	�
��4�:�w�/�/�'��J�$�$�&�&�&��J�J�J��D�J�����	�	s�.A�A	c��	|�d}|j�|j��||��}|j���|_|S)Nr�r�)r r��read_methodrhs    r#r�z_ProxyFile._read�sL��0��<��D��
����	�"�"�"���T�"�"���J�O�O�%�%��	��
r%c��	|Srr�rNs r#�	__enter__z_ProxyFile.__enter__�s
��2��r%c�.�|���dSr)ry)r �excs  r#�__exit__z_ProxyFile.__exit__�s���
�
�����r%c�4�|j���Sr)rB�readablerNs r#r�z_ProxyFile.readable�����z�"�"�$�$�$r%c�4�|j���Sr)rB�writablerNs r#r�z_ProxyFile.writable�r�r%c�4�|j���Sr)rB�seekablerNs r#r�z_ProxyFile.seekable�r�r%c�4�|j���Sr)rBrsrNs r#rsz_ProxyFile.flush�s���z���!�!�!r%c�l�t|d��sdSt|jd��sdS|jjS)NrBTr�F)rmrBr�rNs r#r�z_ProxyFile.closed�s=���t�W�%�%�	��4��t�z�8�,�,�	��5��z� � r%r�r)r�r�r�r$r�r�r�r�rZrXr�ryr�r�r�r�r�r�rs�propertyr�r�rr�r�r%r#r�r��sN������(�����1�1�1�1�2�2�2�2�5�5�5�5�	�	�	�	�������&�&�&�&�������������%�%�%�%�%�%�%�%�%�"�"�"��!�!��X�!�$��L�1�1���r%r�c�2�eZdZ	dd�Zd�Zd	d�Zd�Zd�ZdS)
r�Nc�\�	t�|||��||_||_dSr)r�r$�_start�_stop)r r�rdres    r#r$z_PartialFile.__init__�s/��(����D�!�U�+�+�+������
�
�
r%c�H�	t�|��|jz
Sr)r�rXr�rNs r#rXz_PartialFile.tell�s��8����t�$�$�t�{�2�2r%rc��	|dkr|j|_d}n|dkr|j|_d}t�|||��dS)Nrrr0)r�r�r�r�r�r�s   r#r�z_PartialFile.seek�sQ��F��Q�;�;���D�I��F�F�
�q�[�[��
�D�I��F�����f�f�-�-�-�-�-r%c��	|j|jz
}|dkrdS|�|dks||kr|}t�|||��S)Nrr%)r�r�r�r�)r r�r��	remainings    r#r�z_PartialFile._readsU��I��J���*�	���>�>��3��<�4�!�8�8�t�i�'7�'7��D�����d�K�8�8�8r%c�.�t|d��r|`dSdS)NrB)rmrBrNs r#ryz_PartialFile.close	s)���4��!�!�	��
�
�
�	�	r%)NNr�)r�r�r�r$rXr�r�ryr�r%r#r�r��sl������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)NFzlockf: lock unavailable: %s�.lockTzdot lock unavailable: %s)�fcntl�lockf�LOCK_EX�LOCK_NBr�r��EAGAINr@rArr�rYryrr�r�r�r�r�r-r0�LOCK_UN)r�rV�dotlock_doner��pre_locks     r#rPrPsG��2��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��F5�,:�F5�
B�AB�B�F5�+B>�=F5�>
C3�C.�'F5�-C.�.C3�3F5�8$D6�E5�65E.�+E5�-E.�.E5�5;F0�0F5�5AG<c���	trtj|tj��tj�|jdz��rtj|jdz��dSdS)Nr�)r�r�r�rrr�r�r0�r�s r#rSrS:se��4��&�
��A�u�}�%�%�%�	�w�~�~�a�f�w�&�'�'�$�
�	�!�&�7�"�#�#�#�#�#�$�$r%c���	tj|tjtjztjzd��}	t|d��tj|��S#tj|��wxYw)Nrr>)rr�rr��O_RDWRry)r�fds  r#r,r,As[��M�	���r�z�B�I�-��	�9�5�	A�	A�B���D�%� � �
�����������������s�A!�!A7c
��	t|�dttj�����dtj���dtj������S)Nr)r,r(rr&r'rr))rs r#rYrYIsU��L��d�d�d�C��	���4D�4D�4D�4D�.4�.@�.B�.B�.B�.B�.0�i�k�k�k�;�<�<�<r%c��	|���ttd��r(tj|�����dSdS)N�fsync)rsrmrr��filenor�s r#rWrWOsL��:��G�G�I�I�I��r�7����
�������������r%c�N�	t|��|���dSr)rWryr�s r#r�r�Us!��D���N�N�N��G�G�I�I�I�I�Ir%c��eZdZdS)rNryr�r%r#rr[s������,�,r%rc��eZdZdS)rNryr�r%r#rr^s������D�Dr%rc��eZdZdS)rNryr�r%r#rras������H�Hr%rc��eZdZdS)rNryr�r%r#rrd�������3�3r%rc��eZdZdS)rNryr�r%r#rrgr�r%r)T)1rrrsr&r�r)r�rF�
email.message�email.generatorr�r?�typesrr��ImportError�__all__r�r{rrr<rvrr	rrr+r
rr�rr
rrr�r�rPrSr,rYrWr��	Exceptionrrrrrr�r%r#�<module>r�sz��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

?>