AlkantarClanX12

Your IP : 3.144.43.194


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/imaplib.cpython-310.opt-2.pyc

o

6��fR��@s"	dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
m
Z
mZmZddl
mZzddlZdZWneyJdZYnwgd�ZdZdZd	Zd
ZdZdZid
d�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�dd�d d�d!d�d"d�id#d�d$d�d%d�d&d�d'd�d(d�d)d�d*d�d+d�d,d�d-d�d.d�d/d�d0d�d1d�d2d�d3d��ddddddddd4��Ze�d5�Ze�d6�Ze�d7�Ze�d8ej�Ze�d9�Z e�d:�Z!e�d;�Z"e�d<ej�Z#d8Z$d<Z%Gd=d>�d>�Z&e�rGd?d@�d@e&�Z'e�(d@�GdAdB�dBe&�Z)GdCdD�dD�Z*dE�+dF�Z,dGdH�e-e,dId��D�Z.dJdK�Z/dLdM�Z0dNdO�Z1dPdQ�Z2e3dRk�r�ddl4Z4ddl5Z5ze4�4ej6dId�dS�\Z7Z8Wne4j9�y|Z:z
dT\Z7Z8WYdZ:[:ndZ:[:wwdZ;e7D]\Z<Z:e<dUk�r�e=e:�Z�q�e<dVk�r�e:Z;e8�s�e;fZ8�q�e8�s�dWZ8e8dZ>e5�?�Z@e5�5dXe@e>�p�dYf�ZAdZe@d[d\�ZBd]e@eAffd^d_d`dadbddeBffdcdddedfdgdhdidjdkfZCdldmdndodadddeBffdjdpfZDdqdr�ZEz�e;�r�e)e;�ZFne&e>�ZFeFjGdsk�reCdId�ZCeF�HdteFjI�eF�HdueFjJf�eCD]
\ZKZ8eEeKe8��qeEdvdw�D]ZLe�MdxeL�ZNeN�r9eN�OdI�ZPneL�+�dyZPeEdzePf��q(eDD]*\ZKZ8eEeKe8�ZQeKe8fdnk�r[�qIeQdy�+�ZReR�sf�qIeEd{dd|eRdyd}f��qIeSd~�WdSeSd�e�s�eSd�ej6d��dS)�z2.58�N)�datetime�timezone�	timedelta)�DEFAULT_BUFFER_SIZETF)�IMAP4�IMAP4_stream�Internaldate2tuple�Int2AP�
ParseFlags�Time2Internaldate�
�i�)Z	IMAP4REV1ri@B�APPEND)�AUTH�SELECTED�AUTHENTICATE)�NONAUTH�
CAPABILITY)rrr�LOGOUT�CHECK)r�CLOSE�COPY�CREATE�DELETE�	DELETEACL�ENABLE)r�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�eZdZ	Gdd�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@�eZdZdS)zIMAP4.errorN��__name__�
__module__�__qualname__�r?r?�./opt/alt/python310/lib64/python3.10/imaplib.py�error��rAc@r:)zIMAP4.abortNr;r?r?r?r@�abort�rBrCc@r:)zIMAP4.readonlyNr;r?r?r?r@�readonly�rBrD�NcCs�t|_d|_d|_i|_i|_d|_d|_d|_d|_	|�
�|�|||�z|��WdSt
yDz|��W�tyCY�ww)NrrEFr)�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�rWr?r?r@rP�szIMAP4._mode_asciicCs(d|_d|_t�t�|_t�t�|_dS)NT�utf-8)r]r^r_r`rarcrdrerfr?r?r@�
_mode_utf8�szIMAP4._mode_utf8cCs�tt�dd��|_t�d|jdtj�|_	|��|_d|jvr%d|_nd
|jvr.d|_n|�|j��|��	tD]
}||jvrCq;||_dS|�d��)Nii��s(?P<tag>s"\d+) (?P<type>[A-Z]+) (?P<data>.*)F�
r�zimaplib version %sznew IMAP4 connection, tag=%sZPREAUTHr�OKr�zCAPABILITIES: %rzserver not IMAP4 compliant)r	�randomZrandint�tagprer_r`rb�tagre�_cmd_log_len�_cmd_log_idx�_cmd_logrG�_mesg�__version__�
_get_responseZwelcomerKrHrA�_get_capabilities�capabilities�AllowedVersions�PROTOCOL_VERSION)rW�versionr?r?r@rR�s.���




zIMAP4._connectcCs"|tvrt||���Std|��)NzUnknown IMAP4 command: '%s')�Commands�getattr�lower�AttributeError)rW�attrr?r?r@�__getattr__
szIMAP4.__getattr__cCs|S�Nr?rfr?r?r@�	__enter__szIMAP4.__enter__cGs2|jdkrdSz|��WdStyYdSw�Nr)rH�logoutrU)rW�argsr?r?r@�__exit__s
�zIMAP4.__exit__cCs`|dur
|s
td��|jsdn|j}t�d||j|j�||jf}|dur+t�||�St�|�S)Nz0Non-blocking socket (timeout=0) is not supportedzimaplib.open)�
ValueErrorrX�sys�auditrY�socketZcreate_connection)rWrZrXZaddressr?r?r@�_create_socket#s

