Your IP : 3.142.195.79


Current Path : /opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/__pycache__/imaplib.cpython-35.opt-2.pyc



���]���Y@s\dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
mZmZddl
mZyddlZdZWnek
r�dZYnXddd	d
ddgZd
ZdZdZdZddfZdZdddfddfdddddfddfddfddfdddfdddfdddfddfd ddfd!dfd"dfd#ddfd$ddfd%ddfd&ddfd'ddfd(ddfd)dfdddddfd*ddfd+ddfd,ddddfd-dfd.dfd/ddfd0dfd1ddfd2ddfd3ddfd4ddfd5dfd6dfd7ddfd8dfd9ddfd:dfd;dfd<ddfi(Zejd=�Zejd>�Zejd?�Zejd@ej�ZejdA�Z ejdB�Z!ejdC�Z"ejdDej�Z#d@Z$dDZ%GdEd�d�Z&er�GdFdG�dGe&�Z'ej(dG�GdHd�de&�Z)GdIdJ�dJ�Z*dKj+dL�Z,dMdN�e-e,dOd��D�Z.dPd	�Z/dQd
�Z0dRd�Z1dSd�Z2e3dTkrXddl4Z4ddl5Z5y)e4j4ej6dOd�dU�\Z7Z8Wn:e4j9k
r�Z:zfff\Z7Z8WYddZ:[:XnXdZ;xQe7D]I\Z<Z:e<dVkr�e=e:�Zn"e<dWkre:Z;e8re;fZ8q�We8r$dXfZ8e8dZ>e5j?�Z@e5j5dYe@e>pOdZf�ZAd[d\e@d]d^iZBd_e@eAffd`daffdbdadcffdddffdeddddeBffdfdgdhffdiddffdjddkdlffdmdndoffdpdndqdrffdsffdtffduffdvfffZCdiffdwdxffdyd0dzffdwd{ffdedddeBffduffd|fffZDd}d~�ZEy�e;r�e)e;�ZFne&e>�ZFeFjGdkr�eCdOd�ZCeFjHdeFjI�eFjHd�eFjJf�x!eCD]\ZKZ8eEeKe8�qWxheEdfd�d�f�D]QZLejMd�eL�ZNeNrseNjOdO�ZPneLj+�dOZPeEd�ePf�qCWx~eDD]v\ZKZ8eEeKe8�ZQeKe8fdyd0dzffkr�q�eQdOj+�ZReRr�q�eEdyd"d�eRdOd�f�q�WeSd��Wn1eSd��erPeSd�ej6d��YnXdS)�z2.58�N)�datetime�timezone�	timedelta)�DEFAULT_BUFFER_SIZETF�IMAP4�IMAP4_stream�Internaldate2tuple�Int2AP�
ParseFlags�Time2Internaldates
�i�Z	IMAP4REV1i@B�APPEND�AUTH�SELECTED�AUTHENTICATE�NONAUTH�
CAPABILITY�LOGOUT�CHECK�CLOSE�COPY�CREATE�DELETE�	DELETEACL�ENABLE�EXAMINE�EXPUNGE�FETCH�GETACL�
GETANNOTATION�GETQUOTA�GETQUOTAROOT�MYRIGHTS�LIST�LOGIN�LSUB�	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�Zdedd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdedd�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'dHdIdJdK�Z(dLdM�Z)dNdO�Z*dPdQ�Z+dRdS�Z,dHdIdTdU�Z-dVdW�Z.dXdY�Z/dZd[�Z0d\d]�Z1d^d_�Z2d`da�Z3dbdc�Z4dddedfdg�Z5dhdi�Z6djdk�Z7dldm�Z8dndo�Z9dpdqdr�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@seZdZdS)zIMAP4.errorN)�__name__�
__module__�__qualname__�r;r;�,/opt/alt/python35/lib64/python3.5/imaplib.py�error�sr=c@seZdZdS)zIMAP4.abortN)r8r9r:r;r;r;r<�abort�sr>c@seZdZdS)zIMAP4.readonlyN)r8r9r:r;r;r;r<�readonly�sr?�cCs�t|_d|_d|_i|_i|_d|_d|_d|_d|_	|j
�|j||�y|j�Wn8t
k
r�y|j�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__cCsFd|_d|_tjttj�|_tjttj�|_dS)NF�ascii)	�utf8_enabled�	_encoding�re�compile�_Literal�ASCII�Literal�_Untagged_status�Untagged_status)rQr;r;r<rK�s		zIMAP4._mode_asciicCs:d|_d|_tjt�|_tjt�|_dS)NTzutf-8)rVrWrXrYrZr\r]r^)rQr;r;r<�
_mode_utf8�s		zIMAP4._mode_utf8cCs�ttjdd��|_tjd|jdtj�|_|j�|_	d|j
krhd|_n-d|j
kr�d|_n|j|j	��|j
�x*tD]"}||jkr�q�||_dSW|jd	��dS)
Nii��s(?P<tag>s"\d+) (?P<type>[A-Z]+) (?P<data>.*)ZPREAUTHr�OKrzserver not IMAP4 compliant)r	�random�randint�tagprerXrYr[�tagre�
_get_responseZwelcomerFrCr=�_get_capabilities�AllowedVersions�capabilities�PROTOCOL_VERSION)rQ�versionr;r;r<rM�s 


	zIMAP4._connectcCs3|tkrt||j��Std|��dS)NzUnknown IMAP4 command: '%s')�Commands�getattr�lower�AttributeError)rQ�attrr;r;r<�__getattr__szIMAP4.__getattr__cCs|S)Nr;)rQr;r;r<�	__enter__szIMAP4.__enter__cGs'y|j�Wntk
