Your IP : 3.144.109.147


Current Path : /usr/lib64/python3.8/__pycache__/
Upload File :
Current File : //usr/lib64/python3.8/__pycache__/imaplib.cpython-38.opt-2.pyc

U

e5df��*@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
mZmZddl
mZzddlZdZWnek
r�dZYnXddd	d
ddgZd
ZdZdZdZdZdZdddddddddddddddddddddddddddddddddddddddddd�)Ze�d�Ze�d�Ze�d�Ze�dej�Ze�d�Z e�d�Z!e�d�Z"e�dej�Z#dZ$dZ%Gd d�d�Z&e�r�Gd!d"�d"e&�Z'e�(d"�Gd#d�de&�Z)Gd$d%�d%�Z*d&�+d'�Z,d(d)�e-e,d*d��D�Z.d+d	�Z/d,d
�Z0d-d�Z1d.d�Z2e3d/k�r�ddl4Z4ddl5Z5ze4�4ej6d*d�d0�\Z7Z8Wn.e4j9k
�rlZ:zd1\Z7Z8W5dZ:[:XYnXdZ;e7D]8\Z<Z:e<d2k�r�e=e:�Zne<d3k�rve:Z;e8�sve;fZ8�qve8�s�d4Z8e8dZ>e5�?�Z@e5�5d5e@e>�p�d6f�ZAd7e@d8d9�ZBd:e@eAffd;d<d=d>d?ddeBffd@dAdBdCdDdEdFdGdHfZCdIdJdKdLd>dddeBffdGdMfZDdNdO�ZE�ze;�r^e)e;�ZFne&e>�ZFeFjGdPk�r~eCd*d�ZCeF�HdQeFjI�eF�HdReFjJf�eCD]\ZKZ8eEeKe8��q�eEdSdT�D]<ZLe�MdUeL�ZNeN�r�eN�Od*�ZPneL�+�dVZPeEdWePf��q�eDD]T\ZKZ8eEeKe8�ZQeKe8fdKk�r*�qeQdV�+�ZReR�s@�qeEdXdYdZeRdVd[f��qeSd\�Wn.eSd]�e�s�eSd^ej6d��YnXdS)_z2.58�N)�datetime�timezone�	timedelta)�DEFAULT_BUFFER_SIZETF�IMAP4�IMAP4_stream�Internaldate2tuple�Int2AP�
ParseFlags�Time2Internaldate�
�i�)Z	IMAP4REV1ri@B)�AUTH�SELECTED)�NONAUTH)rrr�LOGOUT)r)r))�APPEND�AUTHENTICATE�
CAPABILITY�CHECK�CLOSE�COPY�CREATE�DELETE�	DELETEACL�ENABLE�EXAMINE�EXPUNGE�FETCH�GETACL�
GETANNOTATION�GETQUOTA�GETQUOTAROOT�MYRIGHTS�LIST�LOGINr�LSUBZMOVE�	NAMESPACE�NOOP�PARTIAL�	PROXYAUTH�RENAME�SEARCH�SELECT�SETACL�
SETANNOTATION�SETQUOTA�SORT�STARTTLS�STATUS�STORE�	SUBSCRIBE�THREAD�UID�UNSUBSCRIBEs\+( (?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@s�eZdZGdd�de�ZGdd�de�ZGdd�de�Zdefdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdefdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dBdC�Z%dDdE�Z&dFdG�Z'd�dJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,d�dTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1d^d_�Z2d`da�Z3dbdc�Z4d�dfdg�Z5dhdi�Z6djdk�Z7dldm�Z8dndo�Z9d�dqdr�Z:dsdt�Z;dudv�Z<dwdx�Z=dydz�Z>d{d|�Z?d}d~�Z@dd��ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNdpS)�rc@seZdZdS)zIMAP4.errorN��__name__�
__module__�__qualname__�r=r=�/usr/lib64/python3.8/imaplib.py�error�sr?c@seZdZdS)zIMAP4.abortNr9r=r=r=r>�abort�sr@c@seZdZdS)zIMAP4.readonlyNr9r=r=r=r>�readonly�srA�cCs�t|_d|_d|_i|_i|_d|_d|_d|_d|_	|�
�|�||�z|��Wn8t
k
r�z|��Wntk
r�YnX�YnXdS)NrrBFr)�Debug�debug�state�literal�tagged_commands�untagged_responses�continuation_response�is_readonly�tagnum�_tls_established�_mode_ascii�open�_connect�	Exception�shutdown�OSError��self�host�portr=r=r>�__init__�s&zIMAP4.__init__cCs0d|_d|_t�ttj�|_t�ttj�|_dS)NF�ascii)	�utf8_enabled�	_encoding�re�compile�_Literal�ASCII�Literal�_Untagged_status�Untagged_status�rTr=r=r>rM�szIMAP4._mode_asciicCs(d|_d|_t�t�|_t�t�|_dS)NT�utf-8)rYrZr[r\r]r_r`rarbr=r=r>�
_mode_utf8�szIMAP4._mode_utf8cCs�tt�dd��|_t�d|jdtj�|_|�	�|_
d|jkrHd|_nd|jkrZd|_n|�
|j
��|��tD]}||jkr�qr||_dS|�
d	��dS)
Nii��s(?P<tag>s"\d+) (?P<type>[A-Z]+) (?P<data>.*)ZPREAUTHr�OKrzserver not IMAP4 compliant)r	�randomZrandint�tagprer[r\r^�tagre�__version__�
_get_responseZwelcomerHrEr?�_get_capabilities�AllowedVersions�capabilities�PROTOCOL_VERSION)rT�versionr=r=r>rO�s*���



zIMAP4._connectcCs&|tkrt||���Std|��dS)NzUnknown IMAP4 command: '%s')�Commands�getattr�lower�AttributeError)rT�attrr=r=r>�__getattr__	szIMAP4.__getattr__cCs|S�Nr=rbr=r=r>�	__enter__szIMAP4.__enter__cGs4|jdkrdSz|��Wntk
r.YnXdS�Nr)rE�logoutrR)rT�argsr=r=r>�__exit__s
zIMAP4.__exit__cCs4|js
dn|j}t�d||j|j�t�||jf�S)Nzimaplib.open)rU�sys�auditrV�socketZcreate_connection)rTrUr=r=r>�_create_socketszIMAP4._create_socketcCs(||_||_|��|_|j�d�|_dS)N�rb)rUrVr�sock�makefile�filerSr=r=r>rN's
z
IMAP4.opencCs|j�|�Srv)r��read�rT�sizer=r=r>r�3sz
IMAP4.readcCs.|j�td�}t|�tkr*|�dt��|S)N�zgot more than %d bytes)r��readline�_MAXLINE�lenr?�rT�liner=r=r>r�8szIMAP4.readlinecCst�d||�|j�|�dS)Nzimaplib.send)r|r}r�Zsendall�rT�datar=r=r>�send@sz
IMAP4.sendc
Cst|j��zXz|j�tj�Wn@tk
r^}z"|jtjkrNt	|dd�dkrN�W5d}~XYnXW5|j��XdS)NZwinerrorri&')
r��closer�rQr~Z	SHUT_RDWRrR�errnoZENOTCONNrq)rT�excr=r=r>rQFs
�zIMAP4.shutdowncCs|jSrv)r�rbr=r=r>r~VszIMAP4.socketcCsBd}|�ddg|�\}}|dr(||fS|��\}}|�|||�S)NZRECENTre���)�_untagged_response�noop�rT�name�typ�datr=r=r>�recentbs	zIMAP4.recentcCs|�|dg|���Srv)r��upper)rT�coder=r=r>�responsesszIMAP4.responsecCsxd}|sd}|r.|d|dfdkr2d|}nd}|r@t|�}nd}t�t|�}|jrbd|d}||_|�||||�S)	Nr�INBOXrr���(�)�(%s)sUTF8 (�))r�MapCRLF�sub�CRLFrYrF�_simple_command)rT�mailbox�flags�	date_time�messager�rFr=r=r>�append�s

zIMAP4.appendcCsP|��}t|�j|_|�d|�\}}|dkrB|�|d�dd���d|_||fS)Nrrer�rc�replacer)r��_Authenticator�processrFr�r?�decoderE)rTZ	mechanismZ
authobject�mechr�r�r=r=r>�authenticate�szIMAP4.authenticatecCs d}|�|�\}}|�|||�S)Nr�r�r�r�r=r=r>�
capability�szIMAP4.capabilitycCs
|�d�S)Nr�r�rbr=r=r>�check�szIMAP4.checkcCs$z|�d�\}}W5d|_X||fS)Nrr)rEr��rTr�r�r=r=r>r��szIMAP4.closecCs|�d||�S)Nrr�)rT�message_setZnew_mailboxr=r=r>�copy�sz
IMAP4.copycCs|�d|�S)Nrr��rTr�r=r=r>�create�szIMAP4.createcCs|�d|�S)Nrr�r�r=r=r>�delete�szIMAP4.deletecCs|�d||�S)Nrr�)rTr��whor=r=r>�	deleteacl�szIMAP4.deleteaclcCsHd|jkrt�d��|�d|�\}}|dkr@d|��kr@|��||fS)NrzServer does not support ENABLErezUTF8=ACCEPT)rmrr?r�r�rd)rTr�r�r�r=r=r>�enable�s

zIMAP4.enablecCs d}|�|�\}}|�|||�S)Nrr�r�r=r=r>�expunges	z
IMAP4.expungecCs$d}|�|||�\}}|�|||�S)Nrr�)rTr�Z
message_partsr�r�r�r=r=r>�fetchs
zIMAP4.fetchcCs|�d|�\}}|�||d�S)NrZACLr��rTr�r�r�r=r=r>�getaclszIMAP4.getaclcCs"|�d|||�\}}|�||d�S)Nr �
ANNOTATIONr�)rTr��entryZ	attributer�r�r=r=r>�
getannotation(szIMAP4.getannotationcCs|�d|�\}}|�||d�S)Nr!�QUOTAr�)rT�rootr�r�r=r=r>�getquota0szIMAP4.getquotacCs@|�d|�\}}|�||d�\}}|�||d�\}}|||gfS)Nr"r�Z	QUOTAROOTr�)rTr�r�r�ZquotaZ	quotarootr=r=r>�getquotaroot;szIMAP4.getquotaroot�""�*cCs$d}|�|||�\}}|�|||�S)Nr$r��rTZ	directory�patternr�r�r�r=r=r>�listFsz
IMAP4.listcCs<|�d||�|��\}}|dkr.|�|d��d|_||fS)Nr%rer�r)r��_quoter?rE)rT�user�passwordr�r�r=r=r>�loginRs
zIMAP4.logincCs|||_|_|�d|j�S)NzCRAM-MD5)r�r�r��_CRAM_MD5_AUTH)rTr�r�r=r=r>�login_cram_md5`szIMAP4.login_cram_md5cCsBddl}t|jt�r |j�d�n|j}|jd|�||d���S)Nrrc� Zmd5)�hmac�
isinstancer��str�encoder�ZHMACZ	hexdigest)rTZ	challenger��pwdr=r=r>r�is
�zIMAP4._CRAM_MD5_AUTHcCs$d|_|�d�\}}|��||fSrx)rEr�rQr�r=r=r>ryqszIMAP4.logoutcCs$d}|�|||�\}}|�|||�S)Nr&r�r�r=r=r>�lsub~sz
IMAP4.lsubcCs|�d|�\}}|�||d�S)Nr#r�r�r=r=r>�myrights�szIMAP4.myrightscCs d}|�|�\}}|�|||�S)Nr'r�r�r=r=r>�	namespace�szIMAP4.namespacecCs
|�d�S)Nr(r�rbr=r=r>r��sz
IMAP4.noopcCs(d}|�|||||�\}}|�||d�S)Nr)rr�)rTZmessage_numZmessage_part�startZlengthr�r�r�r=r=r>�partial�sz
IMAP4.partialcCsd}|�d|�S)Nr*r�)rTr�r�r=r=r>�	proxyauth�s	zIMAP4.proxyauthcCs|�d||�S)Nr+r�)rTZ
oldmailboxZ
newmailboxr=r=r>�rename�szIMAP4.renamecGsTd}|r2|jrt�d��|j|d|f|��\}}n|j|f|��\}}|�|||�S)Nr,z'Non-None charset not valid in UTF8 mode�CHARSET)rYrr?r�r�)rT�charsetZcriteriar�r�r�r=r=r>�search�s
zIMAP4.searchr�FcCsvi|_||_|rd}nd}|�||�\}}|dkr@d|_||fSd|_d|jkrb|sb|�d|��||j�ddg�fS)	Nrr-rerr�	READ-ONLYz%s is not writable�EXISTS)rHrJr�rErA�get)rTr�rAr�r�r�r=r=r>�select�s
�zIMAP4.selectcCs|�d|||�S)Nr.r�)rTr�r�Zwhatr=r=r>�setacl�szIMAP4.setaclcGs |jd|��\}}|�||d�S)Nr/r�)r/r�)rTrzr�r�r=r=r>�
setannotationszIMAP4.setannotationcCs |�d||�\}}|�||d�S)Nr0r�r�)rTr�Zlimitsr�r�r=r=r>�setquota	szIMAP4.setquotacGsFd}|d|dfdkr d|}|j|||f|��\}}|�|||�S)Nr1rr�r�r�r�)rTZ
sort_criteriar��search_criteriar�r�r�r=r=r>�sorts
z
IMAP4.sortNcCs�d}ts|�d��|jr"|�d��||jkr6|�d��|dkrFt��}|�|�\}}|dkr�|j|j	|j
d�|_	|j	�d�|_d|_|�
�n
|�d	��|�|||�S)
Nr2zSSL support missingzTLS session already establishedzTLS not supported by serverre�Zserver_hostnamer�TzCouldn't establish TLS session)�HAVE_SSLr?rLr@rm�ssl�_create_stdlib_contextr��wrap_socketr�rUr�r�rkr�)rT�ssl_contextr�r�r�r=r=r>�starttls s&



