Your IP : 18.118.32.6


Current Path : /opt/alt/python312/lib64/python3.12/__pycache__/
Upload File :
Current File : //opt/alt/python312/lib64/python3.12/__pycache__/imaplib.cpython-312.opt-2.pyc

�

�Q�f����b�	dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
mZmZddl
mZ	ddlZdZgd�ZdZdZd	Zd
ZdZdZid
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d�d!d�d"d�id#d�d$d�d%d�d&d�d'd�d(d�d)d�d*d�d+d�d,d�d-d�d.d�d/d�d0d�d1d�d2d�d3d��ddddddddd4��Zej4d5�Zej4d6�Zej4d7�Zej4d8ej<�Zej4d9�Z ej4d:�Z!ej4d;�Z"ej4d<ej<�Z#d8Z$d<Z%Gd=�d>�Z&erGd?�d@e&�Z'ejQd@�GdA�dBe&�Z)GdC�dD�Z*dEjWdF�Z,e-e,dGd�D��cic]\}}|j]�|dGz��c}}Z/dH�Z0dI�Z1dJ�Z2dK�Z3e4dLk(�r�ddl5Z5ddl6Z6	e5jjejndGddM�\Z8Z9dZ<e8D]!\Z=Z;e=dOk(r	e>e;�Z�e=dPk(s�e;Z<e9r�e<fZ9�#e9sdQZ9e9dZ?e6j��ZAe6jldReA�dSe?xsdT�dU��ZBdVeAdWdX�zZCdYeAeBffdZd[d\d]d^ddeCffd_d`dadbdcdddedfdgfZDdhdidjdkd]dddeCffdfdlfZEdm�ZF	e<r	e)e<�ZGne&e?�ZGeGj�dnk(reDdGdZDeGj�doeGj�z�eGj�dpeGj����eDD]\ZLZ9eFeLe9��eFdqdr�D]FZMej�dseM�ZOeOreOj�dG�ZQneMjW�dtZQeFdueQf��HeED]>\ZLZ9eFeLe9�ZReLe9fdjk7r�eRdtjW�ZSeSs�-eFdvddweSdtzdxf��@eTdy�yy#e$rdZY���wxYwcc}}w#e5jt$rZ;dN\Z8Z9YdZ;[;���dZ;[;wwxYw#eTdz�eseTd{ejndz��xYw)|z2.58�N)�datetime�timezone�	timedelta)�DEFAULT_BUFFER_SIZETF)�IMAP4�IMAP4_stream�Internaldate2tuple�Int2AP�
ParseFlags�Time2Internaldate�
�i�)�	IMAP4REV1ri@B�APPEND)�AUTH�SELECTED�AUTHENTICATE)�NONAUTH�
CAPABILITY)rrr�LOGOUT�CHECK)r�CLOSE�COPY�CREATE�DELETE�	DELETEACL�ENABLE)r�EXAMINE�EXPUNGE�FETCH�GETACL�
GETANNOTATION�GETQUOTA�GETQUOTAROOT�MYRIGHTS�LIST�LOGINr�LSUB�MOVE�	NAMESPACE�NOOP�PARTIAL�	PROXYAUTH�RENAME�SEARCH�SELECT�SETACL�
SETANNOTATION�SETQUOTA�SORT)�STARTTLS�STATUS�STORE�	SUBSCRIBE�THREAD�UID�UNSUBSCRIBE�UNSELECTs\+( (?P<data>.*))?s.*FLAGS \((?P<flags>[^\)]*)\)s�.*INTERNALDATE "(?P<day>[ 0123][0-9])-(?P<mon>[A-Z][a-z][a-z])-(?P<year>[0-9][0-9][0-9][0-9]) (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9]) (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])"s.*{(?P<size>\d+)}$s
\r\n|\r|\ns%\[(?P<type>[A-Z-]+)( (?P<data>.*))?\]s$\* (?P<type>[A-Z-]+)( (?P<data>.*))?s3\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?c��eZdZ	Gd�de�ZGd�de�ZGd�de�Zdedfd	�Zd
�Z	d�Z
d�Zd
�Zd�Z
d�Zd�Zdedfd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Z d"�Z!d#�Z"d$�Z#d%�Z$d&�Z%d'�Z&d(�Z'dQd)�Z(d*�Z)d+�Z*d,�Z+d-�Z,dQd.�Z-d/�Z.d0�Z/d1�Z0d2�Z1d3�Z2d4�Z3d5�Z4dRd6�Z5d7�Z6d8�Z7d9�Z8d:�Z9dSd;�Z:d<�Z;d=�Z<d>�Z=d?�Z>d@�Z?dA�Z@dB�ZAdC�ZBdD�ZCdE�ZDdF�ZEdG�ZFdH�ZGdI�ZHdTdJ�ZIdK�ZJdL�ZKdM�ZLdN�ZMdO�ZNdP�ZOy)Urc��eZdZy)�IMAP4.errorN��__name__�
__module__�__qualname__���./opt/alt/python312/lib64/python3.12/imaplib.py�errorr?���rErGc��eZdZy)�IMAP4.abortNr@rDrErF�abortrJ�rHrErKc��eZdZy)�IMAP4.readonlyNr@rDrErF�readonlyrM�rHrErN�Nc�N�t|_d|_d|_i|_i|_d|_d|_d|_d|_	|j�|j|||�	|j�y#t$r"	|j��#t$rY�wxYwwxYw)NrrOFr)�Debug�debug�state�literal�tagged_commands�untagged_responses�continuation_response�is_readonly�tagnum�_tls_established�_mode_ascii�open�_connect�	Exception�shutdown�OSError��self�host�port�timeouts    rF�__init__zIMAP4.__init__�s�����
���
����!���"$���%'��"� ������ %�������	
�	�	�$��g�&�	��M�M�O���	�
��
�
��
���
���
��	�s0�(A9�9	B$�B�B$�	B �B$�B � B$c���d|_d|_tjttj
�|_tjttj
�|_y)NF�ascii)	�utf8_enabled�	_encoding�re�compile�_Literal�ASCII�Literal�_Untagged_status�Untagged_status�rbs rFr[zIMAP4._mode_ascii�s?��!��� ����z�z�(�B�H�H�5���!�z�z�*:�B�H�H�E��rEc��d|_d|_tjt�|_tjt�|_y)NT�utf-8)rirjrkrlrmrorprqrrs rF�
_mode_utf8zIMAP4._mode_utf8�s3�� ��� ����z�z�(�+���!�z�z�*:�;��rEc��ttjdd��|_t	j
d|jzdztj�|_	|j�|_d|j vrd|_n1d|j vrd|_n|j%|j��|j'�	t*D]}||j(vr�||_y|j%d	��)
Nii��s(?P<tag>s"\d+) (?P<type>[A-Z]+) (?P<data>.*)�PREAUTHr�OKrzserver not IMAP4 compliant)r
�random�randint�tagprerkrlrn�tagre�_cmd_log_len�_cmd_log_idx�_cmd_logrR�_mesg�__version__�
_get_response�welcomerVrSrG�_get_capabilities�capabilities�AllowedVersions�PROTOCOL_VERSION)rb�versions  rFr]zIMAP4._connect�s����V�^�^�D�%�8�9����Z�Z���+�+�!&�@�!A�BD�(�(�L��
���)�)�+�����/�/�/��D�J�
�T�,�,�
,�"�D�J��*�*�T�\�\�*�*���� ��'�G��d�/�/�/��$+�D�!��	'��j�j�5�6�6rEc�b�|tvrt||j��Std|z��)NzUnknown IMAP4 command: '%s')�Commands�getattr�lower�AttributeError)rb�attrs  rF�__getattr__zIMAP4.__getattr__
s.���8���4�����.�.��:�T�A�B�BrEc��|S�NrDrrs rF�	__enter__zIMAP4.__enter__s���rEc�d�|jdk(ry	|j�y#t$rYywxYw�Nr)rS�logoutr`)rb�argss  rF�__exit__zIMAP4.__exit__s1���:�:��!��	��K�K�M���	��	�s�#�	/�/c�"�|�
|std��|jsdn|j}tjd||j|j�||jf}|�tj||�Stj|�S)Nz0Non-blocking socket (timeout=0) is not supportedzimaplib.open)�
ValueErrorrc�sys�auditrd�socket�create_connection)rbrerc�addresss    rF�_create_socketzIMAP4._create_socket#s{����w��O�P�P��9�9�t�$�)�)���	�	�.�$��	�	�4�9�9�=�����#�����+�+�G�W�=�=��'�'��0�0rEc��	||_||_|j|�|_|jj	d�|_y)N�rb)rcrdr��sock�makefile�fileras    rFr\z
IMAP4.open0s?��	�
��	���	��'�'��0��	��I�I�&�&�t�,��	rEc�:�	|jj|�Sr�)r��read�rb�sizes  rFr�z
IMAP4.read<s��,��y�y�~�~�d�#�#rEc��	|jjtdz�}t|�tkDr|j	dtz��|S)N�zgot more than %d bytes)r��readline�_MAXLINE�lenrG�rb�lines  rFr�zIMAP4.readlineAsC��$��y�y�!�!�(�Q�,�/���t�9�x���*�*�5��@�A�A��rEc�j�	tjd||�|jj|�y)Nzimaplib.send)r�r�r��sendall�rb�datas  rF�sendz
IMAP4.sendIs'��"��	�	�.�$��-��	�	���$�rEc��	|jj�	|jjtj
�|jj�y#t$r8}|jtjk7rt|dd�dk7r�Yd}~�Wd}~wwxYw#|jj�wxYw)N�winerrorri&')
r��closer�r_r��	SHUT_RDWRr`�errno�ENOTCONNr�)rb�excs  rFr_zIMAP4.shutdownOs���.��	�	����
	��I�I���v�/�/�0�
�I�I�O�O����	��	�	�U�^�^�+��3�
�A�.�%�7����
	��
�I�I�O�O��s)�)A!�!	B"�*.B�B%�B"�"B%�%Cc��	|jSr�)r�rrs rFr�zIMAP4.socket_s��	��y�y�rEc��	d}|jddg|�\}}|dr||fS|j�\}}|j|||�S)N�RECENTrx���)�_untagged_response�noop�rb�name�typ�dats    rF�recentzIMAP4.recentks\��	����*�*�4�$���>���S��r�7���8�O��9�9�;���S��&�&�s�C��6�6rEc�H�	|j|dg|j��Sr�)r��upper)rb�codes  rF�responsezIMAP4.response|s&��	��&�&�t�d�V�T�Z�Z�\�B�BrEc���	d}|sd}|r|d|dfdk7rd|z}nd}|rt|�}nd}tjt|�}|jrd|zdz}||_|j
||||�S)	Nr�INBOXrr���(�)�(%s)sUTF8 (�))r�MapCRLF�sub�CRLFrirT�_simple_command)rb�mailbox�flags�	date_time�messager�rTs       rF�appendzIMAP4.append�s���	�����G���a���r��#�y�0������E��)�)�4�I��I��+�+�d�G�,������'�)�D�0�G�����#�#�D�'�5�)�D�DrEc���	|j�}t|�j|_|j	d|�\}}|dk7r$|j|dj
dd���d|_||fS)Nrrxr�rt�replacer)r��_Authenticator�processrTr�rG�decoderS)rb�	mechanism�
authobject�mechr�r�s      rF�authenticatezIMAP4.authenticate�st��	���� ��
&�j�1�9�9����'�'���=���S��$�;��*�*�S��W�^�^�G�Y�?�@�@���
��C�x�rEc�V�	d}|j|�\}}|j|||�S)Nr�r�r�r�s    rF�
capabilityzIMAP4.capability�s7��	0����'�'��-���S��&�&�s�C��6�6rEc�&�	|jd�S)Nr�r�rrs rF�checkzIMAP4.check�s��	��#�#�G�,�,rEc�\�		|jd�\}}d|_||fS#d|_wxYw)Nrr�r�rS�rbr�r�s   rFr�zIMAP4.close�s;��	�	 ��+�+�G�4�H�C���D�J��C�x��� �D�J���"�	+c�*�	|jd||�S)Nrr�)rb�message_set�new_mailboxs   rF�copyz
IMAP4.copy�s��	��#�#�F�K��E�ErEc�(�	|jd|�S)Nrr��rbr�s  rF�createzIMAP4.create����	��#�#�H�g�6�6rEc�(�	|jd|�S)Nrr�r�s  rF�deletezIMAP4.delete�r�rEc�*�	|jd||�S)Nrr�)rbr��whos   rF�	deleteaclzIMAP4.deleteacl�s��	��#�#�K��#�>�>rEc���	d|jvrtjd��|jd|�\}}|dk(r"d|j	�vr|j�||fS)NrzServer does not support ENABLErxzUTF8=ACCEPT)r�rrGr�r�ru)rbr�r�r�s    rF�enablezIMAP4.enable�sh��	��4�,�,�,��+�+�>�?�?��(�(��:�>�	��T��$�;�=�J�,<�,<�,>�>��O�O���D�y�rEc�V�	d}|j|�\}}|j|||�S)Nrr�r�s    rF�expungez
IMAP4.expunges7��	����'�'��-���S��&�&�s�C��6�6rEc�Z�	d}|j|||�\}}|j|||�S)Nr r�)rbr��
message_partsr�r�r�s      rF�fetchzIMAP4.fetchs;��	����'�'��k�=�I���S��&�&�s�C��6�6rEc�T�	|jd|�\}}|j||d�S)Nr!�ACLr��rbr�r�r�s    rF�getaclzIMAP4.getacl(s4��	��'�'��'�:���S��&�&�s�C��7�7rEc�X�	|jd|||�\}}|j||d�S)Nr"�
ANNOTATIONr�)rbr��entry�	attributer�r�s      rF�
getannotationzIMAP4.getannotation1s8��	!��'�'���%��S���S��&�&�s�C��>�>rEc�T�	|jd|�\}}|j||d�S)Nr#�QUOTAr�)rb�rootr�r�s    rF�getquotazIMAP4.getquota9s4��	��'�'�
�D�9���S��&�&�s�C��9�9rEc��	|jd|�\}}|j||d�\}}|j||d�\}}|||gfS)Nr$r�	QUOTAROOTr�)rbr�r�r��quota�	quotaroots      rF�getquotarootzIMAP4.getquotarootDs_��	��'�'���@���S��,�,�S�#�w�?�
��U��0�0��c�;�G���Y��Y��&�&�&rEc�Z�	d}|j|||�\}}|j|||�S)Nr&r��rb�	directory�patternr�r�r�s      rF�listz
IMAP4.listO�;��	����'�'��i��A���S��&�&�s�C��6�6rEc��	|jd||j|��\}}|dk7r|j|d��d|_||fS)Nr'rxr�r)r��_quoterGrS)rb�user�passwordr�r�s     rF�loginzIMAP4.login[sT��	��'�'���t�{�{�8�7L�M���S��$�;��*�*�S��W�%�%���
��C�x�rEc�Z�	||c|_|_|jd|j�S)NzCRAM-MD5)rrr��_CRAM_MD5_AUTH)rbrrs   rF�login_cram_md5zIMAP4.login_cram_md5is2��	�$(�� ��	�4�=�� � ��T�-@�-@�A�ArEc���	ddl}t|jt�r|jj	d�n|j}|j
dz|j
||d�j�zS)Nrrt� �md5)�hmac�
isinstancer�str�encoder�HMAC�	hexdigest)rb�	challenger%�pwds    rFr zIMAP4._CRAM_MD5_AUTHrs\��?��0:�4�=�=�#�0N�t�}�}�#�#�G�,�26�-�-�	��y�y�3�����3�	�5�!A�!K�!K�!M�M�MrEc�b�	d|_|jd�\}}|j�||fSr�)rSr�r_r�s   rFr�zIMAP4.logoutzs6��	���
��'�'��1���S��
�
���C�x�rEc�Z�	d}|j|||�\}}|j|||�S)Nr(r�rs      rF�lsubz
IMAP4.lsub�rrEc�T�	|jd|�\}}|j||d�S)Nr%r�rs    rF�myrightszIMAP4.myrights�s4��	��&�&�z�7�;���C��&�&�s�C��<�<rEc�V�	d}|j|�\}}|j|||�S)Nr*r�r�s    rF�	namespacezIMAP4.namespace�s7��	����'�'��-���S��&�&�s�C��6�6rEc�(�		|jd�S)Nr+)rR�_dump_urrVr�rrs rFr�z
IMAP4.noop�s��	���#�#�F�+�+rEc�^�	d}|j|||||�\}}|j||d�S)Nr,r r�)rb�message_num�message_part�start�lengthr�r�r�s        rF�partialz
IMAP4.partial�s@��	����'�'��k�<��PV�W���S��&�&�s�C��9�9rEc�,�	d}|jd|�S)Nr-r�)rbrr�s   rF�	proxyauthzIMAP4.proxyauth�s!��	����#�#�K��6�6rEc�*�	|jd||�S)Nr.r�)rb�
oldmailbox�
newmailboxs   rF�renamezIMAP4.rename�s��	��#�#�H�j�*�E�ErEc���	d}|r:|jrtjd��|j|d|g|���\}}n|j|g|���\}}|j	|||�S)Nr/z'Non-None charset not valid in UTF8 mode�CHARSET)rirrGr�r�)rb�charset�criteriar�r�r�s      rF�searchzIMAP4.search�sy��	����� � ��k�k�"K�L�L�+�t�+�+�D�)�W�P�x�P�H�C��+�t�+�+�D�<�8�<�H�C���&�&�s�C��6�6rEc��	i|_||_|rd}nd}|j||�\}}|dk7rd|_||fSd|_d|jvr|s	|j
d|z��||jjddg�fS)	Nrr0rxrr�	READ-ONLYz%s is not writable�EXISTS)rVrXr�rSrRr5rN�get)rbr�rNr�r�r�s      rF�selectzIMAP4.select�s���
	�#%���#�����D��D��'�'��g�6���S��$�;��D�J���8�O���
��$�1�1�1� ���-�-� 4�w� >�?�?��D�+�+�/�/��4�&�A�A�ArEc�,�	|jd|||�S)Nr1r�)rbr�r��whats    rF�setaclzIMAP4.setacls ��	��#�#�H�g�s�D�A�ArEc�V�	|jdg|���\}}|j||d�S)Nr2rr�)rbr�r�r�s    rF�
setannotationzIMAP4.setannotation
s9��	�(�4�'�'��?�$�?���S��&�&�s�C��>�>rEc�V�	|jd||�\}}|j||d�S)Nr3rr�)rbr
�limitsr�r�s     rF�setquotazIMAP4.setquotas6��	��'�'�
�D�&�A���S��&�&�s�C��9�9rEc��	d}|d|dfdk7rd|z}|j|||g|���\}}|j|||�S)Nr4rr�r�r�r�)rb�
sort_criteriarD�search_criteriar�r�r�s       rF�sortz
IMAP4.sortse��	���
�!��]�2�.�/�9�<�"�]�2�M�'�4�'�'��m�W�W��W���S��&�&�s�C��6�6rEc��d}ts|jd��|jr|jd��||jvr|jd��|�tj�}|j|�\}}|dk(rd|j|j|j��|_	|jjd�|_d|_|j�n|jd	��|j|||�S)
Nr5zSSL support missingzTLS session already establishedzTLS not supported by serverrx��server_hostnamer�TzCouldn't establish TLS session)�HAVE_SSLrGrZrKr��ssl�_create_stdlib_contextr��wrap_socketr�rcr�r�r�r�)rb�ssl_contextr�r�r�s     rF�starttlszIMAP4.starttls)s�������*�*�2�3�3�� � ��*�*�>�?�?��t�(�(�(��*�*�:�;�;����4�4�6�K��'�'��-���S��$�;�#�/�/��	�	�@D�	�	�0�K�D�I��	�	�*�*�4�0�D�I�$(�D�!��"�"�$��*�*�=�>�>��&�&�s�C��6�6rEc�Z�	d}|j|||�\}}|j|||�S)Nr6r�)rbr��namesr�r�r�s      rF�statuszIMAP4.status@s=��	����'�'��g�u�=���S��&�&�s�C��6�6rEc�|�	|d|dfdk7rd|z}|jd|||�\}}|j||d�S)Nrr�r�r�r7r r�)rbr��commandr�r�r�s      rF�storezIMAP4.storeLsV��	�
�!�H�U�2�Y��9�,��U�N�E��'�'���g�u�M���S��&�&�s�C��9�9rEc�(�	|jd|�S)Nr8r�r�s  rF�	subscribezIMAP4.subscribeWs��	��#�#�K��9�9rEc�^�	d}|j|||g|���\}}|j|||�S)Nr9r�)rb�threading_algorithmrDrVr�r�r�s       rF�threadzIMAP4.thread_sC��	���'�4�'�'��.A�7�]�_�]���S��&�&�s�C��6�6rEc�d�	|j�}|tvr|jd|z��|jt|vr:|jd|�d|j�ddj	t|�����d}|j
||g|���\}}|dvr|}nd}|j
|||�S)	NzUnknown IMAP4 UID command: %s�command � illegal in state �, only allowed in states �, r:)r/r4r9r )r�r�rGrS�joinr�r�)rbrer�r�r�r�s      rF�uidz	IMAP4.uidis���	��-�-�/���(�"��*�*�<�w�F�G�G��:�:�X�g�.�.��*�*�%�t�z�z�"�i�i���(9�:�<�=�
=���'�4�'�'��g�=��=���S��2�2��D��D��&�&�s�C��6�6rEc�(�	|jd|�S)Nr;r�r�s  rF�unsubscribezIMAP4.unsubscribe�s��	��#�#�M�7�;�;rEc�\�		|jd�\}}d|_||fS#d|_wxYw)Nr<rr�)rbr�r�s   rF�unselectzIMAP4.unselect�s<��	�	 ��,�,�Z�8�I�C���D�J��D�y��� �D�J�r�c��	|j�}|tvr|jft|<|j|g|���Sr�)r�r�rSr��rbr�r�s   rF�xatomzIMAP4.xatom�sE��	��z�z�|���x��"�j�j�]�H�T�N�#�t�#�#�D�0�4�0�0rEc�d�|�d}|j}	||vr||j|�y|g||<y�NrE)rVrRr�r�rJr�)rbr�r��urs    rF�_append_untaggedzIMAP4._append_untagged�s>���;��C�
�
$�
$����"�9��s�G�N�N�3���e�B�s�GrEc��|jjd�}|r.|j|dj|jd���y)N�BYEr�r�)rVrJrKr�rj)rb�byes  rF�
_check_byezIMAP4._check_bye�sB���%�%�)�)�%�0����*�*�S��W�^�^�D�N�N�I�F�G�G�rEc��|jt|vrAd|_|jd|�d|j�ddj	t|�����dD]}||j
vs�|j
|=� d|j
vr|js|jd��|j�}t||j�}|dz|z}|D]3}|��t|t�rt||j�}|dz|z}�5|j}|�Qd|_t|�t|j�ur|}n'd}|td	t|�z|j�z}		|j'|t(z�|�|S	|j/�r"|j0|r|S|j/�r�"r||j2�}		|j'|�|j't(�|s	|S�t#t*$r}	|j-d
|	z��d}	~	wwxYw#t*$r}	|j-d
|	z��d}	~	wwxYw)Nrmrnrorp�rx�NO�BADrHz#mailbox status changed to READ-ONLY� z {%s}zsocket error: %s)rSr�rTrGrqrVrXrN�_new_tag�bytesrjr&r'�type�_commandr�rRr��_logr�r�r`rKr�rUrW)
rbr�r�r��tagr��argrT�	literator�vals
          rFr�zIMAP4._command�s9���:�:�X�d�^�+��D�L��*�*�"�D�J�J�"�i�i����7�9�:�
