AlkantarClanX12

Your IP : 18.225.175.230


Current Path : /proc/self/root/lib64/python3.6/__pycache__/
Upload File :
Current File : //proc/self/root/lib64/python3.6/__pycache__/imaplib.cpython-36.opt-2.pyc

3


 \/��2@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
mZmZddl
mZyddlZdZWnek
r�dZYnXddd	d
ddgZd
ZdZdZdZdfZdZdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�d�)Zejd�Zejd�Zejd�Zejdej�Zejd�Z ejd�Z!ejd�Z"ejdej�Z#dZ$dZ%Gdd�d�Z&e�r�Gd d!�d!e&�Z'ej(d!�Gd"d�de&�Z)Gd#d$�d$�Z*d%j+d&�Z,d'd(�e-e,d)d��D�Z.d*d	�Z/d+d
�Z0d,d�Z1d-d�Z2e3d.k�r�ddl4Z4ddl5Z5ye4j4ej6d)d�d/�\Z7Z8Wn0e4j9k
�rnZ:zffZ7Z8WYddZ:[:XnXdZ;x@e7D]8\Z<Z:e<d0k�r�e=e:�Zne<d1k�rze:Z;e8�sze;fZ8�qzWe8�s�d�Z8e8dZ>e5j?�Z@e5j5d3e@e>�p�d4f�ZAd5e@d6d7�ZBd8e@eAffd�d�d�d?d>ddeBffd�d�d�d�d�dMffdNffdOffdPfffZCdCffd�d�d�d?dddeBffdOffdWfffZDdXdY�ZE�y&e;�r�e)e;�ZFne&e>�ZFeFjGdk�r�eCd)d�ZCeFjHdZeFjI�eFjHd[eFjJf�xeCD]\ZKZ8eEeKe8��q�WxJeEd@d��D]<ZLejMd^eL�ZNeN�reNjOd)�ZPneLj+�d�ZPeEd_ePf��q�Wx\eDD]T\ZKZ8eEeKe8�ZQeKe8fd�k�rV�q2eQd�j+�ZReR�sl�q2eEdSd`daeRd�dbf��q2WeSdc�Wn.eSdd�e�s�eSdeej6d��YnXdS)�z2.58�N)�datetime�timezone�	timedelta)�DEFAULT_BUFFER_SIZETF�IMAP4�IMAP4_stream�Internaldate2tuple�Int2AP�
ParseFlags�Time2Internaldates
�i��	IMAP4REV1i@B�AUTH�SELECTED�NONAUTH�LOGOUT))�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<�/usr/lib64/python3.6/imaplib.py�error�sr>c@seZdZdS)zIMAP4.abortN)r9r:r;r<r<r<r=�abort�sr?c@seZdZdS)zIMAP4.readonlyN)r9r:r;r<r<r<r=�readonly�sr@�cCs�t|_d|_d|_i|_i|_d|_d|_d|_d|_	|j
�|j||�y|j�Wn8t
k
r�y|j�Wntk
r�YnX�YnXdS)NrrAFr)�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|_tjttj�|_tjttj�|_dS)NF�ascii)	�utf8_enabled�	_encoding�re�compile�_Literal�ASCII�Literal�_Untagged_status�Untagged_status)rRr<r<r=rL�szIMAP4._mode_asciicCs(d|_d|_tjt�|_tjt�|_dS)NTzutf-8)rWrXrYrZr[r]r^r_)rRr<r<r=�
_mode_utf8�szIMAP4._mode_utf8cCs�ttjdd��|_tjd|jdtj�|_|j�|_	d|j
krHd|_nd|j
krZd|_n|j|j	��|j
�x tD]}||jkr�qt||_dSW|jd	��dS)
Nii��s(?P<tag>s"\d+) (?P<type>[A-Z]+) (?P<data>.*)ZPREAUTHr�OKrzserver not IMAP4 compliant)r	�randomZrandint�tagprerYrZr\�tagre�
_get_responseZwelcomerGrDr>�_get_capabilities�AllowedVersions�capabilities�PROTOCOL_VERSION)rR�versionr<r<r=rN�s 




zIMAP4._connectcCs&|tkrt||j��Std|��dS)NzUnknown IMAP4 command: '%s')�Commands�getattr�lower�AttributeError)rR�attrr<r<r=�__getattr__	szIMAP4.__getattr__cCs|S)Nr<)rRr<r<r=�	__enter__szIMAP4.__enter__cGs&y|j�Wntk
r YnXdS)N)�logoutrQ)rR�argsr<r<r=�__exit__szIMAP4.__exit__cCs |js
dn|j}tj||jf�S)N)rS�socketZcreate_connectionrT)rRrSr<r<r=�_create_socketszIMAP4._create_socketcCs(||_||_|j�|_|jjd�|_dS)N�rb)rSrTrv�sock�makefile�file)rRrSrTr<r<r=rM#s
z
IMAP4.opencCs|jj|�S)N)rz�read)rR�sizer<r<r=r{/sz
IMAP4.readcCs.|jjtd�}t|�tkr*|jdt��|S)N�zgot more than %d bytes)rz�readline�_MAXLINE�lenr>)rR�liner<r<r=r~4szIMAP4.readlinecCs|jj|�dS)N)rxZsendall)rR�datar<r<r=�send<sz
IMAP4.sendcCst|jj�zXy|jjtj�Wn@tk
r^}z$|jtjkrNt	|dd�dkrN�WYdd}~XnXWd|jj�XdS)NZwinerrorri&')
rz�closerxrPruZ	SHUT_RDWRrQ�errnoZENOTCONNrl)rR�excr<r<r=rPAs
zIMAP4.shutdowncCs|jS)N)rx)rRr<r<r=ruQszIMAP4.socketcCsBd}|jddg|�\}}|dr(||fS|j�\}}|j|||�S)NZRECENTrar}���)�_untagged_response�noop)rR�name�typ�datr<r<r=�recent]s	zIMAP4.recentcCs|j|dg|j��S)N)r��upper)rR�coder<r<r=�responsenszIMAP4.responsecCsxd}|sd}|r.|d|d
fdkr2d|}nd}|r@t|�}nd}tjt|�}|jrbd|d	}||_|j||||�S)Nr�INBOXrr}�(�)z(%s)sUTF8 (�)r�)r�r�)r�MapCRLF�sub�CRLFrWrE�_simple_command)rR�mailbox�flags�	date_time�messager�rEr<r<r=�append|s

zIMAP4.appendcCsP|j�}t|�j|_|jd|�\}}|dkrB|j|djdd���d|_||fS)Nrrar}zutf-8�replacerr�)r��_Authenticator�processrEr�r>�decoderD)rRZ	mechanismZ
authobject�mechr�r�r<r<r=�authenticate�szIMAP4.authenticatecCs d}|j|�\}}|j|||�S)Nr)r�r�)rRr�r�r�r<r<r=�
capability�szIMAP4.capabilitycCs
|jd�S)Nr)r�)rRr<r<r=�check�szIMAP4.checkcCs$z|jd�\}}Wdd|_X||fS)Nrr)r�rD)rRr�r�r<r<r=r��szIMAP4.closecCs|jd||�S)Nr)r�)rR�message_setZnew_mailboxr<r<r=�copy�sz
IMAP4.copycCs|jd|�S)Nr)r�)rRr�r<r<r=�create�szIMAP4.createcCs|jd|�S)Nr)r�)rRr�r<r<r=�delete�szIMAP4.deletecCs|jd||�S)Nr)r�)rRr��whor<r<r=�	deleteacl�szIMAP4.deleteaclcCsHd|jkrtjd��|jd|�\}}|dkr@d|j�kr@|j�||fS)NrzServer does not support ENABLErazUTF8=ACCEPT)rhrr>r�r�r`)rRr�r�r�r<r<r=�enable�s