zIMAP4._create_socketcCs,	||_||_|�|�|_|j�d�|_dS)N�rb)rXrYr��sock�makefile�filerVr?r?r@rQ0s
z
IMAP4.opencC�	|j�|�Sr�)r��read�rW�sizer?r?r@r�<�z
IMAP4.readcCs0	|j�td�}t|�tkr|�dt��|S)Nrjzgot more than %d bytes)r��readline�_MAXLINE�lenrA�rW�liner?r?r@r�As
zIMAP4.readlinecCs 	t�d||�|j�|�dS)Nzimaplib.send)r�r�r�Zsendall�rW�datar?r?r@�sendIsz
IMAP4.sendc
Cs�	|j��z;z	|j�tj�Wn!ty1}z|jtjkr't	|dd�dkr'�WYd}~n
d}~wwW|j��dSW|j��dS|j��w)NZwinerrorri&')
r��closer�rTr�Z	SHUT_RDWRrU�errnoZENOTCONNr|)rW�excr?r?r@rTOs
���	�zIMAP4.shutdowncCs	|jSr�)r�rfr?r?r@r�_szIMAP4.socketcCsD	d}|�ddg|�\}}|dr||fS|��\}}|�|||�S)NZRECENTrk���)�_untagged_response�noop�rW�name�typ�datr?r?r@�recentkszIMAP4.recentcCs	|�|dg|���Sr�)r��upper)rW�coder?r?r@�response|szIMAP4.responsecCsz	d}|sd}|r|d|dfdkrd|}nd}|r!t|�}nd}t�t|�}|jr2d|d}||_|�||||�S)	Nr�INBOXrr���(�)�(%s)sUTF8 (�))r�MapCRLF�sub�CRLFr]rI�_simple_command)rW�mailbox�flags�	date_time�messager�rIr?r?r@�append�s"�
zIMAP4.appendcCsR	|��}t|�j|_|�d|�\}}|dkr"|�|d�dd���d|_||fS)Nrrkr�rg�replacer)r��_Authenticator�processrIr�rA�decoderH)rWZ	mechanismZ
authobject�mechr�r�r?r?r@�authenticate�szIMAP4.authenticatecC�"	d}|�|�\}}|�|||�S)Nr�r�r�r�r?r?r@�
capability�szIMAP4.capabilitycCs	|�d�S)Nr�r�rfr?r?r@�check�s
zIMAP4.checkcC�*	z|�d�\}}Wd|_||fSd|_w)Nrr�r�rH�rWr�r�r?r?r@r��s�zIMAP4.closecC�	|�d||�S)Nrr�)rW�message_setZnew_mailboxr?r?r@�copy��z
IMAP4.copycC�	|�d|�S)Nrr��rWr�r?r?r@�create��zIMAP4.createcCr�)Nrr�r�r?r?r@�delete�r�zIMAP4.deletecCr�)Nrr�)rWr��whor?r?r@�	deleteacl�r�zIMAP4.deleteaclcCsJ	d|jvrt�d��|�d|�\}}|dkr!d|��vr!|��||fS)NrzServer does not support ENABLErkzUTF8=ACCEPT)rwrrAr�r�rh)rWr�r�r�r?r?r@�enable�s

