AlkantarClanX12

Your IP : 18.116.89.8


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/imaplib.cpython-37.opt-2.pyc

B

YI~d,��*@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
mZmZddl
mZyddlZdZWnek
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�ddl4Z4ddl5Z5ye4�4ej6d*d�d0�\Z7Z8Wn.e4j9k
�rlZ:zd1\Z7Z8WddZ:[:XYnXdZ;x@e7D]8\Z<Z:e<d2k�r�e=e:�Zne<d3k�rxe:Z;e8�sxe;fZ8�qxWe8�s�d4Z8e8dZ>e5�?�Z@e5�5d5e@e>�p�d6f�ZAd7e@d8d9�ZBd:e@eAffd;d<d=d>d?ddeBffd@dAdBdCdDdEdFdGdHfZCdIdJdKdLd>dddeBffdGdMfZDdNdO�ZE�y&e;�rbe)e;�ZFne&e>�ZFeFjGdPk�r�eCd*d�ZCeF�HdQeFjI�eF�HdReFjJf�xeCD]\ZKZ8eEeKe8��q�WxJeEdSdT�D]<ZLe�MdUeL�ZNeN�r�eN�Od*�ZPneL�+�dVZPeEdWePf��q�Wx\eDD]T\ZKZ8eEeKe8�ZQeKe8fdKk�r8�qeQdV�+�ZReR�sN�qeEdXdYdZeRdVd[f��qWeSd\�Wn.eSd]�e�s�eSd^ej6d��YnXdS)_z2.58�N)�datetime�timezone�	timedelta)�DEFAULT_BUFFER_SIZETF�IMAP4�IMAP4_stream�Internaldate2tuple�Int2AP�
ParseFlags�Time2Internaldates
�i�)Z	IMAP4REV1ri@B)�AUTH�SELECTED)�NONAUTH)rr
r�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��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNdpS)�rc@seZdZdS)zIMAP4.errorN)�__name__�
__module__�__qualname__�r;r;�,/opt/alt/python37/lib64/python3.7/imaplib.py�error�sr=c@seZdZdS)zIMAP4.abortN)r8r9r:r;r;r;r<�abort�sr>c@seZdZdS)zIMAP4.readonlyN)r8r9r:r;r;r;r<�readonly�sr?�cCs�t|_d|_d|_i|_i|_d|_d|_d|_d|_	|�
�|�||�y|��Wn8t
k
r�y|��Wntk
r�YnX�YnXdS)Nrr@Fr)�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)rQr;r;r<rK�szIMAP4._mode_asciicCs(d|_d|_t�t�|_t�t�|_dS)NTzutf-8)rVrWrXrYrZr\r]r^)rQr;r;r<�
_mode_utf8�szIMAP4._mode_utf8cCs�tt�dd��|_t�d|jdtj�|_|��|_	d|j
krHd|_nd|j
krZd|_n|�|j	��|�
�x tD]}||jkr�qt||_dSW|�d	��dS)
Nii��s(?P<tag>s"\d+) (?P<type>[A-Z]+) (?P<data>.*)ZPREAUTHr
�OKrzserver not IMAP4 compliant)r	�randomZrandint�tagprerXrYr[�tagre�
_get_responseZwelcomerFrCr=�_get_capabilities�AllowedVersions�capabilities�PROTOCOL_VERSION)rQ�versionr;r;r<rM�s 