zIMAP4.enablecCs d}|j|�\}}|j|||�S)Nr)r�r�)rRr�r�r�r<r<r=�expunge�s	z
IMAP4.expungecCs$d}|j|||�\}}|j|||�S)Nr)r�r�)rRr�Z
message_partsr�r�r�r<r<r=�fetchs
zIMAP4.fetchcCs|jd|�\}}|j||d�S)NrZACL)r�r�)rRr�r�r�r<r<r=�getaclszIMAP4.getaclcCs"|jd|||�\}}|j||d�S)Nr �
ANNOTATION)r�r�)rRr��entryZ	attributer�r�r<r<r=�
getannotation#szIMAP4.getannotationcCs|jd|�\}}|j||d�S)Nr!�QUOTA)r�r�)rR�rootr�r�r<r<r=�getquota+szIMAP4.getquotacCs@|jd|�\}}|j||d�\}}|j||d�\}}|||gfS)Nr"r�Z	QUOTAROOT)r�r�)rRr�r�r�ZquotaZ	quotarootr<r<r=�getquotaroot6szIMAP4.getquotaroot�""�*cCs$d}|j|||�\}}|j|||�S)Nr$)r�r�)rR�	directory�patternr�r�r�r<r<r=�listAsz
IMAP4.listcCs<|jd||j|��\}}|dkr.|j|d��d|_||fS)Nr%rar}rr�)r��_quoter>rD)rR�user�passwordr�r�r<r<r=�loginMs
zIMAP4.logincCs|||_|_|jd|j�S)NzCRAM-MD5)r�r�r��_CRAM_MD5_AUTH)rRr�r�r<r<r=�login_cram_md5[szIMAP4.login_cram_md5cCsBddl}t|jt�r |jjd�n|j}|jd|j||d�j�S)Nrzutf-8� Zmd5)�hmac�
isinstancer��str�encoder�ZHMACZ	hexdigest)rRZ	challenger��pwdr<r<r=r�dszIMAP4._CRAM_MD5_AUTHcCsjd|_y|jd�\}}Wn(ddtj�dd�g}}YnX|j�d|jkrbd|jdfS||fS)Nr�NOz%s: %s��BYE)rDr��sys�exc_inforPrG)rRr�r�r<r<r=rrls"
zIMAP4.logoutcCs$d}|j|||�\}}|j|||�S)Nr&)r�r�)rRr�r�r�r�r�r<r<r=�lsub|sz
IMAP4.lsubcCs|jd|�\}}|j||d�S)Nr#)r�r�)rRr�r�r�r<r<r=�myrights�szIMAP4.myrightscCs d}|j|�\}}|j|||�S)Nr')r�r�)rRr�r�r�r<r<r=�	namespace�szIMAP4.namespacecCs
|jd�S)Nr()r�)rRr<r<r=r��sz
IMAP4.noopcCs(d}|j|||||�\}}|j||d�S)Nr)r)r�r�)rRZmessage_numZmessage_part�startZlengthr�r�r�r<r<r=�partial�sz
IMAP4.partialcCsd}|jd|�S)Nr*)r�)rRr�r�r<r<r=�	proxyauth�s	zIMAP4.proxyauthcCs|jd||�S)Nr+)r�)rRZ
oldmailboxZ
newmailboxr<r<r=�rename�szIMAP4.renamecGsTd}|r2|jrtjd��|j|d|f|��\}}n|j|f|��\}}|j|||�S)Nr,z'Non-None charset not valid in UTF8 mode�CHARSET)rWrr>r�r�)rR�charsetZcriteriar�r�r�r<r<r=�search�s
zIMAP4.searchr�FcCsxi|_||_|rd}nd}|j||�\}}|dkr@d|_||fSd|_d|jkrd|rd|jd|��||jjddg�fS)	Nrr-rarrz	READ-ONLYz%s is not writable�EXISTS)rGrIr�rDr@�get)rRr�r@r�r�r�r<r<r=�select�s
zIMAP4.selectcCs|jd|||�S)Nr.)r�)rRr�r�Zwhatr<r<r=�setacl�szIMAP4.setaclcGs |jd|��\}}|j||d�S)Nr/r�)r/)r�r�)rRrsr�r�r<r<r=�
setannotation�szIMAP4.setannotationcCs |jd||�\}}|j||d�S)Nr0r�)r�r�)rRr�Zlimitsr�r�r<r<r=�setquotaszIMAP4.setquotacGsFd}|d|dfdkr d|}|j|||f|��\}}|j|||�S)	Nr1rr}r�r�z(%s)r�)r�r�)r�r�)rRZ
sort_criteriar��search_criteriar�r�r�r<r<r=�sorts
z
IMAP4.sortNcCs�d}ts|jd��|jr"|jd��||jkr6|jd��|dkrFtj�}|j|�\}}|dkr�|j|j	|j
d�|_	|j	jd�|_d|_|j
�n
|jd	��|j|||�S)
Nr2zSSL support missingzTLS session already establishedzTLS not supported by serverra)�server_hostnamerwTzCouldn't establish TLS session)�HAVE_SSLr>rKr?rh�ssl�_create_stdlib_contextr��wrap_socketrxrSryrzrfr�)rR�ssl_contextr�r�r�r<r<r=�starttlss$