�

zIMAP4.starttlscCs$d}|�|||�\}}|�|||�S)Nr3r�)rTr��namesr�r�r�r=r=r>�status7szIMAP4.statuscCs>|d|dfdkrd|}|�d|||�\}}|�||d�S)Nrr�r�r�r4rr�)rTr��commandr�r�r�r=r=r>�storeCszIMAP4.storecCs|�d|�S)Nr5r�r�r=r=r>�	subscribeNszIMAP4.subscribecGs*d}|j|||f|��\}}|�|||�S)Nr6r�)rTZthreading_algorithmr�r�r�r�r�r=r=r>�threadVszIMAP4.threadc	Gs�|��}|tkr|�d|��|jt|krL|�d||jd�t|�f��d}|j||f|��\}}|dkrt|}nd}|�|||�S)NzUnknown IMAP4 UID command: %s�9command %s illegal in state %s, only allowed in states %s�, r7)r,r1r6r)r�rpr?rE�joinr�r�)rTr�rzr�r�r�r=r=r>�uid`s��z	IMAP4.uidcCs|�d|�S)Nr8r�r�r=r=r>�unsubscribeyszIMAP4.unsubscribecGs,|��}|tkr|jft|<|j|f|��Srv)r�rprEr��rTr�rzr=r=r>�xatom�s
zIMAP4.xatomcCs8|dkrd}|j}||kr*||�|�n
|g||<dS�N�)rHr�r�)rTr�r�Zurr=r=r>�_append_untagged�szIMAP4._append_untaggedcCs,|j�d�}|r(|�|d�|jd���dS)N�BYEr�r�)rHr�r@r�rZ)rT�byer=r=r>�
_check_bye�szIMAP4._check_byec

Gs�|jt|kr4d|_|�d||jd�t|�f��dD]}||jkr8|j|=q8d|jkrj|jsj|�d��|��}t	||j
�}|d|}|D]0}|dkr�q�t|t�r�t	||j
�}|d|}q�|j}|dk	�r
d|_t
|�t
|j�kr�|}nd}|t	dt|�|j
�}z|�|t�Wn2tk
�rN}	z|�d|	��W5d}	~	XYnX|dk�r^|S|���r||j|�r^|S�q^|�r�||j�}z|�|�|�t�Wn2tk
�r�}	z|�d|	��W5d}	~	XYnX|�s^�q�q^|S)	Nr�r��re�NO�BADr�z#mailbox status changed to READ-ONLY� z {%s}zsocket error: %s)rErprFr?r�rHrJrA�_new_tag�bytesrZr�r��type�_commandr�r�r�rRr@rjrGrI)
rTr�rzr��tagr��argrFZ	literator�valr=r=r>r�sb��


�


 



 zIMAP4._commandc
Cs�|dk}|s|��z|j||d�\}}Wnj|jk
r`}z|�d||f��W5d}~XYn6|jk
r�}z|�d||f��W5d}~XYnX|s�|��|dkr�|�d|||f��||fS)Nr)�
expect_byezcommand: %s => %srz%s command error: %s %s)r�_get_tagged_responser@r?)rTr�rryr�r�rr=r=r>�_command_complete�s"$zIMAP4._command_completecCsJ|��\}}|dgkr |�d��t|d|j�}|��}t|���|_dS)Nz"no CAPABILITY response from serverr�)r�r?r�rZr��tuple�splitrmr�r=r=r>rk
s

