%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3.12/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3.12/__pycache__/mailbox.cpython-312.pyc

�

���f?4���dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Zddl
ZddlZddlZddl
mZ	ddlZgd�Zej$j'd�ZGd�d�ZGd�d	e�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�dej8j:�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%d8d(�Z&d)�Z'd*�Z(d+�Z)d,�Z*d-�Z+Gd.�d/e,�Z-Gd0�d1e-�Z.Gd2�d3e-�Z/Gd4�d5e-�Z0Gd6�d7e-�Z1y#e$rdZY��AwxYw)9zDRead/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&y)&rz*A group of messages in a particular place.Nc��tjjtjj|��|_||_y)zInitialize a Mailbox instance.N)�os�path�abspath�
expanduser�_path�_factory��selfr�factory�creates    �/usr/lib/python3.12/mailbox.py�__init__zMailbox.__init__%s,���W�W�_�_�R�W�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�Kr$c��td��)�=Remove the keyed message; raise KeyError if it doesn't exist.r'r(�r�keys  r"�removezMailbox.remove.r-r$c�&�|j|�y�N)r2r0s  r"�__delitem__zMailbox.__delitem__2s�����C�r$c�F�	|j|�y#t$rYywxYw�z'If the keyed message exists, remove it.N)r2�KeyErrorr0s  r"�discardzMailbox.discard5s%��	��K�K�����	��	�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�H�	|j|�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�	�s��!�!c���|js|j|�Stj|j	|��5}|j|�cddd�S#1swYyxYw)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__GsT���}�}��#�#�C�(�(��#�#�D�M�M�#�$6�7�
+�4��}�}�T�*�
+�
+�
+�s�A�A&c��td��)�4Return a Message representation or raise a KeyError.r'r(r0s  r"rCzMailbox.get_messageOr-r$c�f�tj|j|��j�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�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�4�t|j��S)zReturn a list of keys.)�listrWrVs r"�keyszMailbox.keysfs���D�M�M�O�$�$r$c#�hK�|j�D]}	||}|���y#t$rY�wxYw�w)z%Return an iterator over all messages.N�rWr8�rr1�values   r"�
itervalueszMailbox.itervaluesjsC�����=�=�?�	�C�
��S�	���K�	���
��
�s�2�#�2�	/�2�/�2c�"�|j�Sr4)r_rVs r"�__iter__zMailbox.__iter__ss����� � r$c�4�t|j��S)z,Return a list of messages. Memory intensive.)rYr_rVs r"�valueszMailbox.valuesvs���D�O�O�%�&�&r$c#�lK�|j�D]}	||}||f���y#t$rY�wxYw�w)z.Return an iterator over (key, message) tuples.Nr\r]s   r"�	iteritemszMailbox.iteritemszsH�����=�=�?�	�C�
��S�	����,��	���
��
�s�4�%�	4�	1�4�1�4c�4�t|j��S)z9Return a list of (key, message) tuples. Memory intensive.)rYrerVs 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�P�|j�D]}|j|��y)zDelete all messages.N)rZr9r0s  r"�clearz
Mailbox.clear�s#���9�9�;�	�C��L�L���	r$c�V�	||}|j|�|S#t$r|cYSwxYw)z3Delete the keyed message and return it, or default.)r8r9)rr1r@�results    r"�popzMailbox.pop�s9��	��#�Y�F�	
���S���
���	��N�	�s��(�(c�j�|j�D]}||j|�fcStd��)z6Delete an arbitrary (key, message) pair and return it.zNo messages in mailbox)rWrrr8r0s  r"�popitemzMailbox.popitem�s8���=�=�?�	5�C�����#��'�'�	5��3�4�4r$c���t|d�r|j�}nt|d�r|j�}n|}d}|D]\}}	|||<�
|rtd��y#t$rd}Y�)wxYw)z4Change the messages that correspond to certain keys.rergFTzNo message with key(s)N)�hasattrrergr8)r�arg�source�bad_keyr1r+s      r"�updatezMailbox.update�s����3��$��]�]�_�F�
�S�'�
"��Y�Y�[�F��F���"�	�L�C��
�#��S�	�	�
��3�4�4����
���
�s�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�V�	|jd�S#t$rtd��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�s7��	2��>�>�'�*�*���	2��1�2�
2�	2�s��(Fc��t|tjj�r�t	j
�}tjj||d�}|j|�|jd�|j�}|jdt�}|j|�|jr,|jt�s|jt�y
y
y
t|t t"tj$f�r�t|tj$�r+t'j(dt*d�|j-�}t|t �r|j/|�}|r|jdd�}|jdt�}|j|�|jr,|jt�s|jt�y
y
y
t1|d�r�t1|d�r't'j(d	t*d�|j2}d
}	|j5�}|jd�r	|d
ddz}n|jd
�r|d
ddz}|snE|r|j7d�rd|dd
z}|jdt�}|j|�|}��|jr/|r,|jt�s|jt�y
y
y
y
t9dt;|�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 insteadN�
����
����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�rvr��readline�
startswith�	TypeError�type)	rr+�target�mangle_from_r��gen�data�lastline�lines	         r"�
_dump_messagezMailbox._dump_message�sv���g�u�}�}�4�4�5��Z�Z�\�F��/�/�0�0���q�I�C��K�K�� ��K�K��N��;�;�=�D��<�<��w�/�D��L�L����#�#�D�M�M�'�,B����W�%�-C�#���#�u�b�k�k�!:�
;��'�2�;�;�/��
�
�*�+=�q�B�!�*�*�,���'�3�'��/�/��8���!�/�/�*�k�B���o�o�e�W�5�G��L�L��!��#�#�G�,<�,<�W�,E����W�%�-F�#��W�f�
%��w��)��
�
�5�6H�!�M�!�.�.���H���'�'�)���=�=��)����9�u�,�D��]�]�5�)����9�u�,�D����D�O�O�H�$=�$�t�A�B�x�/�D��|�|�E�7�3�����T�"�����#�#���9J�9J�7�9S����W�%�:T��#��6��g��F�G�Gr$�NTr4�F)'�__name__�
__module__�__qualname__�__doc__r#r,r2r5r9r=rAr?rCrPrNrFrWrZr_rarcrergrjrmrorrrtrzr}r�r�r�r�r�r��classmethodr�__class_getitem__�r$r"rr"s���4� �
L�L���L��+�L�I�L�L�L�%��!�'��&�L�L��
�5�5�"L�L�L�L�2��O�4H�l$�L�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�Zy)rzA qmail-style Maildir mailbox.�:Nc��tj||||�tjj	|j
d�tjj	|j
d�tjj	|j
d�d�|_tjj|j
�sm|rVtj|j
d�|jj�D]}tj|d��nt|j
��i|_ddd�|_d|_
d|_y	)
zInitialize a Maildir instance.�tmp�new�cur)r�r�r��r)r�r�g�������?N)rr#rr�joinr�_paths�exists�mkdirrcr�_toc�_toc_mtimes�
_last_read�_skewfactor)r�dirnamer r!rs     r"r#zMaildir.__init__s�������w���8��7�7�<�<��
�
�E�2��7�7�<�<��
�
�E�2��7�7�<�<��
�
�E�2����
�w�w�~�~�d�j�j�)��������U�+� �K�K�.�.�0�*�D��H�H�T�5�)�*�)����4�4���	�#$�Q�/��������r$c���|j�}	|j||�t|�t|t�r?|j�}|j|j�z}||jk(rd}nd}d}tjj|j�j|j�d}tjj!|j"|||z�}t|t�rWt	j$|jtjj'|j�|j)�f�		t	j*|j|�t	j
|j�|S#t$r1|j�t	j
|j��wxYw#t,t.f$r$t	j0|j|�Y|SwxYw#t2$rP}t	j
|j�|j4t4j6k(rt9d|z���d}~wwxYw)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$s����#�#�%��	����w��1�
	�H���g�~�.��'�'�)�F��Z�Z�'�"2�"2�"4�4�F�����#����F��F��w�w����
�
�.�4�4�T�Z�Z�@��C���w�w�|�|�D�J�J���v�
�>���g�~�.��H�H�X�]�]��g�g�&�&�x�}�}�5�w�7G�7G�7I�J�
L�

	�
)�����
�
�t�,��	�	�(�-�-�(����G�	��N�N���I�I�h�m�m�$��	��0#�O�4�
/��	�	�(�-�-��.���
/���	��I�I�h�m�m�$��w�w�%�,�,�&�(�)O�+/�*0�1�1���
	�sB�F� G�>H�:G�/H�H�H�H�	I+�AI&�&I+c��tjtjj|j|j|���y�r/N)rr2rr�r�_lookupr0s  r"r2zMaildir.removeNs*��
�	�	�"�'�'�,�,�t�z�z�4�<�<��+<�=�>r$c�R�	|j|�y#ttf$rYywxYwr7)r2r8�FileNotFoundErrorr0s  r"r9zMaildir.discardRs+��	��K�K�����+�,�	��	�s��&�&c���|j|�}|j|�}|j|�}t|t�r|}n|}tj
j
|�}|j|vr,|j|j|j�dz}nd}|j|�tj
j|j|�}	tj
j|j|||z�}
t|t�rCt	j|	tj
j|	�|j�f�t	j|	|
�y)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__Zs���l�l�3�'���8�8�G�$���|�|�H�-���g�~�.�+�� +�������!1�2���:�:�)�)��Z�Z�"2�"8�"8����"D�R�"H�H�F��F����S���7�7�<�<��
�
�L�9���7�7�<�<��
�
�F�C�&�L�A���g�~�.��H�H�X��g�g�&�&�x�0�'�2B�2B�2D�E�
G�
	�	�	�(�H�%r$c��|j|�}ttjj	|j