zIMAP4.starttlscCs$d}|j|||�\}}|j|||�S)Nr3)r�r�)rRr��namesr�r�r�r<r<r=�status5szIMAP4.statuscCs>|d|dfd	krd|}|jd|||�\}}|j||d�S)
Nrr}r�r�z(%s)r4rr�)r�r�)r�r�)rRr��commandr�r�r�r<r<r=�storeAszIMAP4.storecCs|jd|�S)Nr5)r�)rRr�r<r<r=�	subscribeLszIMAP4.subscribecGs*d}|j|||f|��\}}|j|||�S)Nr6)r�r�)rRZthreading_algorithmr�r�r�r�r�r<r<r=�threadTszIMAP4.threadcGs�|j�}|tkr|jd|��|jt|krL|jd||jdjt|�f��d}|j||f|��\}}|d	krt|}nd}|j|||�S)
NzUnknown IMAP4 UID command: %sz9command %s illegal in state %s, only allowed in states %sz, r7r,r1r6r)r,r1r6)r�rkr>rD�joinr�r�)rRr�rsr�r�r�r<r<r=�uid^sz	IMAP4.uidcCs|jd|�S)Nr8)r�)rRr�r<r<r=�unsubscribewszIMAP4.unsubscribecGs,|j�}|tkr|jft|<|j|f|��S)N)r�rkrDr�)rRr�rsr<r<r=�xatoms
zIMAP4.xatomcCs8|dkrd}|j}||kr*||j|�n
|g||<dS)N�)rGr�)rRr�r�Zurr<r<r=�_append_untagged�szIMAP4._append_untaggedcCs,|jjd�}|r(|j|dj|jd���dS)Nr�r}r�r�)rGr�r?r�rX)rRZbyer<r<r=�
_check_bye�szIMAP4._check_byec
Gs�|jt|kr4d|_|jd||jdjt|�f��xdD]}||jkr:|j|=q:Wd|jkrp|jrp|jd��|j�}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	d	t|�|j
�}y|j|t�Wn2tk
�rX}	z|jd
|	��WYdd}	~	XnX|dk�rh|Sx�x |j��r�|j|�rl|S�qlW|�r�||j�}y|j|�|jt�Wn2tk
�r�}	z|jd
|	��WYdd}	~	XnX|�sjP�qjW|S)Nz9command %s illegal in state %s, only allowed in states %sz, rar��BADz	READ-ONLYz#mailbox status changed to READ-ONLY� z {%s}zsocket error: %s)rar�r�)rDrkrEr>r�rGrIr@�_new_tag�bytesrXr�r��type�_commandr�r�r�rQr?rerFrH)
rRr�rsr��tagr��argrEZ	literator�valr<r<r=r��s^






 



 zIMAP4._commandcCs�|dkr|j�y|j|�\}}Wnj|jk