zIMAP4._get_capabilitiescCs�|��}|�|j|�rp|j�d�}||jkr:|�d|��|j�d�}t||j�}|j�d�}||gf|j|<n�d}|�t	|�s�|�|j
|�r�|j�d�}|jdkr�|�t|�r�|j�d�|_dS|�d|��|j�d�}t||j�}|j�d�}|dk�rd}|�r|d|}|�|j
|��rZt|j�d	��}|�|�}|�|||f�|��}�q|�||�|d
k�r�|�t|��r�|j�d�}t||j�}|�||j�d��|S)Nrzunexpected tagged response: %rrr�Zdata2zunexpected response: %rrrr�r	)�	_get_line�_matchrh�mo�grouprGr@r�rZ�Untagged_responsera�ContinuationrIr_�intr�r�
Response_code)rT�resprr�r�Zdat2r�r�r=r=r>rjsH



zIMAP4._get_responsec
Cs�|j|}|dk	r|j|=|S|rDd}|j�|d�}|dk	rD||fS|��z|��Wq|jk
r~}z�W5d}~XYqXqdS)Nr)rGrH�poprrjr@)rTrr�resultr�rrr=r=r>rcs
zIMAP4._get_tagged_responsecCs>|��}|s|�d��|�d�s.|�d|��|dd�}|S)Nzsocket error: EOFrz#socket error: unterminated line: %r���)r�r@�endswithr�r=r=r>r�s