zIMAP4.enablecCr�)Nrr�r�r?r?r@�expungesz
IMAP4.expungecC�&	d}|�|||�\}}|�|||�S)Nrr�)rWr�Z
message_partsr�r�r�r?r?r@�fetchs	zIMAP4.fetchcC� 	|�d|�\}}|�||d�S)NrZACLr��rWr�r�r�r?r?r@�getacl(�zIMAP4.getaclcCs$	|�d|||�\}}|�||d�S)Nr �
ANNOTATIONr�)rWr��entryZ	attributer�r�r?r?r@�
getannotation1szIMAP4.getannotationcCr�)Nr!�QUOTAr�)rW�rootr�r�r?r?r@�getquota9szIMAP4.getquotacCsB	|�d|�\}}|�||d�\}}|�||d�\}}|||gfS)Nr"r�Z	QUOTAROOTr�)rWr�r�r�ZquotaZ	quotarootr?r?r@�getquotarootDs
zIMAP4.getquotaroot�""�*cCr�)Nr$r��rWZ	directory�patternr�r�r�r?r?r@�listO�z
IMAP4.listcCs>	|�d||�|��\}}|dkr|�|d��d|_||fS)Nr%rkr�r)r��_quoterArH)rW�user�passwordr�r�r?r?r@�login[szIMAP4.logincCs	|||_|_|�d|j�S)NzCRAM-MD5)r�r�r��_CRAM_MD5_AUTH)rWr�r�r?r?r@�login_cram_md5iszIMAP4.login_cram_md5cCsD	ddl}t|jt�r|j�d�n|j}|jd|�||d���S)Nrrg� Zmd5)�hmac�
isinstancer��str�encoder�ZHMACZ	hexdigest)rWZ	challenger��pwdr?r?r@r�rs�zIMAP4._CRAM_MD5_AUTHcCs&	d|_|�d�\}}|��||fSr�)rHr�rTr�r?r?r@r�zs
zIMAP4.logoutcCr�)Nr&r�r�r?r?r@�lsub�r�z
IMAP4.lsubcCs 	|�d|�\}}|�||d�S)Nr#r�r�r?r?r@�myrights�r�zIMAP4.myrightscCr�)Nr'r�r�r?r?r@�	namespace�szIMAP4.namespacecCs		|�d�S)NFrlr()rG�_dump_urrKr�rfr?r?r@r��s
z
IMAP4.noopcCs*	d}|�|||||�\}}|�||d�S)Nr)rr�)rWZmessage_numZmessage_part�startZlengthr�r�r�r?r?r@�partial�sz
IMAP4.partialcCs	d}|�d|�S)Nr*r�)rWr�r�r?r?r@�	proxyauth�szIMAP4.proxyauthcCr�)Nr+r�)rWZ
oldmailboxZ
newmailboxr?r?r@�rename�r�zIMAP4.renamecGsZ	d}|r|jr
t�d��|j|d|g|�R�\}}n|j|g|�R�\}}|�|||�S)Nr,z'Non-None charset not valid in UTF8 mode�CHARSET)r]rrAr�r�)rW�charsetZcriteriar�r�r�r?r?r@�search�s
zIMAP4.searchr�FcCsz	i|_||_|rd}nd}|�||�\}}|dkr!d|_||fSd|_d|jvr3|s3	|�d	|��||j�d
dg�fS)Nrr-rkrr�	READ-ONLYFrjz%s is not writable�EXISTS)rKrMr�rHrGr�rD�get)rWr�rDr�r�r�r?r?r@�select�s"
�zIMAP4.selectcCs	|�d|||�S)Nr.r�)rWr�r�Zwhatr?r?r@�setaclszIMAP4.setaclcGs&	|jdg|�R�\}}|�||d�S)Nr/r�r�)rWr�r�r�r?r?r@�
setannotation
szIMAP4.setannotationcCs"	|�d||�\}}|�||d�S)Nr0r�r�)rWr�Zlimitsr�r�r?r?r@�setquotaszIMAP4.setquotacGsJ	d}|d|dfdkrd|}|j|||g|�R�\}}|�|||�S)Nr1rr�r�r�r�)rWZ
sort_criteriar��search_criteriar�r�r�r?r?r@�sortsz
IMAP4.sortcCs�d}ts	|�d��|jr|�d��||jvr|�d��|dur#t��}|�|�\}}|dkrG|j|j	|j
d�|_	|j	�d�|_d|_|�
�n|�d	��|�|||�S)
Nr2zSSL support missingzTLS session already establishedzTLS not supported by serverrk�Zserver_hostnamer�TzCouldn't establish TLS session)�HAVE_SSLrArOrCrw�ssl�_create_stdlib_contextr��wrap_socketr�rXr�r�rvr�)rW�ssl_contextr�r�r�r?r?r@�starttls)s&