:�
'�C��d�-�-�-��+�+�C�0�'��$�1�1�1�� � ��-�-� E�F�F��m�m�o���T�4�>�>�*���T�z�D� ���C��{�H��#�s�#��C����0���$�;��$�D�	��,�,�����D�L��G�}��T�]�]� 3�3�#�	� �	��e�G�c�'�l�$:�D�N�N�K�K���	7��I�I�d�T�k�"��?��J���$�$�&��'�'��,��J��$�$�&��#�D�$>�$>�?���
;��	�	�'�"��	�	�$�����
�3��
�	7��*�*�/�#�5�6�6��	7��2�
;��j�j�!3�c�!9�:�:��
;�s0�,G=�&H"�=	H�H�H�"	I�+H?�?Ic�t�|dk(}|s|j�	|j||��\}}|s|j�|dk(r|j|�d|�d|����||fS#|j$r}|jd|�d|����d}~w|j$r}|jd|�d|����d}~wwxYw)Nr)�
expect_byez	command: � => r�z command error: r#)r��_get_tagged_responserKrG)rbr�r�r�r�r�r�s       rF�_command_completezIMAP4._command_completes����(�"����O�O��	@��1�1�#�&�1�I�I�C��
��O�O���%�<��*�*�$��T�J�K�K��D�y����z�z�	@��*�*�D�#�>�?�?���z�z�	@��*�*�D�#�>�?�?��	@�s#�A#�#B7�2B	�	B7�B2�2B7c���|j�\}}|dgk(r|jd��t|d|j�}|j	�}t|j
��|_y)Nz"no CAPABILITY response from serverr�)r�rGr'rjr��tuple�splitr�r�s   rFr�zIMAP4._get_capabilities#s]���?�?�$���S��4�&�=��*�*�A�B�B��#�b�'�4�>�>�*���i�i�k��!�#�)�)�+�.��rEc���|j�}|j|j|�r�|jj	d�}||j
vr|j
d|z��|jj	d�}t||j�}|jj	d�}||gf|j
|<�n�d}|jt|�s7|j|j|�r|jj	d�}|j�K|jt|�r!|jj	d�|_y|j
d|z��|jj	d�}t||j�}|jj	d�}|�d}|r|dz|z}|j|j|�rwt|jj	d	��}	|j#|�}|j%|||f�|j�}|j|j|�r�w|j%||�|d
vrr|jt&|�r\|jj	d�}t||j�}|j%||jj	d��	|S)Nr�zunexpected tagged response: %rr�r��data2zunexpected response: %rrEr�r�r�)�	_get_line�_matchr|�mo�grouprUrKr'rj�Untagged_responserq�ContinuationrWro�intrRr�r�r}�
Response_code)rb�respr�r�r��dat2r�r�s        rFr�zIMAP4._get_response,s\���~�~����;�;�t�z�z�4�(��'�'�-�-��&�C��$�.�.�.��j�j�!A�D�!H�I�I��'�'�-�-��'�C��c�4�>�>�*�C��'�'�-�-��'�C�),�s�e��D� � ��%��D��;�;�0�$�7��;�;�t�3�3�T�:��7�7�=�=��1�D��w�w���;�;�|�T�2�15�����v�1F�D�.���j�j�!:�T�!A�B�B��'�'�-�-��'�C��c�4�>�>�*�C��'�'�-�-��'�C��{�#�C��3��:��,�S��+�+�d�l�l�C�0��4�7�7�=�=��0�1����y�y�����%�%�c�C��;�7��n�n�&��!�+�+�d�l�l�C�0�$
�!�!�#�s�+��%�%�$�+�+�m�S�*I��'�'�-�-��'�C��c�4�>�>�*�C��!�!�#�t�w�w�}�}�V�'<�=���rEc��	|j|}|�|j|=|S|r$d}|jj|d�}|�||fS|j�	|j	��h#|j
$r}	�d}~wwxYw)Nr)rUrV�popr�r�rKrR�	print_log)rbr�r��resultr�r�r�s       rFr�zIMAP4._get_tagged_response|s�����)�)�#�.�F��!��(�(��-��
�����-�-�1�1�#�t�<���?���:�%�
�O�O��
��"�"�$�/��0�:�:�
����	
�s�A*�*B�9A;�;Bc��|j�}|s|jd��|jd�s|jd|z��|dd}	|S)Nzsocket error: EOFr
z#socket error: unterminated line: %r���)r�rK�endswithrRr�r�r�s  rFr�zIMAP4._get_line�sX���}�}�����*�*�0�1�1��}�}�W�%��*�*�B�T�I�J�J��C�R�y���
�rEc�L�|j|�|_	|jduSr�)�matchr�rRr�r�groups)rb�cre�ss   rFr�zIMAP4._match�s'��
�)�)�A�,�����w�w�d�"�"rEc��|jtt|j�|j�z}|jdz|_d|j
|<|S)Nr�)r{r�r'rYrjrU)rbr�s  rFr�zIMAP4._new_tag�sH���k�k�E�#�d�k�k�"2�D�N�N�C�C���k�k�A�o���$(����S�!��
rEc�Z�|jdd�}|jdd�}d|zdzS)N�\z\\�"z\")r�)rbr�s  rFrzIMAP4._quote�s0���k�k�$��'���k�k�#�u�%���S�y�3��rEc�H�|j||j|g|����Sr�)r�r�rxs   rFr�zIMAP4._simple_command�s%���%�%�d�M�D�M�M�$�,F��,F�G�GrEc�z�|dk(r||fS||jvr|dgfS|jj|�}	||fS)Nr�)rVr�rRr�)rbr�r�r�r�s     rFr�zIMAP4._untagged_response�sQ���$�;���8�O��t�.�.�.����;���&�&�*�*�4�0����D�y�rE)z""�*)r�Fr�)F)TrArBrCr^rGrKrN�
IMAP4_PORTrfr[rur]r�r�r�r�r\r�r�r�r_r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrrr!r r�r/r1r3r�r;r=rArFrKrNrPrSrWr`rcrfrhrkrrrtrvryr}r�r�r�r�r�r�r�r�r�rr�r�r�r5r�r�rDrErFrr�s���-�^!�	� �����5���Z���2F�<�'7�TC���1���T�	-�$�
� �
� �7�"C�E�4�:7�-��F�7�7�?�
�7�7�8�?�:�'�	7��B�N�
�	7�=�7�,�	:�
7�F�7�$B�@B�?�:�7�7�.	7�:�:�7�7�2<�
� 1�,�H�J�Z�$/�M�`�B�&	#���H�
	�rErc�6�eZdZ	defddd�d�Zd�Zdedfd�Zy)�	IMAP4_SSLrON)r_rec�n�|�tj�}||_tj	||||�yr�)r\r]r_rrf)rbrcrdr_res     rFrfzIMAP4_SSL.__init__s0���"�!�8�8�:��*�D���N�N�4��t�W�5rEc�|�tj||�}|jj||j��S)NrY)rr�r_r^rc)rbrer�s   rFr�zIMAP4_SSL._create_sockets=���'�'��g�6�D��#�#�/�/��@D�	�	�0�K�
KrEc�6�	tj||||�yr�)rr\ras    rFr\zIMAP4_SSL.open!s��
�

�J�J�t�T�4��1rE)rArBrC�IMAP4_SSL_PORTrfr�r\rDrErFr�r�s1��	�!#��	6�$(�$�	6�	K�
�^�T�	2rEr�c�4�eZdZ	d�Zdd�Zd�Zd�Zd�Zd�Zy)	rc�<�||_tj|�yr�)rerrf)rbres  rFrfzIMAP4_stream.__init__8s�����
���t�rENc�>�	d|_d|_d|_d|_t	j
|jttjtjdd��|_	|jj|_|jj|_
y)NT)�bufsize�stdin�stdout�shell�	close_fds)rcrdr�r��
subprocess�Popenrer�PIPEr�r��	writefiler��readfileras    rFr\zIMAP4_stream.open=sv��	���	���	���	���	�!�'�'����'��/�/�*�/�/��$�(������+�+������+�+��
rEc�:�	|jj|�Sr�)r�r�r�s  rFr�zIMAP4_stream.readMs��,��}�}�!�!�$�'�'rEc�8�	|jj�Sr�)r�r�rrs rFr�zIMAP4_stream.readlineRs��$��}�}�%�%�'�'rEc�p�	|jj|�|jj�yr�)r��write�flushr�s  rFr�zIMAP4_stream.sendWs'��"������T�"������rEc��	|jj�|jj�|jj	�yr�)r�r�r�r��waitrrs rFr_zIMAP4_stream.shutdown]s5��.��
�
���������������rE)NNN)	rArBrCrfr\r�r�r�r_rDrErFrr,s%����
,� (�
(�
�rErc�&�eZdZ	d�Zd�Zd�Zd�Zy)r�c��||_yr�)r�)rb�mechinsts  rFrfz_Authenticator.__init__ks	����	rEc�j�|j|j|��}|�y|j|�S)N�*)r�r�r()rbr��rets   rFr�z_Authenticator.processns0���i�i����D�)�*���;���{�{�3��rEc���d}t|t�r|jd�}|r?t|�dkDr|dd}|dd}n|}d}t	j
|�}|r||ddz}|r�?|S)NrErt�0r�)r&r'r(r��binascii�
b2a_base64)rb�inp�oup�t�es     rFr(z_Authenticator.encodets}�����c�3���*�*�W�%�C���3�x�"�}����H���"�#�h�������#�#�A�&�A���A�c�r�F�l����
rEc�2�|sytj|�Sr{)r��
a2b_base64)rbr�s  rFr�z_Authenticator.decode�s�����"�"�3�'�'rEN)rArBrCrfr�r(r�rDrErFr�r�es���� ��0(rEr�z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr#r�c	��	tj|�}|syt|jd�}|jd�}t	|jd��}t	|jd��}t	|jd��}t	|jd��}t	|jd��}t	|jd��}	t	|jd	��}
|	d
z|
zd
z}|dk(r|}||||||dddf	}tj|�|z
}
tj|
�S)
N�mon�zonen�day�year�hour�min�sec�zoneh�zonem�<�-r�)	�InternalDater��Mon2numr�r��calendar�timegm�time�	localtime)r�r�r�r�r�r�r�r�r�r�r��zone�tt�utcs              rFr	r	�s���
�	�	�D�	!�B�
��
�"�(�(�5�/�
"�C��H�H�W��E�

�b�h�h�u�o�
�C��r�x�x��� �D��r�x�x��� �D�

�b�h�h�u�o�
�C�

�b�h�h�u�o�
�C������!�"�E������!�"�E�
�"�H�u��b� �D���}��u��
��S�$��S�"�b�"�	5�B�
�/�/�"�
��
$�C��>�>�#��rEc�v�	d}d}tt|��}|rt|d�\}}|||dz|z}|r�|S)NrEsABCDEFGHIJKLMNOP�r�)r��abs�divmod)�numr��AP�mods    rFr
r
�sN��7�

�C�'�r�

�c�#�h�-�C�

��#�r�?���S���S��U�m�c�!����JrEc��	tj|�}|syt|jd�j	��S)NrDr�)�Flagsr�r�r�r�)r�r�s  rFrr�s6��7�	���T�	�B�
������'�"�(�(�*�+�+rEc�<�	t|ttf�r3tj|t
j�j�}n�t|t�r1	|j}t!|��}t|dddt|�i�}nTt|t�r|j"�t%d��|}n*t|t&�r|d|dfdk(r|St%d	��d
j)t*|j,�}|j/|�S#t$rtjrZ|d}|dk(r+tjtj|��d}tj
tjf|}ntj
}Y��2wxYw)N�r�)�seconds��tzinfozdate_time must be awarer)r�r�zdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")r&r��floatr�
fromtimestamprr��
astimezoner��	tm_gmtoffr�r��daylightr��mktime�altzonerrr�r'�format�Months�month�strftime)r��dt�gmtoff�dst�delta�fmts      rFrr�sb��	��)�c�5�\�*�
�
#�
#�I�$,�L�L�2�2<�*�,�	�	�I�u�	%�		(��(�(�F��&�)��
�y��!�}�
=�X�e�_�
=��	�I�x�	(����#��6�7�7�
��	�I�s�	#��1��i��m�(D�	�(Q����8�9�9�
"�
)�
)�&����*:�
;�C�
�;�;�s����'�	(��}�}���l���"�9��.�.����Y�)?�@��C�C��=�=�$�,�,�7��<�<���-�-����	(�s�D�BF�F�__main__zd:s:)rDrDz-dz-s)rOzIMAP password for z on �	localhostz: zJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s�
)r�lfr)r�)�
/tmp/xxx 1)rA)rz/tmp/yyy)r��
/tmp/yyz 2r�r)r)z/tmpzyy*)rKr)rF)N�SUBJECT�test)r)�1z(FLAGS INTERNALDATE RFC822))rf)r�FLAGSz
(\Deleted))r3rD)r�rD)r�rD)r�rD)rKrD)r�)�UIDVALIDITY)rr)r/�ALL)r�)rI)r�rDc��tj|�d|���tt|�|�\}}tj|�d|�d|���|dk(r|d�|S)Nr#r�r�r)�Mr�r�)�cmdr�r�r�s    rF�runr%0sP��	���3��%�&�"�7�1�c�?�D�)���S�	����c�3�/�0��$�;�c�!�f���
rErzPROTOCOL_VERSION = %szCAPABILITIES = r)z/tmp/zyy%z.*"([^"]+)"$r�r�rrz%sz:(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822.TEXT)z
All tests OK.z
Tests failed.z8
If you would like to see debugging output,
try: %s -d5
)Ur�r�r�ryrkr�r�r�r�r�rrr�iorr\r[�ImportError�__all__r�rQr�r�r�r�r�rlr�r�r�rnror�r�r�rqrmrprr�r�rr�r�r
�	enumerater(r�r	r
rrrA�getopt�getpass�argv�optlistr�rGr��stream_command�optr�rc�getuser�USER�PASSWD�	test_mesg�	test_seq1�	test_seq2r%r#rSr�r�r�r$�mlr�r�r��pathr�rr�print)�nr�s00rF�<module>r:sf��
�,��K�K�K�K�K�2�2�"����H�8��
��	��
�
���(����
,
��,�,
�	��,
�	�A�	,
�
	�
�,
�	�
�
,
�	�
�,
�	�,�,
�	�,�,
�	�,�,
�	�
�,
�	�,�,
�	�
�,
�	�
�,
�	�,�,
� 	�,�!,
�"	�,�#,
�$	�,�%,
�&	�,�',
�(	�,�),
�*	��+,
�,	�A�-,
�.	�,�/,
�0	�
�1,
�2	�,�3,
�4	�A�5,
�6	�
�7,
�8	�	�9,
�:	�,�;,
�<	�
�=,
�>	�,�?,
�@	�,�A,
�B	�,�C,
�D	�,�E,
�F	�
�G,
�H%�,�%�,�%�%�,�%�W,
��`�r�z�z�0�1����
�
�4�5���r�z�z�����"�*�*�+�R�X�X�
6��
�"�*�*�^�
$����
�
�D�E�
��B�J�J�G�H���"�*�*�;�R�X�X�G��"��J��x�x�v#�#2�E�#2�J�N�N�;��5�5�5�r*(�*(�X
<�	A�	A�#�	F��&/��q�r�
�&;�
<�&;�d�a��1�8�8�:�a��c�>�&;�
<���F	�,�%�R�z����%��
�
�c�h�h�q�r�l�F�;�
����N����C��$�;���H�E�
�D�[� �N��� 1��������7�D��7�?�?��D�
�W�_�_�t�T�EX�[�EX�Y�
Z�F�\�gk�rv�_w�w�I��t�V�n���*��
��d�D�)�4�5���)�3�,������I�$�!���
��d�D�)�,�-����I��)���^�,�A��d��A��7�7�f��!�!�"�
�I�	���'�!�*<�*<�<�=�	���q�~�~�7�8�!�H�C����T�N�"��f�.�/�B�����/�2�.�B��"�(�(�1�+�4�����B��$���4�'�"�	0�"�H�C���c�4�.�C��D�z�7�7���b�'�-�-�/�C��������B���P�R�
S�"�	�� �{��q.���H���d+=��`�<�<���
������j	�
�� ����
�h�h�q�k��
�
	�s<�O�
O!�#O'�>DP	�O�O�'P�6P�P�	%P.

?>