zIMAP4._connectcCs&|tkrt||���Std|��dS)NzUnknown IMAP4 command: '%s')�Commands�getattr�lower�AttributeError)rQ�attrr;r;r<�__getattr__	szIMAP4.__getattr__cCs|S)Nr;)rQr;r;r<�	__enter__szIMAP4.__enter__cGs&y|��Wntk
r YnXdS)N)�logoutrP)rQ�argsr;r;r<�__exit__szIMAP4.__exit__cCs |js
dn|j}t�||jf�S)N)rR�socketZcreate_connectionrS)rQrRr;r;r<�_create_socketszIMAP4._create_socketcCs(||_||_|��|_|j�d�|_dS)N�rb)rRrSru�sock�makefile�file)rQrRrSr;r;r<rL#s
z
IMAP4.opencCs|j�|�S)N)ry�read)rQ�sizer;r;r<rz/sz
IMAP4.readcCs.|j�td�}t|�tkr*|�dt��|S)N�zgot more than %d bytes)ry�readline�_MAXLINE�lenr=)rQ�liner;r;r<r}4szIMAP4.readlinecCs|j�|�dS)N)rwZsendall)rQ�datar;r;r<�send<sz
IMAP4.sendc
Cst|j��zXy|j�tj�Wn@tk
r^}z"|jtjkrNt	|dd�dkrN�Wdd}~XYnXWd|j��XdS)NZwinerrorri&')
ry�closerwrOrtZ	SHUT_RDWRrP�errnoZENOTCONNrk)rQ�excr;r;r<rOAs
zIMAP4.shutdowncCs|jS)N)rw)rQr;r;r<rtQszIMAP4.socketcCsBd}|�ddg|�\}}|dr(||fS|��\}}|�|||�S)NZRECENTr`���)�_untagged_response�noop)rQ�name�typ�datr;r;r<�recent]s	zIMAP4.recentcCs|�|dg|���S)N)r��upper)rQ�coder;r;r<�responsenszIMAP4.responsecCsxd}|sd}|r.|d|dfdkr2d|}nd}|r@t|�}nd}t�t|�}|jrbd|d}||_|�||||�S)	Nr�INBOXrr�)�(�)z(%s)sUTF8 (�))r�MapCRLF�sub�CRLFrVrD�_simple_command)rQ�mailbox�flags�	date_time�messager�rDr;r;r<�append|s

zIMAP4.appendcCsP|��}t|�j|_|�d|�\}}|dkrB|�|d�dd���d|_||fS)Nrr`r�zutf-8�replacer
)r��_Authenticator�processrDr�r=�decoderC)rQZ	mechanismZ
authobject�mechr�r�r;r;r<�authenticate�szIMAP4.authenticatecCs d}|�|�\}}|�|||�S)Nr)r�r�)rQr�r�r�r;r;r<�
capability�szIMAP4.capabilitycCs
|�d�S)Nr)r�)rQr;r;r<�check�szIMAP4.checkcCs$z|�d�\}}Wdd|_X||fS)Nrr
)r�rC)rQr�r�r;r;r<r��szIMAP4.closecCs|�d||�S)Nr)r�)rQ�message_setZnew_mailboxr;r;r<�copy�sz
IMAP4.copycCs|�d|�S)Nr)r�)rQr�r;r;r<�create�szIMAP4.createcCs|�d|�S)Nr)r�)rQr�r;r;r<�delete�szIMAP4.deletecCs|�d||�S)Nr)r�)rQr��whor;r;r<�	deleteacl�szIMAP4.deleteaclcCsHd|jkrt�d��|�d|�\}}|dkr@d|��kr@|��||fS)NrzServer does not support ENABLEr`zUTF8=ACCEPT)rgrr=r�r�r_)rQr�r�r�r;r;r<�enable�s

zIMAP4.enablecCs d}|�|�\}}|�|||�S)Nr)r�r�)rQr�r�r�r;r;r<�expunge�s	z
IMAP4.expungecCs$d}|�|||�\}}|�|||�S)Nr)r�r�)rQr�Z
message_partsr�r�r�r;r;r<�fetchs
zIMAP4.fetchcCs|�d|�\}}|�||d�S)NrZACL)r�r�)rQr�r�r�r;r;r<�getaclszIMAP4.getaclcCs"|�d|||�\}}|�||d�S)Nr�
ANNOTATION)r�r�)rQr��entryZ	attributer�r�r;r;r<�
getannotation#szIMAP4.getannotationcCs|�d|�\}}|�||d�S)Nr �QUOTA)r�r�)rQ�rootr�r�r;r;r<�getquota+szIMAP4.getquotacCs@|�d|�\}}|�||d�\}}|�||d�\}}|||gfS)Nr!r�Z	QUOTAROOT)r�r�)rQr�r�r�ZquotaZ	quotarootr;r;r<�getquotaroot6szIMAP4.getquotaroot�""�*cCs$d}|�|||�\}}|�|||�S)Nr#)r�r�)rQ�	directory�patternr�r�r�r;r;r<�listAsz
IMAP4.listcCs<|�d||�|��\}}|dkr.|�|d��d|_||fS)Nr$r`r�r
)r��_quoter=rC)rQ�user�passwordr�r�r;r;r<�loginMs
zIMAP4.logincCs|||_|_|�d|j�S)NzCRAM-MD5)r�r�r��_CRAM_MD5_AUTH)rQr�r�r;r;r<�login_cram_md5[szIMAP4.login_cram_md5cCsBddl}t|jt�r |j�d�n|j}|jd|�||d���S)Nrzutf-8� Zmd5)�hmac�
isinstancer��str�encoder�ZHMACZ	hexdigest)rQZ	challenger��pwdr;r;r<r�dszIMAP4._CRAM_MD5_AUTHcCsjd|_y|�d�\}}Wn(ddt��dd�g}}YnX|��d|jkrbd|jdfS||fS)Nr�NOz%s: %s��BYE)rCr��sys�exc_inforOrF)rQr�r�r;r;r<rqls"
zIMAP4.logoutcCs$d}|�|||�\}}|�|||�S)Nr%)r�r�)rQr�r�r�r�r�r;r;r<�lsub|sz
IMAP4.lsubcCs|�d|�\}}|�||d�S)Nr")r�r�)rQr�r�r�r;r;r<�myrights�szIMAP4.myrightscCs d}|�|�\}}|�|||�S)Nr&)r�r�)rQr�r�r�r;r;r<�	namespace�szIMAP4.namespacecCs
|�d�S)Nr')r�)rQr;r;r<r��sz
IMAP4.noopcCs(d}|�|||||�\}}|�||d�S)Nr(r)r�r�)rQZmessage_numZmessage_part�start�lengthr�r�r�r;r;r<�partial�sz
IMAP4.partialcCsd}|�d|�S)Nr))r�)rQr�r�r;r;r<�	proxyauth�s	zIMAP4.proxyauthcCs|�d||�S)Nr*)r�)rQZ
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)rVrr=r�r�)rQ�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,r`r
rz	READ-ONLYz%s is not writable�EXISTS)rFrHr�rCr?�get)rQr�r?r�r�r�r;r;r<�select�s
zIMAP4.selectcCs|�d|||�S)Nr-)r�)rQr�r�Zwhatr;r;r<�setacl�szIMAP4.setaclcGs |jd|��\}}|�||d�S)Nr.r�)r.)r�r�)rQrrr�r�r;r;r<�
setannotation�szIMAP4.setannotationcCs |�d||�\}}|�||d�S)Nr/r�)r�r�)rQr�Zlimitsr�r�r;r;r<�setquotaszIMAP4.setquotacGsFd}|d|dfdkr d|}|j|||f|��\}}|�|||�S)Nr0rr�)r�r�z(%s))r�r�)rQZ
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)
Nr1zSSL support missingzTLS session already establishedzTLS not supported by serverr`)�server_hostnamervTzCouldn't establish TLS session)�HAVE_SSLr=rJr>rg�ssl�_create_stdlib_contextr��wrap_socketrwrRrxryrer�)rQ�ssl_contextr�r�r�r;r;r<�starttlss$