zIMAP4._get_linecCs|�|�|_|jdk	Srv)�matchr)rTZcre�sr=r=r>r�szIMAP4._matchcCs2|jtt|j�|j�}|jd|_d|j|<|S)Nr�)rgrr�rKrZrG)rTrr=r=r>r
�s
zIMAP4._new_tagcCs$|�dd�}|�dd�}d|dS)N�\z\\�"z\")r�)rTrr=r=r>r��szIMAP4._quotecGs|�||j|f|���Srv)rrrr=r=r>r��szIMAP4._simple_commandcCs8|dkr||fS||jkr$|dgfS|j�|�}||fS)Nr
)rHr")rTr�r�r�r�r=r=r>r��s

zIMAP4._untagged_response)r�r�)r�r�)r�F)N)F)Sr:r;r<rPr?r@rA�
IMAP4_PORTrWrMrdrOrurwr{rrNr�r�r�rQr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ryr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrkrjrrrr
r�r�r��_mesgZ_dump_urZ_logZ	print_logr=r=r=r>r�s�.*
		
	



 	

M	P
!$c@s6eZdZdedddfdd�Zdd�Zdefdd�ZdS)	�	IMAP4_SSLrBNcCs�|dk	r|dk	rtd��|dk	r0|dk	r0td��|dk	s@|dk	rVddl}|�dtd�||_||_|dkrxtj||d�}||_t	�
|||�dS)Nz8ssl_context and keyfile arguments are mutually exclusivez9ssl_context and certfile arguments are mutually exclusiverzEkeyfile and certfile are deprecated, use a custom ssl_context instead�)�certfile�keyfile)�
ValueError�warnings�warn�DeprecationWarningr/r.r�r�r�rrW)rTrUrVr/r.r�r1r=r=r>rW�s$��zIMAP4_SSL.__init__cCst�|�}|jj||jd�S)Nr�)rrr�r�rU)rTr�r=r=r>rs
�zIMAP4_SSL._create_socketcCst�|||�dSrv)rrNrSr=r=r>rNszIMAP4_SSL.open)r:r;r<�IMAP4_SSL_PORTrWrrNr=r=r=r>r,�s�
r,c@s>eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rcCs||_t�|�dSrv)r�rrW)rTr�r=r=r>rW/szIMAP4_stream.__init__NcCsNd|_d|_d|_d|_tj|jttjtjddd�|_	|j	j
|_|j	j|_
dS)NT)�bufsize�stdin�stdout�shellZ	close_fds)rUrVr�r��
subprocess�Popenr�r�PIPEr�r6�	writefiler7�readfilerSr=r=r>rN4s�
zIMAP4_stream.opencCs|j�|�Srv)r=r�r�r=r=r>r�DszIMAP4_stream.readcCs
|j��Srv)r=r�rbr=r=r>r�IszIMAP4_stream.readlinecCs|j�|�|j��dSrv)r<�write�flushr�r=r=r>r�NszIMAP4_stream.sendcCs"|j��|j��|j��dSrv)r=r�r<r��waitrbr=r=r>rQTs