|�d�5}|jr|j
|�}nt|�}ddd�tjj|�\}}j|�|j|vr-|j|j|j�d�|jtjjtjj	|j
|���|S#1swY��xYw)rI�rbNr�)r��openrrr�rrrr��
set_subdirr��set_info�set_date�getmtime)rr1�subpath�f�msgr�r�s       r"rCzMaildir.get_messageus����,�,�s�#��
�"�'�'�,�,�t�z�z�7�3�T�
:�	(�a��}�}��m�m�A�&��$�Q�'��		(�
�w�w�}�}�W�-�������v���:�:����L�L����D�J�J�/��3�4����R�W�W�%�%�b�g�g�l�l�4�:�:�w�&G�H�I��
�	(�	(�s�*D>�>Ec��ttjj|j|j|��d�5}|j
�jtd�cddd�S#1swYyxYw)�2Return a bytes representation or raise a KeyError.r�r�N)	r�rrr�rr�r�r�r��rr1rs   r"rNzMaildir.get_bytes�sU��
�"�'�'�,�,�t�z�z�4�<�<��+<�=�t�
D�	4���6�6�8�#�#�G�U�3�	4�	4�	4�s�$A2�2A;c��ttjj|j|j|��d�}t
|�S)rSr�)r�rrr�rr��
_ProxyFilers   r"rFzMaildir.get_file�s4��������d�j�j�$�,�,�s�*;�<�d�C���!�}�r$c#�K�|j�|jD]}	|j|�|���y#t$rY�'wxYw�w�rUN)�_refreshr�r�r8r0s  r"rWzMaildir.iterkeys�sM�����
�
���9�9�	�C�
����S�!��I�	���
��
�s%� A
�;�A
�	A�A
�A�A
c�>�|j�||jvS�ri)r	r�r0s  r"rjzMaildir.__contains__�s���
�
���d�i�i��r$c�L�|j�t|j�S�rl)r	�lenr�rVs r"rmzMaildir.__len__�s���
�
���4�9�9�~�r$c��y)�"Write any pending changes to disk.Nr�rVs r"r}z
Maildir.flush�s��	
r$c��y)rNr�rVs r"r�zMaildir.lock����r$c��y)r�Nr�rVs r"r�zMaildir.unlock�rr$c��y�r�Nr�rVs r"r�z
Maildir.close�rr$c�:�g}tj|j�D]v}t|�dkDs�|ddk(s�tjjtjj
|j|��s�c|j|dd��x|S)�Return a list of folder names.�r�.N)r�listdirrrr�isdirr��append�rrq�entrys   r"�list_folderszMaildir.list_folders�st�����Z�Z��
�
�+�	)�E��5�z�A�~�%��(�c�/��w�w�}�}�R�W�W�\�\�$�*�*�e�<�=��
�
�e�A�B�i�(�	)��
r$c��ttjj|jd|z�|j
d��S)z/Return a Maildir instance for the named folder.rF�r r!)rrrr�rr�r�folders  r"�
get_folderzMaildir.get_folder�s2���r�w�w�|�|�D�J�J��f��=�#�}�}�#�%�	%r$c��tjj|jd|z�}t	||j
��}tjj|d�}tjj
|�sItjtj|tjtjzd��|S)z>Create a folder and return a Maildir instance representing it.r�r �
maildirfolder�)rrr�rrrr�r�r��O_CREAT�O_WRONLY)rr#rrq�maildirfolder_paths     r"�
add_folderzMaildir.add_folder�s����w�w�|�|�D�J�J��f��5����t�}�}�5���W�W�\�\�$��@���w�w�~�~�0�1��H�H�R�W�W�/����b�k�k�1I���
��
r$c���tjj|jd|z�}tjtjj|d��tjtjj|d��zD]&}t|�dks	|ddk7s�t
d|z��tj|�D]b}|dk7s�	|dk7s�|dk7s�tjjtjj||��s�St
d|�d	|����tj|d
��D]z\}}}|D]5}tjtjj||���7|D]5}tjtjj||���7�|tj|�y)
�-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�st���w�w�|�|�D�J�J��f��5���Z�Z������T�5� 9�:��Z�Z������T�5� 9�:�;�	O�E��5�z�A�~��q��S��#�$D�v�$M�N�N�	O��Z�Z��%�	5�E���~�%�5�.�U�e�^��w�w�}�}�R�W�W�\�\�$��6�7�#�%+�U�%4�5�5�	5�
"$����u�!=�	4��D�$���
5���	�	�"�'�'�,�,�t�U�3�4�
5��
4����������d�E�2�3�
4�	4�
	����r$c�|�tj�}tjtjj	|j
d��D]h}tjj	|j
d|�}|tjj
|�z
dkDs�Ttj|��jy)zDelete old files in "tmp".r�i@�N)�timerrrr�rr�r2)r�nowrrs    r"�cleanz
Maildir.clean�sy���i�i�k���Z�Z������T�Z�Z�� ?�@�	 �E��7�7�<�<��
�
�E�5�9�D��R�W�W�%�%�d�+�+�f�4��	�	�$��	 r$rc	�b�tj�}tj�}d|vr|jdd�}d|vr|jdd�}t	|��dt	|dzdz��dtj��d	tj�d
|��	}t
jj|jd|�}	tj|�t!d|z��#t$r9txjdz
c_	t|�cYS#t$rYnwxYwY�OwxYw)
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)r7�socket�gethostnamer��intr�getpidr�_countrr�r�statr��_create_carefully�FileExistsErrorr)rr8�hostnamer�rs     r"r�zMaildir._create_tmp�s���i�i�k���%�%�'���(�?��'�'��W�5�H��(�?��'�'��W�5�H�$'��H�c�#��'�C�-�.@�"�)�)�+�$+�N�N�H�>���w�w�|�|�D�J�J��t�4��	��G�G�D�M�!�!I�!%�"&�'�	'��!�	��N�N�a��N�
�(��.�.��"�
��
���	�s6�	C,�,"D.�
D�D.�	D(�%D.�'D(�(D.�-D.c��tj�|jz
d|jzkDred}|jD]Q}tj
j
|j|�}||j|kDrd}||j|<�S|syi|_|jD]�}|j|}t	j|�D]�}tj
j||�}tj
j|�r�C|j|j�d}tj
j||�|j|<����tj�|_y)z!Update table of contents mapping.�FTNr)r7r�r�r�rrr�r�r�rr�rr�r�)r�refreshr��mtimerr�pr�s        r"r	zMaildir._refreshs8���9�9�;����(�1�t�/?�/?�+?�?��G��*�*�
1�����(�(����V�)<�=���4�+�+�F�3�3�"�G�+0�� � ��(�	
1�
����	��&�&�	>�F��;�;�v�&�D����D�)�
>���G�G�L�L��u�-���7�7�=�=��#���{�{�4�:�:�.�q�1��"$�'�'�,�,�v�u�"=��	�	�$��
>�	>��)�)�+��r$c�b�	tjjtjj|j|j
|��r|j
|S	|j�	|j
|S#t$rY�+wxYw#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�w�~�~�b�g�g�l�l�4�:�:�t�y�y��~�F�G��y�y��~�%�H�	
�
�
��	F��9�9�S�>�!��	�	��	��
�	F��4�s�:�;��E�	F�s�A"B�7B�	B�B�B.c��t|d�s|j�|_		|t|j�S#t$rYyt
$rY�/wxYw)z0Return the next message in a one-time iteration.�
_onetime_keysN)rvrWrO�next�
StopIterationr8rVs r"rPzMaildir.next4sU���t�_�-�!%����D���
��D��!3�!3�4�5�5�� �
���
��
�s�<�	A�A�Ar�)r�r�r�r�r�r#r,r2r9r=rCrNrFrWrjrmr}r�r�r�rr$r,r5r9rBr�r	r�rPr�r$r"rrs���(��E��((�T?��&�6
�4�
�
� �
�

�����%���& ��F�'�0"&�HF�
r$rc�t�eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zdd�Zd�Zy)�_singlefileMailboxzA single-file mailbox.Nc��tj||||�	t|jd�}||_
d|_d|_d|_
d|_d|_d|_y#t$r�}|j
t
jk(r.|rt|jd�}nYt|j��|j
t
jt
jfvrt|jd�}n�Yd}~��d}~wwxYw)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�	��T�Z�Z��'�A���
���	������
�"������ ����!�		��w�w�%�,�,�&���T�Z�Z��/�A�,�T�Z�Z�8�8����U�\�\�5�;�;�7�7�����T�*�����		�s�A"�"	D�+BC?�?Dc���|j�|j|�|j|j<|xjdz
c_d|_|jdz
S)r&rT)r��_append_messager�rZr\r*s  r"r,z_singlefileMailbox.add[sO������$(�$8�$8��$A��	�	�$�.�.�!����!���"����~�~��!�!r$c�N�|j|�|j|=d|_y)r/TN)r�r�r[r0s  r"r2z_singlefileMailbox.removees �����S���I�I�c�N���
r$c�p�|j|�|j|�|j|<d|_y)r;TN)r�r`r�r[r<s   r"r=z_singlefileMailbox.__setitem__ks-�����S���-�-�g�6��	�	�#����
r$c#�tK�|j�|jj�Ed{���y7��wr)r�r�rZrVs r"rWz_singlefileMailbox.iterkeysqs#���������9�9�>�>�#�#�#�s�.8�6�8c�>�|j�||jvSr)r�r�r0s  r"rjz_singlefileMailbox.__contains__vs�������d�i�i��r$c�L�|j�t|j�Sr
)r�rr�rVs r"rmz_singlefileMailbox.__len__{s�������4�9�9�~�r$c�V�|jst|j�d|_yy)rTN)r]�
_lock_filerYrVs r"r�z_singlefileMailbox.lock�s!���|�|��t�z�z�"��D�L�r$c�V�|jrt|j�d|_yy�r�FN)r]�_unlock_filerYrVs r"r�z_singlefileMailbox.unlock�s!���<�<�����$� �D�L�r$c	�2�|js)|jrt|j�d|_y|j�J�|jjdd�|jj
�}||jk7rtd|j|fz��t|j�}	i}|j|�t|jj��D]�}|j|\}}|jj|�|j|�|j
�}	|jjt!d||jj
�z
��}|sn|j#|��U||j
�f||<|j%|���|j
�|_t/|�|jj'�t)j0|j�}	t)j2|j,|	j4�	t)j6|j,|	j8|	j:�	t)j@|j,|j�tE|jd�|_||_d|_d|_|jFrtI|jd��yy#|j'�t)j*|j,��xYw#t<t>f$rY��wxYw#tB$rLt)j*|j�t)j@|j,|j�Y��wxYw)	rFNrrHz4Size of mailbox file changed (expected %i, found %i)�rU)�dotlock)%r[r\�_sync_flushrYr�r��tellr^r�_create_temporaryr�_pre_mailbox_hook�sortedrZ�_pre_message_hookr��minr��_post_message_hookr�rr2r�r�rC�chmod�st_mode�chown�st_uid�st_gidr�r�r�rEr�r]rg)
r�cur_len�new_file�new_tocr1�start�stop�	new_startr��infos
          r"r}z_singlefileMailbox.flush�s����}�}��!�!��D�J�J�'�%*��"��
�y�y�$�$�$�	
�
�
����1���*�*�/�/�#���d�'�'�'�$�&?�&*�&7�&7��%A�&B�C�
C�%�T�Z�Z�0��	��G��"�"�8�,��d�i�i�n�n�.�/�
2��"�i�i��n���t��
�
����&��&�&�x�0�$�M�M�O�	��!�Z�Z�_�_�S��15��
�
���8I�1I�.K�L�F�!���N�N�6�*��!*�8�=�=�?�;�����'�'��1�
2�!)�
�
��D��
	�H���
�
�����w�w�t�z�z�"��
���������-�	��H�H�X�]�]�D�K�K����=�	1��I�I�h�m�m�T�Z�Z�0��$�*�*�e�,��
���	���
�"����<�<��t�z�z�5�1���/	��N�N���I�I�h�m�m�$�����(�	��	���	1��I�I�d�j�j�!��I�I�h�m�m�T�Z�Z�0�	1�s2�9DK7�5L,�8*M�72L)�,L>�=L>�AN�Nc��y)�,Called before writing the mailbox to file f.Nr��rrs  r"rqz$_singlefileMailbox._pre_mailbox_hook�rr$c��y)�-Called before writing each message to file f.Nr�r�s  r"rsz$_singlefileMailbox._pre_message_hook�rr$c��y��,Called after writing each message to file f.Nr�r�s  r"ruz%_singlefileMailbox._post_message_hook�rr$c��	|j�	|jr|j�|jj	�y#|jj	�wxYw#	|jr|j�|jj	�w#|jj	�wxYwxYwr)r}r]r�rYr�rVs r"r�z_singlefileMailbox.close�s|��	#��J�J�L�
#��<�<��K�K�M��
�
� � �"���
�
� � �"��	
#��<�<��K�K�M��
�
� � �"���
�
� � �"�s.�A)�A
�
A&�)C�+B"�C�"B>�>Cc��|j�|j�|�	|j|Sy#t$rtd|z�d�wxYw)z'Return (start, stop) or raise KeyError.NrM)r��
_generate_tocr8r0s  r"r�z_singlefileMailbox._lookup�s\���9�9����� ��?�
J��y�y��~�%����
J��8�3�>�?�T�I�
J�s	�0�A	c�D�|jjdd�|jj�}t|j�dk(r'|j
s|j
|j�	|j|j�|j|�}|j|j�|jj�|jj�|_
|S#t$r|jj|��wxYw)z;Append message to mailbox and return (start, stop) offsets.rrH)rYr�rorr�r[rqrs�_install_messagerur��truncater}r^)rr+�before�offsetss    r"r`z"_singlefileMailbox._append_message�s����
�
����1�������"���t�y�y�>�Q��t�}�}�

�"�"�4�:�:�.�	��"�"�4�:�:�.��+�+�G�4�G��#�#�D�J�J�/�	
�
�
���� �J�J�O�O�-�������	��J�J����'��	�s
�7AC9�9&Dr�r4)r�r�r�r�r#r,r2r=rWrjrmr�r�r}rqrsrur�r�r`r�r$r"rSrSAsX�� �!�."���$�
 �
�
 �!�B2�H���	#�J�r$rSc�8�eZdZdZdZd�Zd	d�Zd	d�Zd	d�Zd�Z	y)