r"YnXdS)N)�logoutrP)rQ�argsr;r;r<�__exit__	s
zIMAP4.__exit__cCstj|j|jf�S)N)�socket�create_connectionrRrS)rQr;r;r<�_create_socketszIMAP4._create_socketcCs:||_||_|j�|_|jjd�|_dS)N�rb)rRrSrw�sock�makefile�file)rQrRrSr;r;r<rLs		z
IMAP4.opencCs|jj|�S)N)r{�read)rQ�sizer;r;r<r|"sz
IMAP4.readcCs?|jjtd�}t|�tkr;|jdt��|S)N�zgot more than %d bytes)r{�readline�_MAXLINE�lenr=)rQ�liner;r;r<r'szIMAP4.readlinecCs|jj|�dS)N)ry�sendall)rQ�datar;r;r<�send/sz
IMAP4.sendcCs�|jj�zpy|jjtj�WnRtk
r{}z2|jtjkrit	|dd�dkri�WYdd}~XnXWd|jj�XdS)N�winerrorri&')
r{�closeryrOru�	SHUT_RDWRrP�errnoZENOTCONNrl)rQ�excr;r;r<rO4s
zIMAP4.shutdowncCs|jS)N)ry)rQr;r;r<ruDszIMAP4.socketcCs]d}|jddg|�\}}|dr8||fS|j�\}}|j|||�S)NZRECENTr`r~���)�_untagged_response�noop)rQ�name�typ�datr;r;r<�recentPs	

zIMAP4.recentcCs|j|dg|j��S)N)r��upper)rQ�coder;r;r<�responseaszIMAP4.responsecCs�d}|sd}|r?|d|d
fdkrEd|}nd}|rZt|�}nd}tjt|�}|jr�d|d	}||_|j||||�S)Nr
�INBOXrr~�(�)z(%s)sUTF8 (�)r�)r�r�)r�MapCRLF�sub�CRLFrVrD�_simple_command)rQ�mailbox�flags�	date_time�messager�rDr;r;r<�appendos
		zIMAP4.appendcCst|j�}t|�j|_|jd|�\}}|dkra|j|djdd���d|_||fS)Nrr`r~zutf-8�replacerr�)r��_Authenticator�processrDr�r=�decoderC)rQZ	mechanismZ
