Your IP : 18.225.54.199


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/imaplib.cpython-39.opt-2.pyc

a

R�fx��+@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
mZmZddl
mZzddlZdZWney�dZYn0gd�ZdZdZd	Zd
ZdZdZd
dddddd
d
d
dd
ddd
d
d
d
d
d
ddd
dd
dddd
dd
d
d
d
ddd
dd
ddd
dd�*Ze�d�Ze�d�Ze�d�Ze�dej�Ze�d�Z e�d�Z!e�d�Z"e�dej�Z#dZ$dZ%Gdd�d�Z&e�r�Gdd�de&�Z'e�(d�Gdd �d e&�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/�Z2e3d0k�r�ddl4Z4ddl5Z5ze4�4ej6d'd�d1�\Z7Z8Wn0e4j9�yfZ:zd2\Z7Z8WYdZ:[:n
dZ:[:00dZ;e7D]8\Z<Z:e<d3k�r�e=e:�Zne<d4k�rpe:Z;e8�spe;fZ8�qpe8�s�d5Z8e8dZ>e5�?�Z@e5�5d6e@e>�p�d7f�ZAd8e@d9d:�ZBd;e@eAffd<d=d>d?d@ddeBffdAdBdCdDdEdFdGdHdIfZCdJdKdLdMd?dddeBffdHdNfZDdOdP�ZE�ze;�rXe)e;�ZFne&e>�ZFeFjGdQk�rxeCd'd�ZCeF�HdReFjI�eF�HdSeFjJf�eCD]\ZKZ8eEeKe8��q�eEdTdU�D]<ZLe�MdVeL�ZNeN�r�eN�Od'�ZPneL�+�dWZPeEdXePf��q�eDD]T\ZKZ8eEeKe8�ZQeKe8fdLk�r$�qeQdW�+�ZReR�s:�qeEdYdZd[eRdWd\f��qeSd]�Wn.eSd^�e�s�eSd_ej6d��Yn0dS)`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�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@s�eZdZGdd�de�ZGdd�de�ZGdd�de�Zdedfd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdedfdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'd�dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,d�dUdV�Z-dWdX�Z.dYdZ�Z/d[d\�Z0d]d^�Z1d_d`�Z2dadb�Z3dcdd�Z4d�dgdh�Z5didj�Z6dkdl�Z7dmdn�Z8dodp�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�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOdS)�rc@seZdZdS)zIMAP4.errorN��__name__�
__module__�__qualname__�r>r>�,/opt/alt/python39/lib64/python3.9/imaplib.py�error��r@c@seZdZdS)zIMAP4.abortNr:r>r>r>r?�abort�rArBc@seZdZdS)zIMAP4.readonlyNr:r>r>r>r?�readonly�rArC�NcCs�t|_d|_d|_i|_i|_d|_d|_d|_d|_	|�
�|�|||�z|��Wn4t
y�z|��Wnty�Yn0�Yn0dS)NrrDFr)�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�timeoutr>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�rVr>r>r?rO�szIMAP4._mode_asciicCs(d|_d|_t�t�|_t�t�|_dS)NT�utf-8)r\r]r^r_r`rbrcrdrer>r>r?�
_mode_utf8�szIMAP4._mode_utf8cCs�tt�dd��|_t�d|jdtj�|_|�	�|_
d|jvrHd|_nd|jvrZd|_n|�
|j
��|��tD]}||jvr�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_ra�tagre�__version__�
_get_responseZwelcomerJrGr@�_get_capabilities�AllowedVersions�capabilities�PROTOCOL_VERSION)rV�versionr>r>r?rQ�s*���



zIMAP4._connectcCs&|tvrt||���Std|��dS)NzUnknown IMAP4 command: '%s')�Commands�getattr�lower�AttributeError)rV�attrr>r>r?�__getattr__
szIMAP4.__getattr__cCs|S�Nr>rer>r>r?�	__enter__szIMAP4.__enter__cGs2|jdkrdSz|��Wnty,Yn0dS�Nr)rG�logoutrT)rV�argsr>r>r?�__exit__s
zIMAP4.__exit__cCs`|dur|std��|jsdn|j}t�d||j|j�||jf}|durVt�||�St�|�S)Nz0Non-blocking socket (timeout=0) is not supportedzimaplib.open)�
ValueErrorrW�sys�auditrX�socketZcreate_connection)rVrYrWZaddressr>r>r?�_create_socket#s
zIMAP4._create_socketcCs*||_||_|�|�|_|j�d�|_dS)N�rb)rWrXr��sock�makefile�filerUr>r>r?rP0sz
IMAP4.opencCs|j�|�Sry)r��read�rV�sizer>r>r?r�<sz
IMAP4.readcCs.|j�td�}t|�tkr*|�dt��|S)N�zgot more than %d bytes)r��readline�_MAXLINE�lenr@�rV�liner>r>r?r�AszIMAP4.readlinecCst�d||�|j�|�dS)Nzimaplib.send)r�r�r�Zsendall�rV�datar>r>r?�sendIsz
IMAP4.sendc
Cs�|j��zdz|j�tj�WnBty`}z*|jtjkrLt	|dd�dkrL�WYd}~n
d}~00W|j��n|j��0dS)NZwinerrorri&')
r��closer�rSr�Z	SHUT_RDWRrT�errnoZENOTCONNrt)rV�excr>r>r?rSOs
�zIMAP4.shutdowncCs|jSry)r�rer>r>r?r�_szIMAP4.socketcCsBd}|�ddg|�\}}|dr(||fS|��\}}|�|||�S)NZRECENTrh���)�_untagged_response�noop�rV�name�typ�datr>r>r?�recentks	zIMAP4.recentcCs|�|dg|���Sry)r��upper)rV�coder>r>r?�response|szIMAP4.responsecCsxd}|sd}|r.|d|dfdkr2d|}nd}|r@t|�}nd}t�t|�}|jrbd|d}||_|�||||�S)	Nr�INBOXrr���(�)�(%s)sUTF8 (�))r�MapCRLF�sub�CRLFr\rH�_simple_command)rV�mailbox�flags�	date_time�messager�rHr>r>r?�append�s

zIMAP4.appendcCsP|��}t|�j|_|�d|�\}}|dkrB|�|d�dd���d|_||fS)Nrrhr�rf�replacer)r��_Authenticator�processrHr�r@�decoderG)rVZ	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�rer>r>r?�check�szIMAP4.checkcCs*z|�d�\}}Wd|_nd|_0||fS)Nrr�r�rG�rVr�r�r>r>r?r��szIMAP4.closecCs|�d||�S)Nrr�)rV�message_setZnew_mailboxr>r>r?�copy�sz
IMAP4.copycCs|�d|�S)Nrr��rVr�r>r>r?�create�szIMAP4.createcCs|�d|�S)Nrr�r�r>r>r?�delete�szIMAP4.deletecCs|�d||�S)Nrr�)rVr��whor>r>r?�	deleteacl�szIMAP4.deleteaclcCsHd|jvrt�d��|�d|�\}}|dkr@d|��vr@|��||fS)NrzServer does not support ENABLErhzUTF8=ACCEPT)rprr@r�r�rg)rVr�r�r�r>r>r?�enable�s

zIMAP4.enablecCs d}|�|�\}}|�|||�S)Nrr�r�r>r>r?�expunges	z
IMAP4.expungecCs$d}|�|||�\}}|�|||�S)Nrr�)rVr�Z
message_partsr�r�r�r>r>r?�fetchs
zIMAP4.fetchcCs|�d|�\}}|�||d�S)NrZACLr��rVr�r�r�r>r>r?�getacl(szIMAP4.getaclcCs"|�d|||�\}}|�||d�S)Nr �
ANNOTATIONr�)rVr��entryZ	attributer�r�r>r>r?�
getannotation1szIMAP4.getannotationcCs|�d|�\}}|�||d�S)Nr!�QUOTAr�)rV�rootr�r�r>r>r?�getquota9szIMAP4.getquotacCs@|�d|�\}}|�||d�\}}|�||d�\}}|||gfS)Nr"r�Z	QUOTAROOTr�)rVr�r�r�ZquotaZ	quotarootr>r>r?�getquotarootDszIMAP4.getquotaroot�""�*cCs$d}|�|||�\}}|�|||�S)Nr$r��rVZ	directory�patternr�r�r�r>r>r?�listOsz
IMAP4.listcCs<|�d||�|��\}}|dkr.|�|d��d|_||fS)Nr%rhr�r)r��_quoter@rG)rV�user�passwordr�r�r>r>r?�login[s
zIMAP4.logincCs|||_|_|�d|j�S)NzCRAM-MD5)r�r�r��_CRAM_MD5_AUTH)rVr�r�r>r>r?�login_cram_md5iszIMAP4.login_cram_md5cCsBddl}t|jt�r |j�d�n|j}|jd|�||d���S)Nrrf� Zmd5)�hmac�
isinstancer��str�encoder�ZHMACZ	hexdigest)rVZ	challenger��pwdr>r>r?r�rs
�zIMAP4._CRAM_MD5_AUTHcCs$d|_|�d�\}}|��||fSr{)rGr�rSr�r>r>r?r|zsz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�rer>r>r?r��sz
IMAP4.noopcCs(d}|�|||||�\}}|�||d�S)Nr)rr�)rVZmessage_numZmessage_part�startZlengthr�r�r�r>r>r?�partial�sz
IMAP4.partialcCsd}|�d|�S)Nr*r�)rVr�r�r>r>r?�	proxyauth�s	zIMAP4.proxyauthcCs|�d||�S)Nr+r�)rVZ
oldmailboxZ
newmailboxr>r>r?�rename�szIMAP4.renamecGsXd}|r4|jrt�d��|j|d|g|�R�\}}n|j|g|�R�\}}|�|||�S)Nr,z'Non-None charset not valid in UTF8 mode�CHARSET)r\rr@r�r�)rV�charsetZcriteriar�r�r�r>r>r?�search�s
zIMAP4.searchr�FcCsvi|_||_|rd}nd}|�||�\}}|dkr@d|_||fSd|_d|jvrb|sb|�d|��||j�ddg�fS)	Nrr-rhrr�	READ-ONLYz%s is not writable�EXISTS)rJrLr�rGrC�get)rVr�rCr�r�r�r>r>r?�select�s
�zIMAP4.selectcCs|�d|||�S)Nr.r�)rVr�r�Zwhatr>r>r?�setaclszIMAP4.setaclcGs$|jdg|�R�\}}|�||d�S)Nr/r�r�)rVr}r�r�r>r>r?�
setannotation
szIMAP4.setannotationcCs |�d||�\}}|�||d�S)Nr0r�r�)rVr�Zlimitsr�r�r>r>r?�setquotaszIMAP4.setquotacGsHd}|d|dfdkr d|}|j|||g|�R�\}}|�|||�S)Nr1rr�r�r�r�)rVZ
sort_criteriar��search_criteriar�r�r�r>r>r?�sorts
z
IMAP4.sortcCs�d}ts|�d��|jr"|�d��||jvr6|�d��|durFt��}|�|�\}}|dkr�|j|j	|j
d�|_	|j	�d�|_d|_|�
�n
|�d	��|�|||�S)
Nr2zSSL support missingzTLS session already establishedzTLS not supported by serverrh�Zserver_hostnamer�TzCouldn't establish TLS session)�HAVE_SSLr@rNrBrp�ssl�_create_stdlib_contextr��wrap_socketr�rWr�r�rnr�)rV�ssl_contextr�r�r�r>r>r?�starttls)s&



�

zIMAP4.starttlscCs$d}|�|||�\}}|�|||�S)Nr3r�)rVr��namesr�r�r�r>r>r?�status@szIMAP4.statuscCs>|d|dfdkrd|}|�d|||�\}}|�||d�S)Nrr�r�r�r4rr�)rVr��commandr�r�r�r>r>r?�storeLszIMAP4.storecCs|�d|�S)Nr5r�r�r>r>r?�	subscribeWszIMAP4.subscribecGs,d}|j|||g|�R�\}}|�|||�S)Nr6r�)rVZthreading_algorithmr�r�r�r�r�r>r>r?�thread_szIMAP4.threadc	Gs�|��}|tvr|�d|��|jt|vrL|�d||jd�t|�f��d}|j||g|�R�\}}|dvrv|}nd}|�|||�S)NzUnknown IMAP4 UID command: %s�9command %s illegal in state %s, only allowed in states %s�, r7)r,r1r6r)r�rsr@rG�joinr�r�)rVr�r}r�r�r�r>r>r?�uidis��z	IMAP4.uidcCs|�d|�S)Nr8r�r�r>r>r?�unsubscribe�szIMAP4.unsubscribecCs*z|�d�\}}Wd|_nd|_0||fS)Nr9rr�)rVr�r�r>r>r?�unselect�s	zIMAP4.unselectcGs.|��}|tvr|jft|<|j|g|�R�Sry)r�rsrGr��rVr�r}r>r>r?�xatom�s
zIMAP4.xatomcCs8|durd}|j}||vr*||�|�n
|g||<dS�NrA)rJr�r�)rVr�r�Zurr>r>r?�_append_untagged�szIMAP4._append_untaggedcCs,|j�d�}|r(|�|d�|jd���dS)N�BYEr�r�)rJr�rBr�r])rV�byer>r>r?�
_check_bye�szIMAP4._check_byec

Gs�|jt|vr4d|_|�d||jd�t|�f��dD]}||jvr8|j|=q8d|jvrj|jsj|�d��|��}t	||j
�}|d|}|D]0}|dur�q�t|t�r�t	||j
�}|d|}q�|j}|du�r
d|_t
|�t
|j�ur�|}nd}|t	dt|�|j
�}z|�|t�Wn4t�yP}	z|�d|	��WYd}	~	n
d}	~	00|du�r`|S|���r~|j|�r`|S�q`|�r�||j�}z|�|�|�t�Wn4t�y�}	z|�d|	��WYd}	~	n
d}	~	00|�s`�q�q`|S)	Nrr�rh�NO�BADr�z#mailbox status changed to READ-ONLY� z {%s}zsocket error: %s)rGrsrHr@rrJrLrC�_new_tag�bytesr]r�r��type�_commandr�r�r�rTrBrmrIrK)
rVr�r}r��tagr��argrHZ	literator�valr>r>r?r�s`��


�



$



$zIMAP4._commandc
Cs�|dk}|s|��z|j||d�\}}Wnn|jyb}z|�d||f��WYd}~n@d}~0|jy�}z|�d||f��WYd}~n
d}~00|s�|��|dkr�|�d|||f��||fS)Nr)�
expect_byezcommand: %s => %srz%s command error: %s %s)r
�_get_tagged_responserBr@)rVr�rr|r�r�rr>r>r?�_command_completes&(zIMAP4._command_completecCsJ|��\}}|dgkr |�d��t|d|j�}|��}t|���|_dS)Nz"no CAPABILITY response from serverr�)r�r@r�r]r��tuple�splitrpr�r>r>r?rn#s

zIMAP4._get_capabilitiescCs�|��}|�|j|�rp|j�d�}||jvr:|�d|��|j�d�}t||j�}|j�d�}||gf|j|<n�d}|�t	|�s�|�|j
|�r�|j�d�}|jdur�|�t|�r�|j�d�|_dS|�d|��|j�d�}t||j�}|j�d�}|du�rd}|�r|d|}|�|j
|��rZt|j�d	��}|�|�}|�|||f�|��}�q|�||�|d
v�r�|�t|��r�|j�d�}t||j�}|�||j�d��|S)Nrzunexpected tagged response: %rrr�Zdata2zunexpected response: %rrArr�r)�	_get_line�_matchrk�mo�grouprIrBr�r]�Untagged_responserd�ContinuationrKrb�intr�r
�
Response_code)rV�resprr�r�Zdat2r�r�r>r>r?rm,sD


zIMAP4._get_responsec
Cs�|j|}|dur|j|=|S|rDd}|j�|d�}|durD||fS|��z|��Wq|jy�}z�WYd}~qd}~00qdS)Nr)rIrJ�popr
rmrB)rVrr�resultr�rrr>r>r?r|s
zIMAP4._get_tagged_responsecCs>|��}|s|�d��|�d�s.|�d|��|dd�}|S)Nzsocket error: EOFrz#socket error: unterminated line: %r���)r�rB�endswithr�r>r>r?r�s

zIMAP4._get_linecCs|�|�|_|jduSry)�matchr )rVZcre�sr>r>r?r�szIMAP4._matchcCs2|jtt|j�|j�}|jd|_d|j|<|S)Nr�)rjrr�rMr]rI)rVrr>r>r?r�s
zIMAP4._new_tagcCs$|�dd�}|�dd�}d|dS)N�\z\\�"z\")r�)rVrr>r>r?r��szIMAP4._quotecGs|�||j|g|�R��Sry)rrrr>r>r?r��szIMAP4._simple_commandcCs8|dkr||fS||jvr$|dgfS|j�|�}||fS)Nr)rJr')rVr�r�r�r�r>r>r?r��s

zIMAP4._untagged_response)r�r�)r�r�)r�F)N)F)Tr;r<r=rRr@rBrC�
IMAP4_PORTrZrOrgrQrxrzr~r�rPr�r�r�rSr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
r
rrrnrmrrrrr�r�r��_mesgZ_dump_urZ_logZ	print_logr>r>r>r?r�s�1*

		
	



 	

M	P
!$rc@s:eZdZdeddddfdd�Zdd�Zdedfdd�ZdS)	�	IMAP4_SSLrDNcCs�|dur|durtd��|dur0|dur0td��|dus@|durVddl}|�dtd�||_||_|durxtj||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)r�warnings�warn�DeprecationWarningr4r3r�r�r�rrZ)rVrWrXr4r3r�rYr5r>r>r?rZs"��zIMAP4_SSL.__init__cCst�||�}|jj||jd�S)Nr�)rr�r�r�rW)rVrYr�r>r>r?r�.s�zIMAP4_SSL._create_socketcCst�||||�dSry)rrPrUr>r>r?rP3szIMAP4_SSL.open)r;r<r=�IMAP4_SSL_PORTrZr�rPr>r>r>r?r1s
�
r1c@s>eZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rcCs||_t�|�dSry)r�rrZ)rVr�r>r>r?rZJszIMAP4_stream.__init__NcCsNd|_d|_d|_d|_tj|jttjtjddd�|_	|j	j
|_|j	j|_
dS)NT)�bufsize�stdin�stdout�shellZ	close_fds)rWrXr�r��
subprocess�Popenr�r�PIPEr�r:�	writefiler;�readfilerUr>r>r?rPOs�
zIMAP4_stream.opencCs|j�|�Sry)rAr�r�r>r>r?r�_szIMAP4_stream.readcCs
|j��Sry)rAr�rer>r>r?r�dszIMAP4_stream.readlinecCs|j�|�|j��dSry)r@�write�flushr�r>r>r?r�iszIMAP4_stream.sendcCs"|j��|j��|j��dSry)rAr�r@r��waitrer>r>r?rSos

zIMAP4_stream.shutdown)NNN)	r;r<r=rZrPr�r�r�rSr>r>r>r?r>s
rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
r�cCs
||_dSry)r�)rVZmechinstr>r>r?rZ}sz_Authenticator.__init__cCs&|�|�|��}|durdS|�|�S)N�*)r�r�r�)rVr�Zretr>r>r?r��sz_Authenticator.processcCsnd}t|t�r|�d�}|rjt|�dkrB|dd�}|dd�}n|}d}t�|�}|r||dd�}q|S)NrArf�0r�)r�r�r�r��binasciiZ
b2a_base64)rV�inpZoup�t�er>r>r?r��s	


z_Authenticator.encodecCs|sdSt�|�Sr	)rGZ
a2b_base64)rVrHr>r>r?r��sz_Authenticator.decodeN)r;r<r=rZr�r�r�r>r>r>r?r�wsr�z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr�cCsi|]\}}|��|d�qS)r�)r�)�.0�nr,r>r>r?�
<dictcomp>�rArMr�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+�Mon2numr!r$�calendarZtimegm�time�	localtime)r&r rNrOrPrQrRrSrTrUrVZzoneZtt�utcr>r>r?r�s$

rcCs@d}d}tt|��}|r<t|d�\}}|||d�|}q|S)NrAsABCDEFGHIJKLMNOP�r�)r$�abs�divmod)ZnumrZAP�modr>r>r?r	�sr	cCs$t�|�}|sdSt|�d����S)Nr>r�)�Flagsr+rr!r)r&r r>r>r?r
�s
r
cCst|ttf�r"t�|tj���}n�t|t�r�z
|j	}WnXt
y�tjr�|d}|dkrnt�
t�|��d}tjtjf|}ntj}Yn0t|d�}t|dd�dt|�i�}nLt|t�r�|jdur�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
fromtimestamprr^Z
astimezoner�	tm_gmtoffrvr\�daylightr]�mktime�altzonerrfrr��format�MonthsZmonth�strftime)r�ZdtZgmtoffZdstZdeltaZfmtr>r>r?r�s2�





r�__main__zd:s:)r>r>z-dz-s)rDzIMAP 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�)rqz/tmp/yyy)r��
/tmp/yyz 2r�rs)r�)z/tmpzyy*)r�rr)r�)NZSUBJECT�test)r�)�1z(FLAGS INTERNALDATE RFC822))r�)ru�FLAGSz
(\Deleted))r�r>)r�r>)r�r>)r�r>)r�r>)r�)ZUIDVALIDITY)r)r,ZALL)r�)r�)r|r>cCsLt�d||f�tt|�|�\}}t�d|||f�|dkrH|d�|S)Nz%s %sz%s => %s %srr)�Mr0rt)�cmdr}r�r�r>r>r?�runBs
ryrzPROTOCOL_VERSION = %szCAPABILITIES = %rr�)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
)TrlrGr�rir^r�r=r�r\r[rrr�iorr�r��ImportError�__all__r�rEr/r8ror�rsr_r#rcrYrarbr�r%r"rdr`rcrr1r�rr�rrm�	enumeraterZrr	r
rr;ZgetoptZgetpass�argvZoptlistr}r@rZstream_command�optr$rWZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2ryrwrGr0rqrprxZmlr+r r!�pathr�r�printr>r>r>r?�<module>sJH
	�0



	

�6
9,
#
)





��



�
�

?>