�

zIMAP4.starttlscCr�)Nr3r�)rWr��namesr�r�r�r?r?r@�status@szIMAP4.statuscCs@	|d|dfdkrd|}|�d|||�\}}|�||d�S)Nrr�r�r�r4rr�)rWr��commandr�r�r�r?r?r@�storeLs
zIMAP4.storecCr�)Nr5r�r�r?r?r@�	subscribeWr�zIMAP4.subscribecGs.	d}|j|||g|�R�\}}|�|||�S)Nr6r�)rWZthreading_algorithmr�rr�r�r�r?r?r@�thread_szIMAP4.threadc	Gs�	|��}|tvr|�d|��|jt|vr'|�d||jd�t|�f��d}|j||g|�R�\}}|dvr<|}nd}|�|||�S)NzUnknown IMAP4 UID command: %s�9command %s illegal in state %s, only allowed in states %s�, r7)r,r1r6r)r�r{rArH�joinr�r�)rWrr�r�r�r�r?r?r@�uidis ��z	IMAP4.uidcCr�)Nr8r�r�r?r?r@�unsubscribe�r�zIMAP4.unsubscribecCr�)Nr9rr�)rWr�r�r?r?r@�unselect�s�zIMAP4.unselectcGs0	|��}|tvr|jft|<|j|g|�R�Sr�)r�r{rHr��rWr�r�r?r?r@�xatom�s
	zIMAP4.xatomcCs<|durd}|j}	||vr||�|�dS|g||<dS�N�)rKrGrsr�rr�)rWr�r�Zurr?r?r@�_append_untagged�szIMAP4._append_untaggedcCs,|j�d�}|r|�|d�|jd���dS)N�BYEr�r�)rKrrCr�r^)rW�byer?r?r@�
_check_bye�s�zIMAP4._check_byec

Gs�|jt|vrd|_|�d||jd�t|�f��dD]}||jvr'|j|=qd|jvr5|js5|�d��|��}t	||j
�}|d|}|D]}|durNqGt|t�rYt	||j
�}|d|}qG|j}|dur�d|_t
|�t
|j�urv|}nd}|t	dt|�|j
�}	z	|�|t�Wnty�}	z|�d|	��d}	~	ww|dur�|S	|��r�|j|r�|S|��s�|r�||j�}	z|�|�|�t�Wnty�}	z|�d|	��d}	~	ww|s�	|Sq�)Nrr�rk�NO�BADr�z#mailbox status changed to READ-ONLY� z {%s}F�z> %rzsocket error: %s)rHr{rIrArrKrMrD�_new_tag�bytesr^r�r��type�_commandr�rGrs�_logr�r�rUrCrurJrL)
rWr�r�r��tagr��argrIZ	literator�valr?r?r@r+�st��
�
�


��
�

���zIMAP4._commandc
Cs�|dk}|s
|��z|j||d�\}}Wn+|jy+}z	|�d||f��d}~w|jy@}z	|�d||f��d}~ww|sG|��|dkrU|�d|||f��||fS)Nr)�
expect_byezcommand: %s => %sr%z%s command error: %s %s)r"�_get_tagged_responserCrA)rWr�r-r�r�r�r/r?r?r@�_command_completes"���zIMAP4._command_completecCsJ|��\}}|dgkr|�d��t|d|j�}|��}t|���|_dS)Nz"no CAPABILITY response from serverr�)r�rAr�r^r��tuple�splitrwr�r?r?r@rv#s

zIMAP4._get_capabilitiescCs�|��}|�|j|�r8|j�d�}||jvr|�d|��|j�d�}t||j�}|j�d�}||gf|j|<n~d}|�t	|�sM|�|j
|�rM|j�d�}|jdurh|�t|�ra|j�d�|_dS|�d|��|j�d�}t||j�}|j�d�}|dur�d}|r�|d|}|�|j
|�r�t|j�d	��}	|�|�}|�|||f�|��}|�|j
|�s�|�||�|d
vr�|�t|�r�|j�d�}t||j�}|�||j�d��	|S)Nr-zunexpected tagged response: %rr*r�Zdata2zunexpected response: %rrr&r�Fr'zread literal size %sr#)�	_get_line�_matchro�mo�grouprJrCr�r^�Untagged_responsere�ContinuationrLrc�intrGrsr�r�
Response_code)rW�respr-r�r�Zdat2r�r�r?r?r@ru,sJ