authobject�mechr�r�r;r;r<�authenticate�s	zIMAP4.authenticatecCs.d}|j|�\}}|j|||�S)Nr)r�r�)rQr�r�r�r;r;r<�
capability�szIMAP4.capabilitycCs
|jd�S)Nr)r�)rQr;r;r<�check�szIMAP4.checkcCs0z|jd�\}}Wdd|_X||fS)Nrr)r�rC)rQr�r�r;r;r<r��s
zIMAP4.closecCs|jd||�S)Nr)r�)rQ�message_setZnew_mailboxr;r;r<�copy�sz
IMAP4.copycCs|jd|�S)Nr)r�)rQr�r;r;r<�create�szIMAP4.createcCs|jd|�S)Nr)r�)rQr�r;r;r<�delete�szIMAP4.deletecCs|jd||�S)Nr)r�)rQr��whor;r;r<�	deleteacl�szIMAP4.deleteaclcCshd|jkrtjd��|jd|�\}}|dkr^d|j�kr^|j�||fS)NrzServer does not support ENABLEr`zUTF8=ACCEPT)rhrr=r�r�r_)rQr�r�r�r;r;r<�enable�s
zIMAP4.enablecCs.d}|j|�\}}|j|||�S)Nr)r�r�)rQr�r�r�r;r;r<�expunge�s	z
IMAP4.expungecCs4d}|j|||�\}}|j|||�S)Nr)r�r�)rQr�Z
message_partsr�r�r�r;r;r<�fetch�s
zIMAP4.fetchcCs+|jd|�\}}|j||d�S)NrZACL)r�r�)rQr�r�r�r;r;r<�getacl
szIMAP4.getaclcCs1|jd|||�\}}|j||d�S)Nr�
ANNOTATION)r�r�)rQr��entryZ	attributer�r�r;r;r<�
getannotationszIMAP4.getannotationcCs+|jd|�\}}|j||d�S)Nr �QUOTA)r�r�)rQ�rootr�r�r;r;r<�getquotaszIMAP4.getquotacCs^|jd|�\}}|j||d�\}}|j||d�\}}|||gfS)Nr!r�Z	QUOTAROOT)r�r�)rQr�r�r�ZquotaZ	quotarootr;r;r<�getquotaroot)szIMAP4.getquotarootz""�*cCs4d}|j|||�\}}|j|||�S)Nr#)r�r�)rQ�	directory�patternr�r�r�r;r;r<�list4sz
IMAP4.listcCsV|jd||j|��\}}|dkrC|j|d��d|_||fS)Nr$r`r~rr�)r��_quoter=rC)rQ�user�passwordr�r�r;r;r<�login@s
$	zIMAP4.logincCs&|||_|_|jd|j�S)NzCRAM-MD5)r�r�r��_CRAM_MD5_AUTH)rQr�r�r;r;r<�login_cram_md5NszIMAP4.login_cram_md5cCs]ddl}t|jt�r0|jjd�n|j}|jd|j||d�j�S)Nrzutf-8� �md5)�hmac�
isinstancer��str�encoder�ZHMAC�	hexdigest)rQZ	challenger��pwdr;r;r<r�Ws$	zIMAP4._CRAM_MD5_AUTHcCs�d|_y|jd�\}}Wn,ddtj�dd�g}}YnX|j�d|jkr{d|jdfS||fS)Nr�NOz%s: %s��BYE)rCr��sys�exc_inforOrF)rQr�r�r;r;r<rr_s	)
zIMAP4.logoutcCs4d}|j|||�\}}|j|||�S)Nr%)r�r�)rQr�r�r�r�r�r;r;r<�lsubosz
IMAP4.lsubcCs+|jd|�\}}|j||d�S)Nr")r�r�)rQr�r�r�r;r;r<�myrightszszIMAP4.myrightscCs.d}|j|�\}}|j|||�S)Nr&)r�r�)rQr�r�r�r;r;r<�	namespace�szIMAP4.namespacecCs
|jd�S)Nr')r�)rQr;r;r<r��sz
IMAP4.noopcCs:d}|j|||||�\}}|j||d�S)Nr(r)r�r�)rQZmessage_numZmessage_part�start�lengthr�r�r�r;r;r<�partial�s!z
IMAP4.partialcCsd}|jd|�S)Nr))r�)rQr�r�r;r;r<�	proxyauth�s	zIMAP4.proxyauthcCs|jd||�S)Nr*)r�)rQZ
oldmailboxZ
newmailboxr;r;r<�rename�szIMAP4.renamecGspd}|rE|jr$tjd��|j|d||�\}}n|j||�\}}|j|||�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�FcCs�i|_||_|r!d}nd}|j||�\}}|dkr^d|_||fSd|_d|jkr�|r�|jd|��||jjddg�fS)	Nrr,r`rrz	READ-ONLYz%s is not writable�EXISTS)rFrHr�rCr?�get)rQr�r?r�r�r�r;r;r<�select�s				
	zIMAP4.selectcCs|jd|||�S)Nr-)r�)rQr�r�Zwhatr;r;r<�setacl�szIMAP4.setaclcGs+|jd|�\}}|j||d�S)Nr.r�)r�r�)rQrsr�r�r;r;r<�
setannotation�szIMAP4.setannotationcCs.|jd||�\}}|j||d�S)Nr/r�)r�r�)rQr�Zlimitsr�r�r;r;r<�setquota�szIMAP4.setquotacGs[d}|d|dfdkr*d|}|j||||�\}}|j|||�S)	Nr0rr~r�r�z(%s)r�)r�r�)r�r�)rQZ
sort_criteriar��search_criteriar�r�r�r;r;r<�sorts

z
IMAP4.sortNcCs�d}ts|jd��|jr3|jd��||jkrQ|jd��|dkritj�}|j|�\}}|dkr�|j|j	d|j
�|_	|j	jd�|_d|_|j
�n|jd	��|j|||�S)
Nr1zSSL support missingzTLS session already establishedzTLS not supported by serverr`�server_hostnamerxTzCouldn't establish TLS session)�HAVE_SSLr=rJr>rh�ssl�_create_stdlib_contextr��wrap_socketryrRrzr{rfr�)rQ�ssl_contextr�r�r�r;r;r<�starttlss$		
zIMAP4.starttlscCs4d}|j|||�\}}|j|||�S)Nr2)r�r�)rQr��namesr�r�r�r;r;r<�status(szIMAP4.statuscCsU|d|dfd	kr$d|}|jd|||�\}}|j||d�S)
Nrr~r�r�z(%s)r3rr�)r�r�)r�r�)rQr��commandr�r�r�r;r;r<�store4s
zIMAP4.storecCs|jd|�S)Nr4)r�)rQr�r;r;r<�	subscribe?szIMAP4.subscribecGs7d}|j||||�\}}|j|||�S)Nr5)r�r�)rQZthreading_algorithmr�r�r�r�r�r;r;r<�threadGszIMAP4.threadcGs�|j�}|tkr+|jd|��|jt|krj|jd||jdjt|�f��d}|j|||�\}}|d	kr�|}nd}|j|||�S)
NzUnknown IMAP4 UID command: %sz9command %s illegal in state %s, only allowed in states %sz, r6r+r0r5r)r+r0r5)r�rkr=rC�joinr�r�)rQr�rsr�r�r�r;r;r<�uidQs			z	IMAP4.uidcCs|jd|�S)Nr7)r�)rQr�r;r;r<�unsubscribejszIMAP4.unsubscribecGs8|j�}|tkr(|jft|<|j||�S)N)r�rkrCr�)rQr�rsr;r;r<�xatomrs
zIMAP4.xatomcCsL|dkrd}|j}||kr;||j|�n
|g||<dS)N�)rFr�)rQr�r��urr;r;r<�_append_untagged�s	zIMAP4._append_untaggedcCs>|jjd�}|r:|j|dj|jd���dS)Nr�r~r�r�)rFr�r>r�rW)rQZbyer;r;r<�
_check_bye�szIMAP4._check_byec
Gs�|jt|krHd|_|jd||jdjt|�f��x'dD]}||jkrO|j|=qOWd|jkr�|jr�|jd��|j�}t	||j
�}|d|}xL|D]D}|dkr�q�t|t�rt	||j
�}|d|}q�W|j}|dk	r}d|_t
|�t
|j�krW|}n&d}|t	d	t|�|j
�}y|j|t�Wn8tk
r�}	z|jd
|	��WYdd}	~	XnX|dkr�|Sx�x!|j�r|j|r�|Sq�W|r||j�}y|j|�|jt�Wn8tk
rq}	z|jd
|	��WYdd}	~	XnX|s�Pq�W|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)r`r�r�)rCrkrDr=r�rFrHr?�_new_tag�bytesrWr�r��type�_commandr�r�r�rPr>rerErG)
rQr�rsr��tagr��argrDZ	literator�valr;r;r<r��s^			


			 &

&zIMAP4._commandcCs�|dkr|j�y|j|�\}}Wn�|jk
rr}z|jd||f��WYdd}~XnA|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=)rQr�rr�r�rr;r;r<�_command_complete�s
+,
zIMAP4._command_completecCsk|j�\}}|dgkr0|jd��t|d|j�}|j�}t|j��|_dS)Nz"no CAPABILITY response from serverr~r�)r�r=r�rWr��tuple�splitrh)rQr�r�r;r;r<rf�szIMAP4._get_capabilitiescCsc|j�}|j|j|�r�|jjd�}||jkrU|jd|��|jjd�}t||j�}|jjd�}||gf|j|<n]d}|jt	|�s�|j|j
|�r�|jjd�}|jdkr0|jt|�r|jjd�|_dS|jd|��|jjd�}t||j�}|jjd�}|dkrxd}|r�|d|}xb|j|j
|�r�t|jjd	��}|j|�}|j|||f�|j�}q�W|j||�|d
kr_|jt|�r_|jjd�}t||j�}|j||jjd��|S)Nrzunexpected tagged response: %rr�r�Zdata2zunexpected response: %rr�r�r}r`r�r�)r`r�r�)�	_get_line�_matchrd�mo�grouprEr>r�rW�Untagged_responser^�ContinuationrGr\�intr|r��
Response_code)rQ�resprr�r�Zdat2r}r�r;r;r<resHzIMAP4._get_responsecCsxxq|j|}|dk	r*|j|=|S|j�y|j�Wq|jk
ro}z�WYdd}~XqXqWdS)N)rEr�rer>)rQr�resultrr;r;r<rSs


zIMAP4._get_tagged_responsecCsW|j�}|s!|jd��|jd�sC|jd|��|dd�}|S)Nzsocket error: EOFs
z#socket error: unterminated line: %rr����)rr>�endswith)rQr�r;r;r<rnszIMAP4._get_linecCs|j|�|_|jdk	S)N)�matchr	)rQZcre�sr;r;r<r�szIMAP4._matchcCsC|jtt|j�|j�}|jd|_d|j|<|S)Nr~)rcr�r�rIrWrE)rQrr;r;r<r��s"
zIMAP4._new_tagcCs0|jdd�}|jdd�}d|dS)N�\z\\�"z\")r�)rQrr;r;r<r��szIMAP4._quotecGs|j||j||��S)N)rr�)rQr�rsr;r;r<r��szIMAP4._simple_commandcCsN|dkr||fS||jkr2|dgfS|jj|�}||fS)Nr�)rF�pop)rQr�r�r�r�r;r;r<r��s

zIMAP4._untagged_response)Or8r9r:rNr=r>r?�
IMAP4_PORTrTrKr_rMrprqrtrwrLr|rr�rOrur�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�rrfrerrrr�r�r�r�r;r;r;r<r}s�.*
			

 	
M	Pc@sIeZdZdeddddd�Zdd�Zdedd�ZdS)	�	IMAP4_SSLr@NcCs�|dk	r$|dk	r$td��|dk	rH|dk	rHtd��||_||_|dkr~tjd|d|�}||_tj|||�dS)Nz8ssl_context and keyfile arguments are mutually exclusivez9ssl_context and certfile arguments are mutually exclusive�certfile�keyfile)�
ValueErrorrrr�r�r�rrT)rQrRrSrrr�r;r;r<rT�s				zIMAP4_SSL.__init__cCs(tj|�}|jj|d|j�S)Nr�)rrwr�r�rR)rQryr;r;r<rw�szIMAP4_SSL._create_socketcCstj|||�dS)N)rrL)rQrRrSr;r;r<rL�szIMAP4_SSL.open)r8r9r:�IMAP4_SSL_PORTrTrwrLr;r;r;r<r�s	rc@s^eZdZdd�Zdddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rcCs||_tj|�dS)N)r�rrT)rQr�r;r;r<rTs	zIMAP4_stream.__init__NcCsd|_d|_d|_d|_tj|jdtdtjdtjdddd�|_	|j	j
|_|j	j|_
dS)N�bufsize�stdin�stdout�shellT�	close_fds)rRrSryr{�
subprocess�Popenr�r�PIPEr�r�	writefiler �readfile)rQrRrSr;r;r<rLs				zIMAP4_stream.opencCs|jj|�S)N)r'r|)rQr}r;r;r<r|+szIMAP4_stream.readcCs
|jj�S)N)r'r)rQr;r;r<r0szIMAP4_stream.readlinecCs!|jj|�|jj�dS)N)r&�write�flush)rQr�r;r;r<r�5szIMAP4_stream.sendcCs+|jj�|jj�|jj�dS)N)r'r�r&r��wait)rQr;r;r<rO;s

zIMAP4_stream.shutdown)	r8r9r:rTrLr|rr�rOr;r;r;r<r
sc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs
||_dS)N)r�)rQZmechinstr;r;r<rTIsz_Authenticator.__init__cCs5|j|j|��}|dkr(dS|j|�S)N�*)r�r�r�)rQr��retr;r;r<r�Lsz_Authenticator.processcCs�d}t|t�r$|jd�}xt|r�t|�dkrb|dd�}|dd�}n|}d}tj|�}|r'||dd�}q'W|S)Nr�zutf-8�0r~r�)r�r�r�r��binasciiZ
b2a_base64)rQ�inpZoup�t�er;r;r<r�Rs		z_Authenticator.encodecCs|s
dStj|�S)Nr�)r.Z
a2b_base64)rQr/r;r;r<r�jsz_Authenticator.decodeN)r8r9r:rTr�r�r�r;r;r;r<r�Csr�z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr�cCs)i|]\}}|d|j��qS)r~)r�)�.0�nrr;r;r<�
<dictcomp>ps	r4r~c	Cs4tj|�}|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�Mon2numr
r
�calendarZtimegm�time�	localtime)rr	r5r6r7r8r9r:r;r<r=Zzone�tt�utcr;r;r<rrs$!cCs\d}d}tt|��}x7|rWt|d�\}}|||d�|}q!W|S)Nr�sABCDEFGHIJKLMNOP�r~)r
�abs�divmod)�numrZAP�modr;r;r<r	�s	cCs2tj|�}|sfSt|jd�j��S)Nr�)�Flagsrrr
r)rr	r;r;r<r
�sc
Cs�t|ttf�r3tj|tj�j�}n0t|t�r�y
|j	}Wnqt
k
r�tjr�|d}|dkr�tj
tj|��d}tjtjf|}n
tj}YnXtd|�}t|dd�dt|��}nlt|t�r*|jdkr!td��|}n9t|t�rW|d|dfd
krW|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
fromtimestamprrFZ
astimezoner�	tm_gmtoffrnrC�daylightrD�mktime�altzonerrOrr��format�MonthsZmonth�strftime)r�ZdtZgmtoff�dstZdelta�fmtr;r;r<r�s0	

	
%	)�__main__zd:s:z-dz-sr@zIMAP password for %s on %s: �	localhostzJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)sr�Zlf�
r�r�z
/tmp/xxx 1r�z/tmp/yyyz
/tmp/yyz 2r�r�z/tmpzyy*r�r�ZSUBJECTZtestr��1z(FLAGS INTERNALDATE RFC822)r��FLAGSz
(\Deleted)r�r�r�r�r�ZUIDVALIDITYr�ZALLr�rrcCsftjd||f�tt|�|�\}}tjd|||f�|dkrb|d�|S)Nz%s %sz%s => %s %sr�r)�M�_mesgrl)�cmdrsr�r�r;r;r<�runs
rbzPROTOCOL_VERSION = %szCAPABILITIES = %rz/tmp/zyy%z.*"([^"]+)"$r�z%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�rarXrur#r�rCrBrrr�iorr�r��ImportError�__all__r�rArrrgr�rkrYrrLr@r[r\r�rrr^rZr]rrr�rr�rrV�	enumeraterArr	r
rr8ZgetoptZgetpass�argvZoptlistrsr=rZstream_command�optr
rRZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2rbr_rCr`rirhra�mlrr	r
�pathr�r��printr;r;r;r<�<module>s:l

																		����[1
9,##
))%
	
					


?>