zIMAP4_stream.shutdown)NN)	r:r;r<rWrNr�r�r�rQr=r=r=r>r#s
c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs
||_dSrv)r�)rTZmechinstr=r=r>rWbsz_Authenticator.__init__cCs&|�|�|��}|dkrdS|�|�S)N�*)r�r�r�)rTr�Zretr=r=r>r�esz_Authenticator.processcCsnd}t|t�r|�d�}|rjt|�dkrB|dd�}|dd�}n|}d}t�|�}|r||dd�}q|S)Nrrc�0r�)r�r�r�r��binasciiZ
b2a_base64)rT�inpZoup�t�er=r=r>r�ks	


z_Authenticator.encodecCs|sdSt�|�Sr)rCZ
a2b_base64)rTrDr=r=r>r��sz_Authenticator.decodeN)r:r;r<rWr�r�r�r=r=r=r>r�\sr�z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr�cCsi|]\}}|��|d�qS)r�)r�)�.0�nr'r=r=r>�
<dictcomp>�srIr�c	Cs�t�|�}|sdSt|�d�}|�d�}t|�d��}t|�d��}t|�d��}t|�d��}t|�d��}t|�d��}	t|�d	��}
|	d
|
d
}|dkr�|}||||||dddf	}t�|�|}
t�|
�S)
N�mon�zonen�day�year�hour�min�sec�zoneh�zonem�<�-r�)	�InternalDater&�Mon2numrr�calendarZtimegm�time�	localtime)r!rrJrKrLrMrNrOrPrQrRZzoneZtt�utcr=r=r>r�s$