�zIMAP4._get_responsec
Cs|	|j|}|dur|j|=|S|r#d}|j�|d�}|dur#||fS|��z|��Wn|jy<}z	�d}~wwq)Nrjr )rJrK�popr"rurCrG�	print_log)rWr-r0�resultr�r!r/r?r?r@r1|s&
���zIMAP4._get_tagged_responsecCs@|��}|s|�d��|�d�s|�d|��|dd�}	|S)Nzsocket error: EOFrz#socket error: unterminated line: %r���)r�rC�endswithrGrsr,r�r?r?r@r5�s

zIMAP4._get_linecCs|�|�|_	|jduSr�)�matchr7rGrsr��groups)rWZcre�sr?r?r@r6�s
zIMAP4._matchcCs2|jtt|j�|j�}|jd|_d|j|<|S)Nrj)rnr)r�rNr^rJ)rWr-r?r?r@r(�s
zIMAP4._new_tagcCs$|�dd�}|�dd�}d|dS)N�\z\\�"z\")r�)rWr.r?r?r@r��szIMAP4._quotecGs|�||j|g|�R��Sr�)r2r+rr?r?r@r��szIMAP4._simple_commandcCs:|dkr||fS||jvr|dgfS|j�|�}	||fS)Nr$)rKr>rGrs)rWr�r�r�r�r?r?r@r��s

zIMAP4._untagged_responsecCsN|durt��}t�dt�|��}tj�d||dd|f�tj��dS)Nz%M:%Sz
  %s.%02d %s
�d)�time�strftime�	localtimer��stderr�write�flush)rWrEZsecsZtmr?r?r@rs�s
zIMAP4._mesgcCs2|sdSdd�|��D�}|�dd�|��dS)Ncss"�|]\}}|�d|��VqdS)z: Nr?)�.0�key�valuer?r?r@�	<genexpr>�s��z!IMAP4._dump_ur.<locals>.<genexpr>zuntagged responses dump:z
		)�itemsrsr)rWZuntagged_resp_dictrSr?r?r@r��s�zIMAP4._dump_urcCs<|t��f|j|j<|jd7_|j|jkrd|_dSdS)Nrjr)rIrrrqrpr�r?r?r@r,�s