�	_mboxMMDFzAn mbox or MMDF mailbox.Tc���|j|�\}}|jj|�|jj�j	t
d�j
d�}|jj||jj�z
�}|j|j	t
d��}|j|�|j|dd�|S)rIr$rr�r�N)r�rYr�r�r�r��decoder�ro�_message_factory�set_unixfrom�set_from)rr1r~r�	from_line�stringrs       r"rCz_mboxMMDF.get_message
s����l�l�3�'���t��
�
������J�J�'�'�)�1�1�'�3�?�F�F�w�O�	��������
�
���(9�!9�:���#�#�F�N�N�7�E�$B�C������#����Y�q�r�]�#��
r$c�l�tj|j||��j|��S)�3Return a string representation or raise a KeyError.)�unixfromrK)rr1�from_s   r"rPz_mboxMMDF.get_strings0���'�'��N�N�3��&�(�(1�	�5�	�(A�	Br$c�0�|j|�\}}|jj|�|s|jj�|jj	||jj�z
�}|j
td�S)r�r�)r�rYr�r�r�ror�r�)rr1r�r~rr�s      r"rNz_mboxMMDF.get_bytessj���l�l�3�'���t��
�
�������J�J���!��������
�
���(9�!9�:���~�~�g�u�-�-r$c��|j|�\}}|jj|�|s|jj�t	|j|jj�|�S)rS)r�rYr�r��_PartialFilero)rr1r�r~rs     r"rFz_mboxMMDF.get_file&sU���l�l�3�'���t��
�
�������J�J���!��D�J�J��
�
���(9�4�@�@r$c�J�d}t|t�r|j|�}t|t�r:|j	d�r)|jd�}|dk7r|d|}||dzd}n�|}d}n|t|t�r%|j�jd�}d|z}nGt|tjj�r#|j�}|�|jd�}|�8dtjtj��j�z}|j j#�}|j j%|t&z�|j)||j |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_unixfromr7�asctime�gmtimerYror�r�r��
_mangle_from_)rr+r��newline�authorr~rs       r"r�z_mboxMMDF._install_message.s^���	��g�s�#��+�+�G�4�G��g�u�%�'�*<�*<�X�*F��l�l�5�)�G��"�}�#�H�W�-�	�!�'�A�+�,�/��#�	���
��!1�
2��%�%�'�.�.�w�7�F� �6�)�I�
�����!6�!6�
7��,�,�.�I��$�%�,�,�W�5�	���.����d�k�k�m�1L�1S�1S�1U�U�I��
�
���!���
�
����W�,�-����7�D�J�J��0B�0B�C��z�z��� ���t�}�r$Nr�)
r�r�r�r�r�rCrPrNrFr�r�r$r"r�r�s%��"��M�	�B�
.�A�r$r�c�,�eZdZdZdZdZdd�Zd�Zd�Zy)rzA classic mbox mailbox.TNc�J�t|_tj||||�y)zInitialize an mbox mailbox.N)rr�r�r#rs    r"r#z
mbox.__init__T��� +������4��w��7r$c�.�|jt�yr��r�r�r�s  r"ruzmbox._post_message_hookYs��	����r$c���gg}}d}|jjd�	|jj�}|jj�}|j	d�r`t|�t|�kr5|r"|j
|tt�z
�n|j
|�|j
|�d}nF|s6|r"|j
|tt�z
�n|j
|�n|tk(rd}nd}��ttt||���|_t|j�|_|jj�|_
y)�0Generate key-to-(start, stop) table of contents.FrTr�N)rYr�ror�r�rrr��dict�	enumerate�zipr�rZr^)r�starts�stops�last_was_empty�line_posr�s      r"r�zmbox._generate_toc]s���B������
�
�������z�z���(�H��:�:�&�&�(�D����x�(��u�:��F��+�%����X��G��%<�=�
���X�.��
�
�h�'�!&���!��L�L��C��L�!8�9��L�L��*�����!%��!&��/�0��3�v�u�#5�6�7��	��T�Y�Y���� �J�J�O�O�-��r$r�)	r�r�r�r�r�r�r#rur�r�r$r"rrKs ��!��M��O�8�
�.r$rc�*�eZdZdZdd�Zd�Zd�Zd�Zy)r	zAn MMDF mailbox.Nc�J�t|_tj||||�y)zInitialize an MMDF mailbox.N)rr�r�r#rs    r"r#z
MMDF.__init__�r�r$c�4�|jdtz�y)r��Nr�r�s  r"rszMMDF._pre_message_hook�s��	���#�g�-�.r$c�B�|jtdztz�y)r�r�Nr�r�s  r"ruzMMDF._post_message_hook�s��	����-�-��7�8r$c���gg}}|jjd�d}	|}|jj�}|jj�}|j	dt
z�r�|j
|�	|}|jj�}|jj�}|dt
zk(r"|j
|tt
�z
�n|s|j
|�n�y|sn��ttt||���|_t|j�|_|jjdd�|jj�|_
y)r�rr�rHN)rYr�r�ror�r�rrr�r�r�r�rZr^)rr�r��next_posr�r�s      r"r�zMMDF._generate_toc�s*���B����
�
���������H��:�:�&�&�(�D��z�z���(�H����2�W�<�=��
�
�h�'��'�H��:�:�.�.�0�D�#�z�z���0�H��2�W�<�<����X��G��%<�=��!����X�.�����#�$��3�v�u�#5�6�7��	��T�Y�Y�����
�
����1�� �J�J�O�O�-��r$r�)r�r�r�r�r#rsrur�r�r$r"r	r	s���8�
/�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�Zy)rzAn MH mailbox.Nc��tj||||�tjj	|j
�s�|r�tj|j
d�tjtjtjj|j
d�tjtjztjzd��d|_yt|j
��d|_y)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��w�w�~�~�d�j�j�)��������U�+������������d�j�j�/�!J�!#���b�i�i�!7�"�+�+�!E�u�N�O����)����4�4���r$c��|j�}t|�dk(rd}nt|�dz}tjj|jt|��}t|�}d}	|jrt|�		|j||�t!|t"�r|j%||�|jrt|�	|st|�|S#t$r;|jrt|�t|�d}tj|��wxYw#|jrt|�wwxYw#|st|�wwxYw)r&rrFT)rZr�maxrrr�rr�rDr]rgr�r�rjr�r2r�r
�_dump_sequences)rr+rZ�new_keyr�r�closeds       r"r,zMH.add�s���y�y�{���t�9��>��G��$�i�!�m�G��7�7�<�<��
�
�C��L�9���h�'����	��|�|��1�
�
$�	��&�&�w��2��g�y�1��(�(��'�:��<�<� ��O���A�����!%���|�|�$�Q����N�!�F��I�I�h�'�����<�<� ��O� ����A���s7�1E	�
C%�"D,�>E	�%AD)�)D,�,E�E	�	Ec�H�tjj|jt	|��}	t|d�}|j
�tj|�y#t$r1}|jtjk(rtd|z���d}~wwxYw)r/rUrMN)rrr�rr�r�r�r2r�r�rVr8)rr1rrr�s     r"r2z	MH.remove�s{���w�w�|�|�D�J�J��C��1��		��T�5�!�A�
�G�G�I��I�I�d�O���	��w�w�%�,�,�&��8�3�>�?�?���		�s�A'�'	B!�0,B�B!c���tjj|jt	|��}	t|d�}	|jrt|�	tjtj
|tjtjz��|j||�t!|t"�r|j%||�|jrt'|�	t)|�y#t$r1}|jtjk(rtd|z���d}~wwxYw#|jrt'|�wwxYw#t)|�wxYw)r;rUrMN)rrr�rr�r�r�r�rVr8r]rgr�r*�O_TRUNCr�r�r
r�rjr�)rr1r+rrr�s      r"r=zMH.__setitem__�s���w�w�|�|�D�J�J��C��1��	��T�5�!�A�	��|�|��1�
�
$��������r�{�{�R�Z�Z�'?�@�A��"�"�7�A�.��g�y�1��(�(��#�6��<�<� ��O���N��#�	��w�w�%�,�,�&��8�3�>�?�?���		���<�<� ��O� ��
��N�s<�C:�E�A<D7�E�:	D4�,D/�/D4�7E�E�
E!c���	|jr>ttjj	|j
t
|��d�}n=ttjj	|j
t
|��d�}|5|jrt|�	t|�}|jrt|�	ddd�|j�j�D]\}}||vs�j!|��S#t$r1}|jtjk(rtd|z���d}~wwxYw#|jrt|�wwxYw#1swY��xYw)rIrUr�rMN)r]r�rrr�rr�r�r�rVr8rgr
rj�
get_sequencesrg�add_sequence)rr1rr�rr��key_lists       r"rCzMH.get_messages'��		��|�|�������d�j�j�#�c�(�;�U�C��������d�j�j�#�c�(�;�T�B���	$��|�|��1�
�
$���l���<�<� ��O�	$�#�0�0�2�8�8�:�	'�N�D�(��h��� � ��&�	'��
��!�	��w�w�%�,�,�&��8�3�>�?�?���		���<�<� ��O� ��
	$�	$�s<�BD
�E'�$E
�/E'�
	E�,E�E�
E$�$E'�'E0c��	|jr>ttjj	|j
t
|��d�}n=ttjj	|j
t
|��d�}|5|jrt|�	|j�jtd�|jrt|�cddd�S#t$r1}|jtjk(rtd|z���d}~wwxYw#|jrt|�wwxYw#1swYyxYw)rrUr�rMNr�)r]r�rrr�rr�r�r�rVr8rgr�r�r�rj�rr1rr�s    r"rNzMH.get_bytess���		��|�|�������d�j�j�#�c�(�;�U�C��������d�j�j�#�c�(�;�T�B���	$��|�|��1�
�
$��v�v�x�'�'���7��<�<� ��O�	$�	$���	��w�w�%�,�,�&��8�3�>�?�?���		���<�<� ��O� ��
	$�	$�s<�BC(�E�$#D%�E�(	D"�1,D�D"�%D?�?E�Ec��	ttjj|jt|��d�}t|�S#t$r1}|jtjk(rtd|z���d}~wwxYw)rSr�rMN)r�rrr�rr�r�r�rVr8rr�s    r"rFzMH.get_file1sl��	��R�W�W�\�\�$�*�*�c�#�h�7��>�A��!�}����	��w�w�%�,�,�&��8�3�>�?�?���		�s�=A
�
	B�,A?�?Bc�r�ttd�tj|j�D���S)rUc3�RK�|]}|j�r