zIMAP4.starttlscCs$d}|�|||�\}}|�|||�S)Nr2)r�r�)rQr��namesr�r�r�r;r;r<�status5szIMAP4.statuscCs>|d|dfdkrd|}|�d|||�\}}|�||d�S)Nrr�)r�r�z(%s)r3r)r�r�)rQr��commandr�r�r�r;r;r<�storeAszIMAP4.storecCs|�d|�S)Nr4)r�)rQr�r;r;r<�	subscribeLszIMAP4.subscribecGs*d}|j|||f|��\}}|�|||�S)Nr5)r�r�)rQZthreading_algorithmr�r�r�r�r�r;r;r<�threadTszIMAP4.threadc	Gs�|��}|tkr|�d|��|jt|krL|�d||jd�t|�f��d}|j||f|��\}}|dkrt|}nd}|�|||�S)NzUnknown IMAP4 UID command: %sz9command %s illegal in state %s, only allowed in states %sz, r6)r+r0r5r)r�rjr=rC�joinr�r�)rQr�rrr�r�r�r;r;r<�uid^sz	IMAP4.uidcCs|�d|�S)Nr7)r�)rQr�r;r;r<�unsubscribewszIMAP4.unsubscribecGs,|��}|tkr|jft|<|j|f|��S)N)r�rjrCr�)rQr�rrr;r;r<�xatoms
zIMAP4.xatomcCs8|dkrd}|j}||kr*||�|�n
|g||<dS)N�)rFr�)rQr�r��urr;r;r<�_append_untagged�szIMAP4._append_untaggedcCs,|j�d�}|r(|�|d�|jd���dS)Nr�r�r�)rFr�r>r�rW)rQZbyer;r;r<�
_check_bye�szIMAP4._check_byec