�z
IMAP4._logcCsn|�dt|j��|j|j}}|r5z
|j|j|�WnY|d7}||jkr-d}|d8}|sdSdS)Nzlast %d IMAP4 interactions:rjr)rsr�rrrqrp)rW�i�nr?r?r@r?�s
�zIMAP4.print_log)r�r�)r�Fr�)F)Tr<r=r>rSrArCrD�
IMAP4_PORTr[rPrhrRr�r�r�r�rQr�r�r�rTr�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�rrrrrrrrrrrrrrrr"r+r2rvrur1r5r6r(r�r�r�rsr�r,r?r?r?r?r@r�s�/*

		
	




 	

M	
P!rc@s<eZdZ	deddddfdd�Zdd�Zdedfdd�ZdS)	�	IMAP4_SSLrENcCs�|dur|durtd��|dur|durtd��|dus |dur+ddl}|�dtd�||_||_|dur<tj||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�DeprecationWarningrZrYr
rr
rr[)rWrXrYrZrYr
rZr[r?r?r@r[s"��zIMAP4_SSL.__init__cCst�||�}|jj||jd�S)Nr)rr�r
rrX)rWrZr�r?r?r@r�-s�zIMAP4_SSL._create_socketcCs	t�||||�dSr�)rrQrVr?r?r@rQ2szIMAP4_SSL.open)r<r=r>�IMAP4_SSL_PORTr[r�rQr?r?r?r@rWs
�rWc@s@eZdZ	dd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)rcCs||_t�|�dSr�)rrr[)rWrr?r?r@r[IszIMAP4_stream.__init__NcCsP	d|_d|_d|_d|_tj|jttjtjddd�|_	|j	j
|_|j	j|_
dS)NT)�bufsize�stdin�stdout�shellZ	close_fds)rXrYr�r��
subprocess�Popenrr�PIPEr�r`�	writefilera�readfilerVr?r?r@rQNs�
zIMAP4_stream.opencCr�r�)rgr�r�r?r?r@r�^r�zIMAP4_stream.readcCs	|j��Sr�)rgr�rfr?r?r@r�cs
zIMAP4_stream.readlinecCs	|j�|�|j��dSr�)rfrMrNr�r?r?r@r�hszIMAP4_stream.sendcCs$	|j��|j��|j��dSr�)rgr�rfr��waitrfr?r?r@rTns

zIMAP4_stream.shutdown)NNN)	r<r=r>r[rQr�r�r�rTr?r?r?r@r=s

rc@s.eZdZ	dd�Zdd�Zdd�Zdd�Zd	S)
r�cCs
||_dSr�)r�)rWZmechinstr?r?r@r[|s
z_Authenticator.__init__cCs&|�|�|��}|durdS|�|�S)N�*)r�r�r�)rWr�Zretr?r?r@r�s
z_Authenticator.processcCspd}t|t�r|�d�}|r6t|�dkr!|dd�}|dd�}n|}d}t�|�}|r4||dd�}|s|S)Nrrg�0r�)r�r�r�r��binasciiZ
b2a_base64)rW�inpZoup�t�er?r?r@r��s	


�
z_Authenticator.encodecCs|sdSt�|�Sr)rkZ
a2b_base64)rWrlr?r?r@r��s
z_Authenticator.decodeN)r<r=r>r[r�r�r�r?r?r?r@r�vsr�z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr�cCsi|]\}}|��|d�qS)rj)r�)rOrUrEr?r?r@�
<dictcomp>�srorjc	Cs�	t�|�}|s
dSt|�d�}|�d�}t|�d��}t|�d��}t|�d��}t|�d��}t|�d��}t|�d��}	t|�d	��}
|	d
|
d
}|dkrV|}||||||dddf	}t�|�|}
t�|
�S)
N�mon�zonen�day�year�hour�min�sec�zoneh�zonem�<�-r�)	�InternalDaterC�Mon2numr8r;�calendarZtimegmrIrK)r=r7rprqrrrsrtrurvrwrxZzoneZtt�utcr?r?r@r�s&


rcCsD	d}d}tt|��}|r t|d�\}}|||d�|}|s
|S)NrsABCDEFGHIJKLMNOP�rj)r;�abs�divmod)Znumr/ZAP�modr?r?r@r	�s�r	cCs&	t�|�}|s
dSt|�d����S)Nr?r�)�FlagsrCr3r8r4)r=r7r?r?r@r
�s

r
cCs	t|ttf�rt�|tj���}npt|t�r\z|j	}Wn,t
yHtjrB|d}|dkr8t�
t�|��d}tjtjf|}ntj}Ynwt|d�}t|dd�dt|�i�}n&t|t�rm|jdurjtd��|}nt|t�r~|d|dfdkr~|Std	��d
�t|j�}|�|�S)N�r�)Zseconds��tzinfozdate_time must be awarer)rGrGzdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")r�r;�floatrZ
fromtimestamprr~Z
astimezoner3�	tm_gmtoffr~rI�daylightrK�mktime�altzonerr�r�r��format�MonthsZmonthrJ)r�ZdtZgmtoffZdstZdeltaZfmtr?r?r@r�s<
��

��



r�__main__zd:s:)r?r?z-dz-s)rEzIMAP 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�)r�z/tmp/yyy)r��
/tmp/yyz 2r�r�)r�)z/tmpzyy*)rr�)r�)NZSUBJECT�test)r�)�1z(FLAGS INTERNALDATE RFC822))r)r��FLAGSz
(\Deleted))r�r?)r�r?)r�r?)r�r?)rr?)r�)ZUIDVALIDITY)r)r,ZALL)r�)r)r�r?cCsLt�d||f�tt|�|�\}}t�d|||f�|dkr$|d�|S)Nz%s %sz%s => %s %sr$r)�Mrsr|)�cmdr�r�r�r?r?r@�runAs
r�rzPROTOCOL_VERSION = %szCAPABILITIES = %rr�)z/tmp/zyy%z.*"([^"]+)"$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
)Trtrkr�rmr_r�rcr�rIr}rrr�iorr
r	�ImportError�__all__r�rFrVr^rxr�r{r`r:r�r{rbrcr�r<r9rerardrrWr�rr�r4r��	enumerater|rr	r
rr<ZgetoptZgetpass�argvZoptlistr�rAr/Zstream_command�optr;rXZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2r�r�rHrsryrwr�ZmlrCr7r8�pathr�r�printr?r?r?r@�<module>s�H�	�������	�
���
������������������� �!�"�#�$�
0



	
�
69
,#

)��

�

��




���