rX}z|jd||f��WYdd}~Xn6|jk
r�}z|jd||f��WYdd}~XnX|dkr�|j�|dkr�|jd|||f��||fS)Nrzcommand: %s => %sr�z%s command error: %s %s)r��_get_tagged_responser?r>)rRr�r�r�r�r�r<r<r=�_command_complete�s"$zIMAP4._command_completecCsJ|j�\}}|dgkr |jd��t|d|j�}|j�}t|j��|_dS)Nz"no CAPABILITY response from serverr}r�)r�r>r�rXr��tuple�splitrh)rRr�r�r<r<r=rfs

zIMAP4._get_capabilitiescCs�|j�}|j|j|�rp|jjd�}||jkr:|jd|��|jjd�}t||j�}|jjd�}||gf|j|<n�d}|jt	|�s�|j|j
|�r�|jjd�}|jdkr�|jt|�r�|jjd�|_dS|jd|��|jjd�}t||j�}|jjd�}|dk�rd}|�r|d|}xH|j|j
|��r\t|jjd	��}|j|�}|j|||f�|j�}�qW|j||�|d
k�r�|jt|��r�|jjd�}t||j�}|j||jjd��|S)Nr�zunexpected tagged response: %rr�r�Zdata2zunexpected response: %rr�r�r|rar�r�)rar�r�)�	_get_line�_matchrd�mo�grouprFr?r�rX�Untagged_responser_�ContinuationrHr]�intr{r��
Response_code)rR�respr�r�r�Zdat2r|r�r<r<r=resH