Gs�|jt|kr4d|_|�d||jd�t|�f��xdD]}||jkr:|j|=q:Wd|jkrn|jsn|�d��|��}t	||j
�}|d|}x8|D]0}|dkr�q�t|t�r�t	||j
�}|d|}q�W|j}|dk	�rd|_t
|�t
|j�kr�|}nd}|t	dt|�|j
�}y|�|t�Wn2tk
�rV}	z|�d|	��Wdd}	~	XYnX|dk�rf|Sx�x |���r�|j|�rj|S�qjW|�r�||j�}y|�|�|�t�Wn2tk
�r�}	z|�d|	��Wdd}	~	XYnX|�shP�qhW|S)	Nz9command %s illegal in state %s, only allowed in states %sz, )r`r��BADz	READ-ONLYz#mailbox status changed to READ-ONLY� z {%s}zsocket error: %s)rCrjrDr=r�rFrHr?�_new_tag�bytesrWr�r��type�_commandrr�r�rPr>rdrErG)
rQr�rrr��tagr��argrDZ	literator�valr;r;r<r��s^






 



 zIMAP4._commandc
Cs�|dkr|��y|�|�\}}Wnj|jk
rX}z|�d||f��Wdd}~XYn6|jk
r�}z|�d||f��Wdd}~XYnX|dkr�|��|dkr�|�d|||f��||fS)Nrzcommand: %s => %sr�z%s command error: %s %s)r��_get_tagged_responser>r=)rQr�r�r�r�r�r;r;r<�_command_complete�s"$zIMAP4._command_completecCsJ|��\}}|dgkr |�d��t|d|j�}|��}t|���|_dS)Nz"no CAPABILITY response from serverr�)r�r=r�rWr��tuple�splitrg)rQr�r�r;r;r<res

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|}xH|�|j
|��r\t|j�d	��}|�|�}|�|||f�|��}�qW|�||�|d
k�r�|�t|��r�|j�d�}t||j�}|�||j�d��|S)Nr�zunexpected tagged response: %rr�r�Zdata2zunexpected response: %rr�r�r{)r`r�r�)�	_get_line�_matchrc�mo�grouprEr>r�rW�Untagged_responser^�ContinuationrGr\�intrzr��
Response_code)rQ�respr�r�r�Zdat2r{r�r;r;r<rdsH



zIMAP4._get_responsec
Csdx^|j|}|dk	r |j|=|S|��y|��Wq|jk
rZ}z�Wdd}~XYqXqWdS)N)rEr�rdr>)rQr��resultr�r;r;r<r�`s
zIMAP4._get_tagged_responsecCs>|��}|s|�d��|�d�s.|�d|��|dd�}|S)Nzsocket error: EOFs
z#socket error: unterminated line: %r���)r}r>�endswith)rQr�r;r;r<r{s

zIMAP4._get_linecCs|�|�|_|jdk	S)N)�matchr)rQZcre�sr;r;r<r�szIMAP4._matchcCs2|jtt|j�|j�}|jd|_d|j|<|S)Nr|)rbr�r�rIrWrE)rQr�r;r;r<r��s
zIMAP4._new_tagcCs$|�dd�}|�dd�}d|dS)N�\z\\�"z\")r�)rQr�r;r;r<r��szIMAP4._quotecGs|�||j|f|���S)N)r�r�)rQr�rrr;r;r<r��szIMAP4._simple_commandcCs8|dkr||fS||jkr$|dgfS|j�|�}||fS)Nr�)rF�pop)rQr�r�r�r�r;r;r<r��s

zIMAP4._untagged_response)r�r�)r�r�)r�F)N)Or8r9r:rNr=r>r?�
IMAP4_PORTrTrKr_rMrorprsrurLrzr}r�rOrtr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�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�r�r�rerdr�rrr�r�r�r�r;r;r;r<r�s�.*
		
	



 	

M	Pc@s6eZdZdedddfdd�Zdd�Zdefdd�ZdS)	�	IMAP4_SSLr@NcCs�|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 insteadr�)�certfile�keyfile)�
ValueError�warnings�warn�DeprecationWarningrrr�r�r�rrT)rQrRrSrrr�rr;r;r<rT�szIMAP4_SSL.__init__cCst�|�}|jj||jd�S)N)r�)rrur�r�rR)rQrwr;r;r<ru
s
zIMAP4_SSL._create_socketcCst�|||�dS)N)rrL)rQrRrSr;r;r<rLszIMAP4_SSL.open)r8r9r:�IMAP4_SSL_PORTrTrurLr;r;r;r<r�src@s>eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rcCs||_t�|�dS)N)r�rrT)rQr�r;r;r<rT&szIMAP4_stream.__init__NcCsNd|_d|_d|_d|_tj|jttjtjddd�|_	|j	j
|_|j	j|_
dS)NT)�bufsize�stdin�stdout�shellZ	close_fds)rRrSrwry�
subprocess�Popenr�r�PIPEr�r�	writefiler�readfile)rQrRrSr;r;r<rL+s
zIMAP4_stream.opencCs|j�|�S)N)r#rz)rQr{r;r;r<rz;szIMAP4_stream.readcCs
|j��S)N)r#r})rQr;r;r<r}@szIMAP4_stream.readlinecCs|j�|�|j��dS)N)r"�write�flush)rQr�r;r;r<r�EszIMAP4_stream.sendcCs"|j��|j��|j��dS)N)r#r�r"r��wait)rQr;r;r<rOKs

zIMAP4_stream.shutdown)NN)	r8r9r:rTrLrzr}r�rOr;r;r;r<rs
c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs
||_dS)N)r�)rQZmechinstr;r;r<rTYsz_Authenticator.__init__cCs&|�|�|��}|dkrdS|�|�S)N�*)r�r�r�)rQr��retr;r;r<r�\sz_Authenticator.processcCsrd}t|t�r|�d�}xT|rlt|�dkrD|dd�}|dd�}n|}d}t�|�}|r||dd�}qW|S)Nr�zutf-8�0r�)r�r�r�r�binasciiZ
b2a_base64)rQ�inpZoup�t�er;r;r<r�bs	


z_Authenticator.encodecCs|sdSt�|�S)Nr�)r*Z
a2b_base64)rQr+r;r;r<r�zsz_Authenticator.decodeN)r8r9r:rTr�r�r�r;r;r;r<r�Ssr�z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr�cCsi|]\}}|d|���qS)r|)r�)�.0�nrr;r;r<�
<dictcomp>�sr0r|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	rr1r2r3r4r5r6r7r8r9Zzone�tt�utcr;r;r<r�s$

cCsDd}d}tt|��}x*|r>t|d�\}}|||d�|}qW|S)Nr�sABCDEFGHIJKLMNOP�r|)r�abs�divmod)Znumr�ZAP�modr;r;r<r	�scCs$t�|�}|sdSt|�d����S)Nr;r�)�Flagsr
r�rr)r	rr;r;r<r
�s
cCst|ttf�r"t�|tj���}n�t|t�r�y
|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)rrzdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")r�r�floatrZ
fromtimestamprrBZ
astimezoner�Z	tm_gmtoffrmr?Zdaylightr@ZmktimeZaltzonerrJrr��format�MonthsZmonthZstrftime)r�ZdtZgmtoff�dstZdeltaZfmtr;r;r<r�s0




�__main__zd:s:)r;r;z-dz-s)r@zIMAP password for %s on %s: Z	localhostzJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s�
)r�Zlfr�)r�)z
/tmp/xxx 1)r�)z
/tmp/xxx 1z/tmp/yyy)r)z
/tmp/yyz 2r�z
/tmp/yyz 2)r�)z/tmpzyy*)r�)z
/tmp/yyz 2)r�)NZSUBJECTZtest)r�)�1z(FLAGS INTERNALDATE RFC822))r�)rQ�FLAGSz
(\Deleted))r�r;)r�r;)r�r;)r�r;)r�r;)r�)ZUIDVALIDITY)r�)r+ZALL)r�)r�)rqr;cCsLt�d||f�tt|�|�\}}t�d|||f�|dkrH|d�|S)Nz%s %sz%s => %s %sr�r)�M�_mesgrk)�cmdrrr�r�r;r;r<�runsrVr
zPROTOCOL_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
)T�__version__r*r�rarXrtrr�r?r>rrr�iorr�r��ImportError�__all__r�rArrrfr~rjrYrrGr<r[r\r�rrr^rZr]rrr�rr�rrM�	enumerater=rr	r
rr8ZgetoptZgetpass�argvZoptlistrrr=r�Zstream_command�optrrRZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2rVrSrCrTrhrgrU�mlr
rr�pathr�r��printr;r;r;r<�<module>sDH

	



	


c4
9,
#
)