t|����!y�wr4)�isdigitr@)�.0rs  r"�	<genexpr>zMH.iterkeys.<locals>.<genexpr>>s$����:�%�).�����u�:�:�s�%')�iterrrrrrrVs r"rWzMH.iterkeys<s/���F�:�2�:�:�d�j�j�3I�:�:�;�	;r$c��tjjtjj|jt|���Sr)rrr�r�rr�r0s  r"rjzMH.__contains__As,���w�w�~�~�b�g�g�l�l�4�:�:�s�3�x�@�A�Ar$c�F�tt|j���Sr
)rrYrWrVs r"rmz
MH.__len__Es���4��
�
��(�)�)r$c���|jsVttjj	|j
d�d�|_t|j�d|_yy)rr�rUTN)r]r�rrr�rrYrgrVs r"r�zMH.lockIsB���|�|��b�g�g�l�l�4�:�:��G��O�D�J��t�z�z�"��D�L�r$c��|jr4t|j�t|j�|`d|_yyri)r]rjrYr�rVs r"r�z	MH.unlockPs2���<�<�����$���
�
�#��
� �D�L�	r$c��y)r|Nr�rVs r"r}zMH.flushXrr$c�>�|jr|j�yyr)r]r�rVs r"r�zMH.close\s���<�<��K�K�M�r$c��g}tj|j�D][}tjj	tjj|j|��s�K|j
|��]|S)r)rrrrrr�rrs   r"rzMH.list_foldersasY�����Z�Z��
�
�+�	%�E��w�w�}�}�R�W�W�\�\�$�*�*�e�<�=��
�
�e�$�	%��
r$c��ttjj|j|�|j
d��S)z+Return an MH instance for the named folder.Fr!�rrrr�rrr"s  r"r$z
MH.get_folderis-���"�'�'�,�,�t�z�z�6�2��-�-��7�	7r$c��ttjj|j|�|j
��S)z:Create a folder and return an MH instance representing it.r&r�r"s  r"r,z
MH.add_folderns+���"�'�'�,�,�t�z�z�6�2��-�-�)�	)r$c�\�tjj|j|�}tj|�}|dgk(r4tj
tjj|d��n|gk(rnt
d|jz��tj|�y)r.r�zFolder not empty: %sN)rrr�rrr2rr1)rr#r�entriess    r"r5zMH.remove_folderssx���w�w�|�|�D�J�J��/���*�*�T�"����'�'��I�I�b�g�g�l�l�4��9�:�
��]��� 6���� C�D�D�
����r$c
���i}ttjj|jd�dd��5}t|j
��}|D]�}	|jd�\}}t�}|j�D]f}|j�r|jt|���.d�|jd�D�\}	}
|jt|	|
dz���ht|�D�cgc]}||vr|��
c}||<t||�d	k(r||=��	ddd�|Scc}w#t$rt!d
|j#�z��wxYw#1swY|SxYw)z=Return a name-to-key-list dictionary to define each sequence.r��r�ASCII��encodingr�c3�2K�|]}t|����y�wr4)r@)r��xs  r"r�z#MH.get_sequences.<locals>.<genexpr>�s����*K�a�3�q�6�*K�s��-rrz"Invalid sequence specification: %sN)r�rrr�r�setrZr�r�r,r@rz�rangerrrr�r�rstrip)r�resultsr�all_keysr�r��contentsrZ�specr~rr1s            r"r�zMH.get_sequencessV����
�"�'�'�,�,�t�z�z�?�;�S�7�
S�	5�WX��4�9�9�;�'�H��
5��5�%)�Z�Z��_�N�D�(��5�D� (��� 0�@���<�<�>� �H�H�S��Y�/�*K�4�:�:�c�?�*K�K�E�4� �K�K��e�T�A�X�(>�?�@�5;�4�L�%=�S�,/�8�O�&)�%=�G�D�M��7�4�=�)�Q�.�#�D�M��
5�	5�&���%=��"�5�%�&J�&*�k�k�m�'4�5�5�5��!	5�&��s6�E�B$D6�=
D1�
D6�$E�1D6�6&E�E�E)c��ttjj|jd�dd��}	tj
tj|jtjtjz��|j�D]�\}}t|�dk(r�|j|dz�d}d}tt|��D]Q}|d	z
|k(r|sCd
}|jd�n/|rd}|j|�d|���n|jd
|z�|}�S|r|jt|�dz���|jd���	t|�y#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�rgrr�rrr�r�r�)r�	sequencesrr�rZ�prev�
completingr1s        r"�
set_sequenceszMH.set_sequences�s,��������d�j�j�/�:�D�7�S��	��H�H�R�W�W�Q�V�V�R�[�[�2�:�:�%=�>�?�'�o�o�/�
"�
��d��t�9��>������s�
�#���"�
�!�#�d�)�,�
�C��Q�w�$��)�)-�J��G�G�C�L�#�%*�
����4�� 5�6�������,��D�
���G�G�C��I��,�-��G�G�D�M�)
"�,
��N��K��N�s�D*E/�/
E<c�
�|j�}d}g}|j�D]�}|dz
|k7r�|j||dzf�	tjtj
j
|jt|��tj
j
|jt|dz���tjtj
j
|jt|���|dz
}��|dz|_
t|�dk(ry|j�D](\}}|D]\}}||vs�|||j!|�<� �*|j#|�y#ttf$r~tjtj
j
|jt|��tj
j
|jt|dz���Y��wxYw)z?Re-name messages to eliminate numbering gaps. Invalidates keys.rrN)r�rWrrr�rr�rr��unlinkr�r�r�rZrrg�indexr�)	rr�r��changesr1r�r��oldr�s	         r"�packzMH.pack�s����&�&�(�	������=�=�?�	�C��Q�w�$������T�A�X��/�B��G�G�B�G�G�L�L����S��X�>��G�G�L�L����S����]�C�E��I�I�b�g�g�l�l�4�:�:�s�3�x�@�A��A�I�D�	�������w�<�1���'�o�o�/�	8�N�D�(�#�
8���S��(�?�47�H�X�^�^�C�0�1�
8�	8�	
���9�%��'��8�G��I�I�b�g�g�l�l�4�:�:�s�3�x�@� �g�g�l�l�4�:�:�s�4�!�8�}�E�G�G�s�A;E5�5B
H�Hc��|j�}|j�}|j�D]2\}}||vr|j|��||vs�!||j|�=�4|D]
}||vs�|g||<�|j	|�y)z;Inspect a new MHMessage and update sequences appropriately.N)r�rgrr�r�)rr+r1�pending_sequences�
all_sequencesr�r��sequences        r"r�zMH._dump_sequences�s���#�1�1�3���*�*�,�
�+�1�1�3�	2�N�D�(��(�(�����$�����X�^�^�C�0�1�		2�
*�	0�H��}�,�+.�%�
�h�'�	0�	
���=�)r$r�)r�r�r�r�r#r,r2r=rCrNrFrWrjrmr�r�r}r�rr$r,r5r�r�rr�r�r$r"rr�su���
� �D��0�2$�*	�;�
B�*� �!���
�7�
)�

��0�:&�4*r$rc�t�eZdZdZehd��Zdd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)rzAn Rmail-style Babyl mailbox.>�filed�edited�resent�unseen�deleted�answered�	forwardedNc�B�tj||||�i|_y)zInitialize a Babyl mailbox.N)rSr#�_labelsrs    r"r#zBabyl.__init__�s���#�#�D�$���@���r$c��tj||�}t|t�r|j	�|j
|<|S)r&)rSr,r�r�
get_labelsr)rr+r1s   r"r,z	Babyl.add�s:�� �$�$�T�7�3���g�|�,� '� 2� 2� 4�D�L�L����
r$c�h�tj||�||jvr|j|=yyr�)rSr2rr0s  r"r2zBabyl.remove�s/���!�!�$��,��$�,�,�����S�!�r$c��tj|||�t|t�r|j	�|j
|<yy)r;N)rSr=r�rrrr<s   r"r=zBabyl.__setitem__�s:���&�&�t�S�'�:��g�|�,� '� 2� 2� 4�D�L�L���-r$c��|j|�\}}|jj|�|jj�t	j
�}	|jj�}|dtzk(s|sn&|j|jtd���Ot	j
�}	|jj�}|tk(s|sn&|j|jtd���L||jj�z
}|dk\sJ�|jj|�}|jtd�}t|j�|z�}	|	j|j��||jvr|	j|j|�|	S)rI�*** EOOH ***r�r)r�rYr�r�r�r�r�r�r�ror�rr��set_visibler�
set_labels)
rr1r~r�original_headersr��visible_headers�n�bodyrs
          r"rCzBabyl.get_message�si���l�l�3�'���t��
�
������
�
�����:�:�<����:�:�&�&�(�D����0�0����"�"�4�<�<���#?�@�	�
�*�*�,����:�:�&�&�(�D��w��d���!�!�$�,�,�w��">�?�	�
�4�:�:�?�?�$�$���A�v�
�v��z�z���q�!���|�|�G�U�+���+�4�4�6��=�>������0�0�2�3��$�,�,���N�N�4�<�<��,�-��
r$c��|j|�\}}|jj|�|jj�t	j
�}	|jj�}|dtzk(s|sn&|j|jtd���O	|jj�}|tk(s|sn�'|j�}||jj�z
}|dk\sJ�|jj|�}|jtd�}||zS)r�rr�r)r�rYr�r�r�r�r�r�r�r�ror�)	rr1r~rrr��headersrr�s	         r"rNzBabyl.get_bytess	���l�l�3�'���t��
�
������
�
�����:�:�<����:�:�&�&�(�D����0�0����"�"�4�<�<���#?�@�	�
��:�:�&�&�(�D��w��d���#�+�+�-���4�:�:�?�?�$�$���A�v�
�v��z�z���q�!���|�|�G�U�+����~�r$c�r�tj|j|�jdt��S)rSr�)r�r�rNr�r�r0s  r"rFzBabyl.get_file-s'���z�z�$�.�.��-�5�5�e�W�E�F�Fr$c���|j�t�}|jj�D]}|j	|��|j|j�t|�S)z4Return a list of user-defined labels in the mailbox.)r�r�rrcrz�difference_update�_special_labelsrY)r�labels�
label_lists   r"rzBabyl.get_labels1sX����������,�,�-�-�/�	&�J��M�M�*�%�	&�� � ��!5�!5�6��F�|�r$c�@�gg}}|jjd�d}g}	|}|jj�}|jj�}|dtzk(r�t|�t|�kr!|j
|tt�z
�|j
|�|jj�ddjd�D�cgc]"}|j�r|j���$}}|j
|�nn|dk(s|dtzk(r9t|�t|�krF|j
|tt�z
�n$|s"|j
|tt�z
�n��dttt||���|_tt|��|_
t|j�|_|jjdd�|jj�|_ycc}w)r�rsrN�,�rH)rYr�r�ror�rrr��stripr�r�r�r�rrZr^)	rr�r�r��label_listsr�r��labelr"s	         r"r�zBabyl._generate_toc:s����B����
�
�����������H��:�:�&�&�(�D��z�z���(�H��{�W�,�,��u�:��F��+��L�L��C��L�!8�9��
�
�h�'�+/�:�:�+>�+>�+@���+D�+J�+J�4�+P�:�E�+0�;�;�=� �+�+�-�:��:��"�"�6�*����D�G�g�,=�$=��u�:��F��+��L�L��C��L�!8�9�����X��G��4�5��#�$��3�v�u�#5�6�7��	��I�k�2�3����T�Y�Y�����
�
����1�� �J�J�O�O�-����:s�'Hc���dtz}|dtzz
}|j�}d�|D�}|ddj|�ztzz
}|dz
}|j|�y)r�sBABYL OPTIONS:s
Version: 5c3�<K�|]}|j����y�wr4)r�)r�r)s  r"r�z*Babyl._pre_mailbox_hook.<locals>.<genexpr>]s����5�U�%�,�,�.�5�s�sLabels:r%r&N)r�rr�r�)rr�babylr"s    r"rqzBabyl._pre_mailbox_hookXsc��!�G�+��
���(�(�����"��5�f�5��
��d�i�i��/�/�'�9�9��
����	����r$c�4�|jdtz�y)r��Nr�r�s  r"rszBabyl._pre_message_hookbs��	����'�!�"r$c�4�|jtdz�y)r�r&Nr�r�s  r"ruzBabyl._post_message_hookfs��	����'�!�"r$c��|jj�}t|t��r	g}g}|j	�D]3}||j
vr|j
|��#|j
|��5|jjd�|D].}|jjd|j�z��0|jjd�|D]1}|jjd|j�zdz��3|jjt�n"|jjdtz�t|tjj��rtj�}tjj!|dd�}|j#|�|j%d�	|j'�}|jj|j)d
t��|d
k(s|sn�H|jjdtz�t|t�r�tj�}	tjj!|	dd�}
|
j#|j+��	|	j'�}|jj|j)d
t��|d
k(s|sn[�H|j%d�	|j'�}|jj|j)d
t��|d
k(s|sn�H	|j-d�}|s�n�|jj|j)d
t���Et|t.t0tj2f��r�t|tj2�r+t5j6d
t8d�|j;�}t|t0�r|j=|�}|j?d�dz}|dz
dk7r�|jj|d|j)d
t��|jjdtz�|jj|d|j)d
t��|jj||dj)d
t���n|jjdtztz�|jj|j)d
t���n�tA|d��r�tA|d�r't5j6dt8d�|jB}|j�}
d	}	|j'�}|jEd�r	|ddd
z}n|jEd�r|ddd
z}|jj|j)d
t��|d
k(s|s9|r6d}|jjdtz�|j%|
�nn��	|j'�}|sn�|jEd�r
|ddtz}n;|jEd�r
|ddtz}n|jEd
�r|ddtz}|jj|���tGdtI|�z��|jj�}||fS)z0Write message contents and return (start, stop).�1s, s,,� r%s1,,FrTr�rrlr�r�s

rHr�Nr�r�r�r�r�r�r�)%rYror�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�rvr�r�r�r�)rr+r~�special_labelsr"r)�orig_buffer�orig_generatorr��
vis_buffer�
vis_generatorr��
body_start�original_pos�
first_passrs                r"r�zBabyl._install_messagejs����
�
���!���g�|�,��N��F� �+�+�-�
)���D�0�0�0�"�)�)�%�0��M�M�%�(�	
)�

�J�J���T�"�'�
9���
�
� � ������!7�8�
9��J�J���U�#��
?���
�
� � ������!6��!=�>�
?��J�J���W�%��J�J���V�g�-�.��g�u�}�}�4�4�5��*�*�,�K�"�_�_�;�;�K��PQ�R�N��"�"�7�+����Q���"�+�+�-���
�
� � ����e�W�!=�>��5�=���	�

�J�J���_�w�6�7��'�<�0��Z�Z�\�
� %��� >� >�z�5�RS� T�
��%�%�g�&9�&9�&;�<��%�.�.�0�D��J�J�$�$�T�\�\�%��%A�B��u�}�D��	�� � ��#��&�/�/�1�D��J�J�$�$�T�\�\�%��%A�B��u�}�D��	�
�$�)�)�$�/�����
�
� � �����w�!?�@�	�
��%��b�k�k�!:�
;��'�2�;�;�/��
�
�*�+=�q�B�!�*�*�,���'�3�'��/�/��8�� ���g�.��2�J��A�~��#��
�
� � ���*�!5�!=�!=�e�W�!M�N��
�
� � ��7�!:�;��
�
� � ���*�!5�!=�!=�e�W�!M�N��
�
� � ����!5�!=�!=�e�W�!M�N��
�
� � ��7�!:�W�!D�E��
�
� � ������!@�A�
�W�j�
)��w��)��
�
�5�6H�!�M�!�.�.��"�<�<�>�L��J���'�'�)���=�=��)����9�u�,�D��]�]�5�)����9�u�,�D��
�
� � ����e�W�!=�>��5�=��!�%*�
��
�
�(�(��7�)B�C����\�2�����'�'�)�����=�=��)����9�w�.�D��]�]�5�)����9�w�.�D��]�]�5�)����9�w�.�D��
�
� � ��&���6��g��F�G�G��z�z��� ���t�}�r$r�)r�r�r�r��	frozensetr!r#r,r2r=rCrNrFrr�rqrsrur�r�r$r"rr�sY��'��!B�C�O��
�"�5��8�,G��.�<�#�#�ir$rc�$�eZdZdZdd�Zd�Zd�Zy)r
z0Message with mailbox-format-specific properties.Nc��t|tjj�rG|j	tj|��t|t�r|j|�yyt|t�r%|j	tj|��yt|t�r%|j	tj|��yt|tj�r%|j	tj|��yt|d�r%|j	tj |��y|�*tjjj#|�yt%dt'|�z��)zInitialize a Message instance.r�Nr�)r�rLr+r
�_become_message�copy�deepcopy�_explain_tor�rMr��message_from_stringr��
TextIOWrapper�message_from_filerv�message_from_binary_filer#r�r�r*s  r"r#zMessage.__init__�s���g�u�}�}�4�4�5�� � ����w�!7�8��'�7�+��#�#�D�)�,�
���
'�� � ��!9�!9�'�!B�C�
���
%�� � ��!:�!:�7�!C�D�
���!1�!1�
2�� � ��!8�!8��!A�B�
�W�f�
%�� � ��!?�!?��!H�I�
�_��M�M�!�!�*�*�4�0��6��g��F�G�Gr$c��t|dg�}|jD]#}||vs�|j||j|<�%y)z0Assume the non-format-specific state of message.�_type_specific_attributesN)�getattr�__dict__)rr+�
type_specificr�s    r"r?zMessage._become_message�sG����)D�b�I�
��$�$�	=�D��=�(�&-�&6�&6�t�&<��
�
�d�#�	=r$c�:�t|t�rytd��)z:Copy format-specific state to message insofar as possible.Nz Cannot convert to specified type)r�r
r�r*s  r"rBzMessage._explain_to�s���g�w�'���>�?�?r$r4)r�r�r�r�r#r?rBr�r$r"r
r
�s��:�H�&=�@r$r
c�b�eZdZdZgd�Zdd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zy)rz)Message with Maildir-specific properties.)�_subdir�_info�_dateNc�~�d|_d|_tj�|_tj||�y)z%Initialize a MaildirMessage instance.r�r�N)rNrOr7rPr
r#r*s  r"r#zMaildirMessage.__init__s-�������
��Y�Y�[��
�����w�'r$c��|jS)zReturn 'new' or 'cur'.)rNrVs r"r�zMaildirMessage.get_subdirs���|�|�r$c�B�|dk(s|dk(r||_ytd|z��)zSet subdir to 'new' or 'cur'.r�r�z!subdir must be 'new' or 'cur': %sN)rNr�)rr�s  r"r�zMaildirMessage.set_subdirs'���U�?�f��o�!�D�L��@�6�I�J�Jr$c�X�|jjd�r|jddSy)�*Return as a string the flags that are set.�2,rHNr�)rOr�rVs r"�	get_flagszMaildirMessage.get_flagss'���:�:� � ��&��:�:�a�b�>�!�r$c�H�ddjt|��z|_y)�)Set the given flags and unset all others.rVr�N)r�rrrO)r�flagss  r"�	set_flagszMaildirMessage.set_flagss���B�G�G�F�5�M�2�2��
r$c��|jdjt|j��t|�z��y�z.Set the given flag(s) without changing others.r�N�r[r�r�rW�r�flags  r"�add_flagzMaildirMessage.add_flag�,�����r�w�w�s�4�>�>�#3�4�s�4�y�@�A�Br$c��|j�rD|jdjt|j��t|�z
��yy)�7Unset the given string flag(s) without changing others.r�N)rWr[r�r�r_s  r"�remove_flagzMaildirMessage.remove_flag!s;���>�>���N�N�2�7�7�3�t�~�~�'7�#8�3�t�9�#D�E�F�r$c��|jS)z<Return delivery date of message, in seconds since the epoch.)rPrVs r"r�zMaildirMessage.get_date&����z�z�r$c�^�	t|�|_y#t$rtd|z�d�wxYw)z9Set delivery date of message, in seconds since the epoch.zcan't convert to float: %sN)�floatrPr�r�)r�dates  r"r�zMaildirMessage.set_date*s7��	K��t��D�J���	K��8�4�?�@�d�J�	K�s��,c��|jS)z%Get the message's "info" as a string.)rOrVs r"r�zMaildirMessage.get_info1rgr$c�`�t|t�r||_ytdt	|�z��)z Set the message's "info" string.zinfo must be a string: %sN)r�r�rOr�r�)rr�s  r"r�zMaildirMessage.set_info5s(���d�C� ��D�J��7�$�t�*�D�E�Er$c��t|t�r^|j|j��|j	|j��|j
|j��yt|t�r�t|j��}d|vr|jd�|j�dk(r|jd�d|vr|jd�d|vr|jd�d|vr|jd�|jd	tj|j���yt|t�rZt|j��}d|vr|jd
�d|vr|jd�d|vr|jd�yyt|t �rot|j��}d|vr|j#d
�d|vr|j#d
�d|vr|j#d�d|vr|j#d�yyt|t$�ryt'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[rWr�r�r�r�r�r�rar�r7r�r
r�r�	add_labelr
r�r�)rr+rZs   r"rBzMaildirMessage._explain_to<s����g�~�.����d�n�n�.�/����t���0�1����T�]�]�_�-�
��!1�
2�����(�)�E��e�|�� � ��%���� �E�)�� � ��%��e�|�� � ��%��e�|�� � ��%��e�|�� � ��%����_�d�k�k�$�-�-�/�.J�K�
���
+�����(�)�E��%���$�$�X�.��e�|��$�$�Y�/��e�|��$�$�Y�/��
���
.�����(�)�E��%���!�!�(�+��e�|��!�!�)�,��e�|��!�!�*�-��e�|��!�!�+�.��
���
)���B� ��M�*�+�
+r$r4)r�r�r�r�rHr#r�r�rWr[rarer�r�r�r�rBr�r$r"rr�sL��3� =��(��K��3�C�G�
�K��F�)+r$rc�J�eZdZdZdgZdd�Zd�Zdd�Zd�Zd�Z	d	�Z
d
�Zd�Zy)
r�z/Message with mbox- or MMDF-specific properties.�_fromNc�
�|jdd�t|tjj�r7|j�}|�%|j
d�r|j|dd�tj||�y)z'Initialize an mboxMMDFMessage instance.ruTNzFrom r�)r�r�rLr+r
r�r�r#)rr+r�s   r"r#z_mboxMMDFMessage.__init__msg���
�
�o�t�,��g�u�}�}�4�4�5��+�+�-�H��#��(;�(;�G�(D��
�
�h�q�r�l�+�����w�'r$c��|jS)z Return contents of "From " line.)r{rVs r"r�z_mboxMMDFMessage.get_fromvrgr$c�|�|�3|durtj�}|dtj|�zz
}||_y)z>Set "From " line, formatting and appending time_ if specified.NTr�)r7r�r�r{)rr��time_s   r"r�z_mboxMMDFMessage.set_fromzs9������}����
���S�4�<�<��.�.�.�E���
r$c�L�|jdd�|jdd�zS)rU�Statusr��X-Status)rArVs r"rWz_mboxMMDFMessage.get_flags�s#���x�x��"�%�����R�(@�@�@r$c��t|�}d\}}dD]}||vs�||z
}|j|��dD]}||vs�||z
}|j|��|djt|��z
}	|j	d|�	|j	d|�y#t
$r|j
d|�Y�1wxYw#t
$r|j
d|�YywxYw)rY)r�r�)rorp)rrrsrtr�r�r�N)r�r2r�rr�replace_headerr8�
add_header)rrZ�status_flags�
xstatus_flagsr`s     r"r[z_mboxMMDFMessage.set_flags�s����E�
��&,�#��m��	#�D��u�}���$�����T�"�	#�$�	#�D��u�}���%�
����T�"�	#�	�������/�/�
�	4�����,�7�	7����
�M�:���	4��O�O�H�l�3�	4���	7��O�O�J�
�6�	7�s$�3B�B:�B7�6B7�:C�Cc��|jdjt|j��t|�z��yr]r^r_s  r"raz_mboxMMDFMessage.add_flag�rbr$c��d|vsd|vrD|jdjt|j��t|�z
��yy)rdr�r�r�Nr^r_s  r"rez_mboxMMDFMessage.remove_flag�s@���t��z�T�1��N�N�2�7�7�3�t�~�~�'7�#8�3�t�9�#D�E�F� 2r$c���t|t�r�t|j��}d|vr|j	d�d|vr|jd�d|vr|jd�d|vr|jd�d|vr|jd�|d	=|d
=dj
|j�j�dd
�}	|jtjtj|d���y
t|t �r?|j#|j��|j%|j��y
t|t&�r_t|j��}d|vr|j)d�d|vr|j)d�d|vr|j)d�|d	=|d
=y
t|t*�r_t|j��}d|vr|j-d�d|vr|j-d�d|vr|j-d�|d	=|d
=y
t|t.�ry
t1dt3|�z��#ttf$rYy
wxYw)zACopy mbox- or MMDF-specific state to message insofar as possible.rpr�rsrtrornrrrq�statuszx-statusr����Nz%a %b %d %H:%M:%S %Yr
rvrwrrrx)r�rr�rWr�rar�r�r�r��calendar�timegmr7�strptimer��
OverflowErrorr�r[r�r
r�rryr
r�r�)rr+rZ�
maybe_dates    r"rBz_mboxMMDFMessage._explain_to�s9���g�~�.�����(�)�E��e�|��"�"�5�)��e�|�� � ��%��e�|�� � ��%��e�|�� � ��%��e�|�� � ��%���!��
�#����$�-�-�/�"7�"7�"9�"�#�">�?�J�
�� � �������z�6L�2N�"O�P���!1�
2����d�n�n�.�/����T�]�]�_�-�
���
+�����(�)�E��%���$�$�X�.��e�|��$�$�Y�/��e�|��$�$�Y�/���!��
�#�
���
.�����(�)�E��%���!�!�(�+��e�|��!�!�)�,��e�|��!�!�*�-���!��
�#�
���
)���B� ��M�*�+�
+��9�
�.�
��
�s�
8I�I*�)I*r4)
r�r�r�r�rHr#r�r�rWr[rarerBr�r$r"r�r�hs8��9�!(�	��(���A�7�,C�G�
1+r$r�c��eZdZdZy)rz&Message with mbox-specific properties.N�r�r�r�r�r�r$r"rr����0r$rc�<�eZdZdZdgZd
d�Zd�Zd�Zd�Zd�Z	d	�Z
y)r
z$Message with MH-specific properties.�
_sequencesNc�>�g|_tj||�y)z!Initialize an MHMessage instance.N)r�r
r#r*s  r"r#zMHMessage.__init__�s���������w�'r$c� �|jddS)z4Return a list of sequences that include the message.N)r�rVs r"r�zMHMessage.get_sequences�s�����q�!�!r$c�$�t|�|_y)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|jj|�yyt	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�sF���h��$��t���.����&�&�x�0�/��;�d�8�n�L�M�Mr$c�Z�	|jj|�y#t$rYywxYw)zARemove sequence from the list of sequences including the message.N)r�r2r�r�s  r"�remove_sequencezMHMessage.remove_sequence�s+��	��O�O�"�"�8�,���	��	����	*�*c�|�t|t�r}t|j��}d|vr|j	d�n"|j	d�|jd�d|vr|jd�d|vr|jd�y
y
t|t�rlt|j��}d|vr|jd�n|jd	�d|vr|jd�d|vr|jd
�y
y
t|t�r'|j�D]}|j|��y
t|t�rEt|j��}d|vr|jd�d|vr|jd�y
y
t|t�ry
tdt|�z��)z6Copy MH-specific state to message insofar as possible.r
r�rnrwrsrvro�ROrprtrrxN)r�rr�r�r�rar�r
r�rryr
r�r�)rr+r�rs    r"rBzMHMessage._explain_to�s����g�~�.��D�.�.�0�1�I��9�$��"�"�5�)��"�"�5�)�� � ��%��I�%�� � ��%��I�%�� � ��%�&�
��!1�
2��D�.�.�0�1�I��y�(�� � ��&�� � ��%��I�%�� � ��%��I�%�� � ��%�&�
���
+� �.�.�0�
/���$�$�X�.�
/�
���
.��D�.�.�0�1�I��9�$��!�!�(�+��I�%��!�!�*�-�&�
���
)���B� ��M�*�+�
+r$r4)r�r�r�r�rHr#r�r�r�r�rBr�r$r"r
r
�s,��.�!-���(�
"�*�N��$+r$r
c�P�eZdZdZddgZdd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
y)rz'Message with Babyl-specific properties.r�_visibleNc�\�g|_t�|_tj||�y)z#Initialize a BabylMessage instance.N)rr
r�r#r*s  r"r#zBabylMessage.__init__*s"������	��
�����w�'r$c� �|jddS)z'Return a list of labels on the message.N)rrVs r"rzBabylMessage.get_labels0s���|�|�A��r$c�$�t|�|_y)z&Set the list of labels on the message.N)rYr)rr"s  r"rzBabylMessage.set_labels4s
���F�|��r$c��t|t�r+||jvr|jj|�yyt	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"ryzBabylMessage.add_label8sF���e�S�!��D�L�L�(����#�#�E�*�)��8�4��;�F�G�Gr$c�Z�	|jj|�y#t$rYywxYw)z4Remove label from the list of labels on the message.N)rr2r�r�s  r"�remove_labelzBabylMessage.remove_label@s+��	��L�L����&���	��	�r�c�,�t|j�S)z3Return a Message representation of visible headers.�r
r�rVs r"r3zBabylMessage.get_visibleGs���t�}�}�%�%r$c�$�t|�|_y)z2Set the Message representation of visible headers.Nr�)r�visibles  r"rzBabylMessage.set_visibleKs����(��
r$c��|jj�D]3}||vr |jj|||��'|j|=�5dD](}||vs�||jvs�|||j|<�*y)z9Update and/or sensibly generate a set of visible headers.)�Date�FromzReply-To�To�CC�SubjectN)r�rZr�)r�headers  r"�update_visiblezBabylMessage.update_visibleOs���m�m�(�(�*�	*�F���~��
�
�,�,�V�T�&�\�B��M�M�&�)�		*�
J�	5�F���~�&��
�
�"=�(,�V���
�
�f�%�	5r$c���t|t�r�t|j��}d|vr|j	d�n"|j	d�|jd�d|vsd|vr|jd�d|vr|jd�d	|vr|jd
�yyt|t�rlt|j��}d|vr|jd�n|jd�d	|vr|jd
�d|vr|jd�yyt|t�rEt|j��}d|vr|jd�d|vr|jd�yyt|t�rF|j|j��|j�D]}|j|��yt|t�rytdt|�z��)z9Copy Babyl-specific state to message insofar as possible.r
r�rnr
r	r<rrorrqr�rprrrtrvrxN)r�rr�rr�rar�r
r�rrr3ryr
r�r�)rr+r"r)s    r"rBzBabylMessage._explain_toZs����g�~�.�����*�+�F��6�!��"�"�5�)��"�"�5�)�� � ��%��f�$��F�(:�� � ��%��V�#�� � ��%��F�"�� � ��%�#�
��!1�
2�����*�+�F��v�%�� � ��&�� � ��%��F�"�� � ��%��V�#�� � ��%�$�
���
+�����*�+�F��6�!��$�$�X�.��V�#��$�$�Y�/�$�
���
.����� 0� 0� 2�3����*�
)���!�!�%�(�
)�
���
)���B� ��M�*�+�
+r$r4)r�r�r�r�rHr#rrryr�r3rr�rBr�r$r"rr%s>��1�!*�J� 7��(��$�H��&�)�	5�'+r$rc��eZdZdZy)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�Zy)rzA read-only wrapper of a file.Nc�P�||_|�|j�|_y||_y)zInitialize a _ProxyFile.N)rYro�_pos)rr�poss   r"r#z_ProxyFile.__init__�s"����
��;�����D�I��D�Ir$c�N�|j||jj�S�zRead bytes.)�_readrYr��r�sizes  r"r�z_ProxyFile.read�s���z�z�$��
�
���0�0r$c�N�|j||jj�Sr�)r�rY�read1r�s  r"r�z_ProxyFile.read1�s���z�z�$��
�
� 0� 0�1�1r$c�N�|j||jj�S)zRead a line.)r�rYr�r�s  r"r�z_ProxyFile.readline�s���z�z�$��
�
� 3� 3�4�4r$c�l�g}|D],}|j|�|��|t|�z}|dks�+|S|S)zRead multiple lines.r)rr)r�sizehintrqr�s    r"�	readlinesz_ProxyFile.readlines�sL�����	�D��M�M�$���#��C��I�%���q�=���
�
	��
r$c#�`K�|j�x}r|��|j�x}r�yy�w)zIterate over lines.N)r�)rr�s  r"raz_ProxyFile.__iter__�s/�����m�m�o�%�d�%��J��m�m�o�%�d�%�s�).�.c��|jS)zReturn the position.)r�rVs r"roz_ProxyFile.tell�s���y�y�r$c���|dk(r%|jj|j�|jj||�|jj�|_y)zChange position.rN�rYr�r�ro�r�offset�whences   r"r�z_ProxyFile.seek�sA���Q�;��J�J�O�O�D�I�I�&��
�
�����'��J�J�O�O�%��	r$c��t|d�r4	t|jd�r|jj�|`yy#|`wxYw)zClose the file.rYr�N)rvrYr�rVs r"r�z_ProxyFile.close�sB���4��!�
��4�:�:�w�/��J�J�$�$�&��J�"��
�J�s�0A�Ac��|�d}|jj|j�||�}|jj�|_|S)z"Read size bytes using read_method.r�r�)rr��read_methodrqs    r"r�z_ProxyFile._read�sA���<��D��
�
����	�	�"��T�"���J�J�O�O�%��	��
r$c��|S)z$Context management protocol support.r�rVs r"�	__enter__z_ProxyFile.__enter__�s���r$c�$�|j�yr4)r�)r�excs  r"�__exit__z_ProxyFile.__exit__�s���
�
�r$c�6�|jj�Sr4)rY�readablerVs r"r�z_ProxyFile.readable�����z�z�"�"�$�$r$c�6�|jj�Sr4)rY�writablerVs r"r�z_ProxyFile.writable�r�r$c�6�|jj�Sr4)rY�seekablerVs r"r�z_ProxyFile.seekable�r�r$c�6�|jj�Sr4)rYr}rVs r"r}z_ProxyFile.flush�s���z�z���!�!r$c�v�t|d�syt|jd�sy|jjS)NrYTr�F)rvrYr�rVs r"r�z_ProxyFile.closed�s0���t�W�%���t�z�z�8�,���z�z� � � r$r4�r)r�r�r�r�r#r�r�r�r�raror�r�r�r�r�r�r�r�r}�propertyr�r�rr�r�r$r"rr�sv��(��1�2�5�	��
�&�����%�%�%�"��!��!�$�L�1�r$rc�2�eZdZdZdd�Zd�Zd	d�Zd�Zd�Zy)
r�z&A read-only wrapper of part of a file.Nc�N�tj|||�||_||_y)zInitialize a _PartialFile.N)rr#�_start�_stop)rrr~rs    r"r#z_PartialFile.__init__�s"�����D�!�U�+������
r$c�F�tj|�|jz
S)z*Return the position with respect to start.)rror�rVs r"roz_PartialFile.tell�s�����t�$�t�{�{�2�2r$c��|dk(r|j|_d}n|dk(r|j|_d}tj	|||�y)z8Change position, possibly with respect to start or stop.rrrHN)r�r�r�rr�r�s   r"r�z_PartialFile.seek�s@���Q�;����D�I��F�
�q�[��
�
�D�I��F�����f�f�-r$c��|j|jz
}|dkry|�
|dks||kDr|}tj|||�S)z;Read size bytes using read_method, honoring start and stop.rr$)r�r�rr�)rr�r��	remainings    r"r�z_PartialFile._readsJ���J�J����*�	���>���<�4�!�8�t�i�'7��D�����d�K�8�8r$c�"�t|d�r|`yy)NrY)rvrYrVs r"r�z_PartialFile.close
s���4��!��
�"r$)NNr�)	r�r�r�r�r#ror�r�r�r�r$r"r�r��s��0��3�.�9�r$r�c��d}	tr6	tj|tjtjz�|r{	t|jdz�}|j�		tj|j|jdz�d}tj|j�yyy#t$rY}|j
t
jt
jt
jfvrtd|jz���d}~wwxYw#t$r7}|j
t
jt
jfvrYd}~y�d}~wwxYw#t t"f$r2tj$|j|jdz�d}Y��wxYw#t&$r8tj(|j�td|jz��wxYw#tr$tj|tj*�|r"tj(|jdz��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��EAGAINrWrXrr�rpr�rr�r�r�r�r�rEr2�LOCK_UN)rrm�dotlock_doner��pre_locks     r"rgrgs����L�%��
����A�u�}�}�u�}�}�<�=��
�,�Q�V�V�g�-=�>����� �
1�-��G�G�H�M�M�1�6�6�G�+;�<�#'�L�
�I�I�h�m�m�,�!���
�
��7�7�u�|�|�U�\�\�5�;�;�G�G�,�-J�-.�V�V�.4�5�5���
���
��7�7�u�|�|�U�[�[�9�9����	
��'��8�(��I�I�h�m�m�Q�V�V�g�-=�>�#'�L�(��
#�
1��	�	�(�-�-�(�(�)C�)*���*0�1�1�
1�����K�K��5�=�=�)���I�I�a�f�f�w�&�'�
�s��G.�5B>�G.�(D#�-/E&�F*�>	D �AD�D � G.�#	E#�,,E�G.�E�E#�#G.�&>F'�$F*�&F'�'F*�*AG+�+G.�.AH?c��tr$tj|tj�tjj|jdz�r#tj|jdz�yy)z*Unlock file f using lockf and dot locking.r�N)r�r�r�rrr�r�r2�rs r"rjrj;sJ���
���A�u�}�}�%�	�w�w�~�~�a�f�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(rU)rr�r)r��O_RDWRr�)r�fds  r"rDrDBsP��	����r�z�z�B�I�I�-��	�	�9�5�	A�B���D�%� �
�����������s�	A*�*Bc
��t|�dttj���dtj��dtj����S)zBCreate a temp file based on path and open for reading and writing.r)rDr@r7r>r?rrA)rs r"rprpJs8���d�C��	�	��4D�.4�.@�.@�.B�.0�i�i�k�;�<�<r$c��|j�ttd�r$tj|j	��yy)z0Ensure changes to file f are physically on disk.�fsyncN)r}rvrr��filenor�s r"rnrnPs,���G�G�I��r�7��
��������r$c�:�t|�|j�y)z:Close file f, ensuring all changes are physically on disk.N)rnr�r�s r"r�r�Vs����N��G�G�Ir$c��eZdZdZy)rz"Raised for module-specific errors.Nr�r�r$r"rr\s��,r$rc��eZdZdZy)rz:The specified mailbox does not exist and won't be created.Nr�r�r$r"rr_s��Dr$rc��eZdZdZy)rz>The specified mailbox is not empty and deletion was requested.Nr�r�r$r"rrbs��Hr$rc��eZdZdZy)rz)Another process caused an action to fail.Nr�r�r$r"rre���3r$rc��eZdZdZy)rz)A file appears to have an invalid format.Nr�r�r$r"rrhrr$r)T)2r�rr7r�r>r�r@r�rL�
email.message�email.generatorr�rD�typesrr��ImportError�__all__r�r�rrrSr�rr	rrr+r
rr�rr
rrrr�rgrjrDrprnr��	Exceptionrrrrrr�r$r"�<module>r
s���J�
���
�������	�����A��

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

Zerion Mini Shell 1.0