zIMAP4._get_responsecCsdx^|j|}|dk	r |j|=|S|j�y|j�Wq|jk
rZ}z�WYdd}~XqXqWdS)N)rFr�rer?)rRr��resultr�r<r<r=r�`s
zIMAP4._get_tagged_responsecCs>|j�}|s|jd��|jd�s.|jd|��|dd�}|S)Nzsocket error: EOFs
z#socket error: unterminated line: %rr����)r~r?�endswith)rRr�r<r<r=r{s

zIMAP4._get_linecCs|j|�|_|jdk	S)N)�matchr)rRZcre�sr<r<r=r�szIMAP4._matchcCs2|jtt|j�|j�}|jd|_d|j|<|S)Nr})rcr�r�rJrXrF)rRr�r<r<r=r��s
zIMAP4._new_tagcCs$|jdd�}|jdd�}d|dS)N�\z\\�"z\")r�)rRr�r<r<r=r��szIMAP4._quotecGs|j||j|f|���S)N)r�r�)rRr�rsr<r<r=r��szIMAP4._simple_commandcCs8|dkr||fS||jkr$|dgfS|jj|�}||fS)Nr�)rG�pop)rRr�r�r�r�r<r<r=r��s

zIMAP4._untagged_response)r�r�)r�r�)r�F)N)Or9r:r;rOr>r?r@�
IMAP4_PORTrUrLr`rNrprqrtrvrMr{r~r�rPrur�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rfrer�rrr�r�r�r�r<r<r<r=r�s�.*
		
	



 	

M	Pc@s6eZdZdedddfdd�Zdd�Zdefdd�ZdS)	�	IMAP4_SSLrANcCs�|dk	r|dk	rtd��|dk	r0|dk	r0td��|dk	s@|dk	rVddl}|jdtd�||_||_|dkrxtj||d�}||_t	j
|||�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�rrU)rRrSrTrrr�rr<r<r=rU�szIMAP4_SSL.__init__cCstj|�}|jj||jd�S)N)r�)rrvr�r�rS)rRrxr<r<r=rv
s
zIMAP4_SSL._create_socketcCstj|||�dS)N)rrM)rRrSrTr<r<r=rMszIMAP4_SSL.open)r9r:r;�IMAP4_SSL_PORTrUrvrMr<r<r<r=r�src@s>eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rcCs||_tj|�dS)N)r�rrU)rRr�r<r<r=rU&szIMAP4_stream.__init__NcCsNd|_d|_d|_d|_tj|jttjtjddd�|_	|j	j
|_|j	j|_
dS)NT)�bufsize�stdin�stdout�shellZ	close_fds)rSrTrxrz�
subprocess�Popenr�r�PIPEr�r�	writefiler�readfile)rRrSrTr<r<r=rM+s
zIMAP4_stream.opencCs|jj|�S)N)r"r{)rRr|r<r<r=r{;szIMAP4_stream.readcCs
|jj�S)N)r"r~)rRr<r<r=r~@szIMAP4_stream.readlinecCs|jj|�|jj�dS)N)r!�write�flush)rRr�r<r<r=r�EszIMAP4_stream.sendcCs"|jj�|jj�|jj�dS)N)r"r�r!r��wait)rRr<r<r=rPKs