cCs@d}d}tt|��}|r<t|d�\}}|||d�|}q|S)NrsABCDEFGHIJKLMNOP�r�)r�abs�divmod)ZnumrZAP�modr=r=r>r	�scCs$t�|�}|sdSt|�d����S)Nr=r�)�Flagsr&rrr)r!rr=r=r>r
�s
cCst|ttf�r"t�|tj���}n�t|t�r�z
|j	}WnZt
k
r�tjr�|d}|dkrpt�
t�|��d}tjtjf|}ntj}YnXt|d�}t|dd�dt|�i�}nLt|t�r�|jdkr�td��|}n*t|t�r�|d|dfdkr�|Std	��d
�t|j�}|�|�S)N�r�)Zseconds��tzinfozdate_time must be awarer)r)r)zdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")r�r�floatrZ
fromtimestamprrZZ
astimezoner�	tm_gmtoffrsrX�daylightrY�mktime�altzonerrbr0r��format�MonthsZmonth�strftime)r�ZdtZgmtoffZdstZdeltaZfmtr=r=r>r�s2�





�__main__zd:s:)r=r=z-dz-s)rBzIMAP password for %s on %s: Z	localhostzJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s�
)r�Zlfr�)r�)�
/tmp/xxx 1)r�)rmz/tmp/yyy)r��
/tmp/yyz 2r�ro)r�)z/tmpzyy*)r�rn)r�)NZSUBJECTZtest)r�)�1z(FLAGS INTERNALDATE RFC822))r�)rp�FLAGSz
(\Deleted))r�r=)r�r=)r�r=)r�r=)r�r=)r�)ZUIDVALIDITY)r�)r,ZALL)r�)r�)ryr=cCsLt�d||f�tt|�|�\}}t�d|||f�|dkrH|d�|S)Nz%s %sz%s => %s %sr
r)�Mr+rq)�cmdrzr�r�r=r=r>�run'srtrzPROTOCOL_VERSION = %szCAPABILITIES = %rr�)z/tmp/zyy%z.*"([^"]+)"$r�r�r�rz%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
)TrirCr�rfr[r~r9r|rXrWrrr�iorr�r��ImportError�__all__r�rCr*r4rlr�rpr\rr_rUr^r_r�r rrar]r`rr,r�rr�rri�	enumeraterVrr	r
rr:ZgetoptZgetpass�argvZoptlistrzr?rZstream_command�optrrUZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2rtrrrEr+rnrmrsZmlr&rr�pathr�r��printr=r=r=r>�<module>sXH
�	�/



	

�l4
9,
#
)





��


�
�

?>