zIMAP4_stream.shutdown)NN)	r9r:r;rUrMr{r~r�rPr<r<r<r=rs
c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs
||_dS)N)r�)rRZmechinstr<r<r=rUYsz_Authenticator.__init__cCs&|j|j|��}|dkrdS|j|�S)N�*)r�r�r�)rRr�Zretr<r<r=r�\sz_Authenticator.processcCsrd}t|t�r|jd�}xT|rlt|�dkrD|dd�}|dd�}n|}d}tj|�}|r||dd�}qW|S)Nr�zutf-8�0r}r�)r�r�r�r��binasciiZ
b2a_base64)rR�inpZoup�t�er<r<r=r�bs	


z_Authenticator.encodecCs|sdStj|�S)Nr�)r(Z
a2b_base64)rRr)r<r<r=r�zsz_Authenticator.decodeN)r9r:r;rUr�r�r�r<r<r<r=r�Ssr�z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr�cCsi|]\}}|d|j��qS)r})r�)�.0�nr
r<r<r=�
<dictcomp>�sr.r}c	Cs�tj|�}|sdSt|jd�}|jd�}t|jd��}t|jd��}t|jd��}t|jd��}t|jd��}t|jd��}	t|jd	��}
|	d
|
d
}|dkr�|}||||||d
ddf	}tj|�|}
tj|
�S)N�mon�zonen�day�year�hour�min�sec�zoneh�zonem�<�-r}r�r�r�)	�InternalDater�Mon2numrr�calendarZtimegm�time�	localtime)rrr/r0r1r2r3r4r5r6r7ZzoneZtt�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$tj|�}|sfSt|jd�j��S)Nr�)�Flagsrr�rr�)rrr<r<r=r
�s
c
Cs t|ttf�r"tj|tj�j�}n�t|t�r�y
|j	}WnZt
k
r�tjr�|d}|dkrptj
tj|��d}tjtjf|}ntj}YnXt|d�}t|dd�dt|�i�}nNt|t�r�|jdkr�td��|}n,t|t�o�|d|dfd
k�r�|Std	��d
jt|j�}|j|�S)N�r})Zseconds��tzinfozdate_time must be awarerrzdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z"r�r�)rr)r�r�floatrZ
fromtimestamprr?Z
astimezoner�Z	tm_gmtoffrnr=Zdaylightr>ZmktimeZaltzonerrGrr��format�MonthsZmonthZstrftime)r�ZdtZgmtoff�dstZdeltaZfmtr<r<r=r�s0




 �__main__zd:s:z-dz-srAzIMAP 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 1r��/tmp/yyyr�
/tmp/yyz 2r�r��/tmp�yy*r�r��SUBJECT�testr��1�(FLAGS INTERNALDATE RFC822)r��FLAGS�
(\Deleted)r�r�r�r�r��UIDVALIDITYr�r,�ALLr�rrcCsLtjd||f�tt|�|�\}}tjd|||f�|dkrH|d�|S)Nz%s %sz%s => %s %sr�r)�M�_mesgrl)�cmdrsr�r�r<r<r=�runsr^zPROTOCOL_VERSION = %szCAPABILITIES = %r�/tmp/�yy%z.*"([^"]+)"$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
)r
r)rr)r)rrrr)r)r)r)rr)rr)rr)r)rr)r)r)rr)rr)rr)rr)rr)rr)r)rrrr)rr)r)rr)rrrr)r)r)rr)r)rr)rr)rr)rr)r)r)rr)r)rr)r)r)rr)rA�rN)r�ra�rNrO)r�rb�rP)rrc�rQrR)r�rd�rP)r�re�NrSrT)r�rf�rUrV)r�rg�rUrWrX)r�rh�rY)r�ri�r,rZ)r�rj�r�)r�rk)r_r`r��r,rZ)r�rlr�r�)T�__version__r(r�rbrYrurr�r=r<rrr�iorr�r��ImportError�__all__r�rBrrrgrrkrZrrDr:r\r]r�rrr_r[r^rrr�rr�r�rJ�	enumerater;rr	r
rr9ZgetoptZgetpass�argvZoptlistrsr>r�Zstream_command�optrrSZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2r^r[rDr\rirhr]Zmlrrr�pathr�r��printr<r<r<r=�<module>sDH

	



	


c4
9,
#
)