U e5dfÑã*@sšdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z ddl mZzddlZdZWnek r”dZYnXddd d d d 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&er¤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/kr–ddl4Z4ddl5Z5ze4 4ej6d*d…d0¡\Z7Z8Wn.e4j9k rlZ:z d1\Z7Z8W5dZ:[:XYnXdZ;e7D]8\Ze5 ?¡Z@e5 5d5e@e>pÚd6f¡ZAd7e@d8d9œZBd:e@eAffd;dd?ddeBffd@dAdBdCdDdEdFdGdHfZCdIdJdKdLd>dddeBffdGdMfZDdNdO„ZEze;r^e)e;ƒZFne&e>ƒZFeFjGdPkr~eCd*d…ZCeF HdQeFjI¡eF HdReFjJf¡eCD]\ZKZ8eEeKe8ƒq¤eEdSdTƒD].*))?s.*FLAGS \((?P[^\)]*)\)sÕ.*INTERNALDATE "(?P[ 0123][0-9])-(?P[A-Z][a-z][a-z])-(?P[0-9][0-9][0-9][0-9]) (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9]) (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])"s.*{(?P\d+)}$s \r\n|\r|\ns%\[(?P[A-Z-]+)( (?P.*))?\]s$\* (?P[A-Z-]+)( (?P.*))?s3\* (?P\d+) (?P[A-Z-]+)( (?P.*))?c@sŠeZdZGdd„deƒZGdd„deƒZGdd„deƒZdefdd „Zd d „Z d d „Z dd„Z dd„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!dd?„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„Z4ddfdg„Z5dhdi„Z6djdk„Z7dldm„Z8dndo„Z9dždqdr„Z:dsdt„Z;dudv„Zd{d|„Z?d}d~„Z@dd€„ZAdd‚„ZBdƒd„„ZCd…d†„ZDd‡dˆ„ZEd‰dŠ„ZFd‹dŒ„ZGdŸddŽ„ZHdd„ZId‘d’„ZJd“d”„ZKd•d–„ZLd—d˜„ZMd™dš„ZNdpS) rc@s eZdZdS)z IMAP4.errorN©Ú__name__Ú __module__Ú __qualname__©r=r=ú/usr/lib64/python3.8/imaplib.pyÚerror´sr?c@s eZdZdS)z IMAP4.abortNr9r=r=r=r>Úabortµsr@c@s eZdZdS)zIMAP4.readonlyNr9r=r=r=r>Úreadonly¶srAÚc Cs”t|_d|_d|_i|_i|_d|_d|_d|_d|_ |  ¡|  ||¡z |  ¡Wn8t k rŽz | ¡Wntk r†YnX‚YnXdS)NrrBFr)Ú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©rTr=r=r>rMÑszIMAP4._mode_asciicCs(d|_d|_t t¡|_t t¡|_dS)NTúutf-8)rYrZr[r\r]r_r`rarbr=r=r>Ú _mode_utf8Øs zIMAP4._mode_utf8cCsœtt dd¡ƒ|_t d|jdtj¡|_|  ¡|_ d|j krHd|_ nd|j krZd|_ n |  |j ¡‚| ¡tD]}||jkr‚qr||_dS|  d ¡‚dS) Niiÿÿs(?Ps"\d+) (?P[A-Z]+) (?P.*)ZPREAUTHrÚOKrzserver not IMAP4 compliant)r ÚrandomZrandintÚtagprer[r\r^ÚtagreÚ __version__Ú _get_responseZwelcomerHrEr?Ú_get_capabilitiesÚAllowedVersionsÚ capabilitiesÚPROTOCOL_VERSION)rTÚversionr=r=r>rOßs*ÿþþ     zIMAP4._connectcCs&|tkrt|| ¡ƒStd|ƒ‚dS)NzUnknown IMAP4 command: '%s')ÚCommandsÚgetattrÚlowerÚAttributeError)rTÚattrr=r=r>Ú __getattr__ szIMAP4.__getattr__cCs|S©Nr=rbr=r=r>Ú __enter__szIMAP4.__enter__cGs4|jdkrdSz | ¡Wntk r.YnXdS©Nr)rEÚlogoutrR)rTÚargsr=r=r>Ú__exit__s   zIMAP4.__exit__cCs4|js dn|j}t d||j|j¡t ||jf¡S)Nz imaplib.open)rUÚsysÚauditrVÚsocketZcreate_connection)rTrUr=r=r>Ú_create_socketszIMAP4._create_socketcCs(||_||_| ¡|_|j d¡|_dS)NÚrb)rUrVrÚsockÚmakefileÚfilerSr=r=r>rN's z IMAP4.opencCs |j |¡Srv)rƒÚread©rTÚsizer=r=r>r„3sz IMAP4.readcCs.|j td¡}t|ƒtkr*| dt¡‚|S)Nézgot more than %d bytes)rƒÚreadlineÚ_MAXLINEÚlenr?©rTÚliner=r=r>rˆ8s zIMAP4.readlinecCst d||¡|j |¡dS)Nz imaplib.send)r|r}rZsendall©rTÚdatar=r=r>Úsend@sz IMAP4.sendc Cst|j ¡zXz|j tj¡Wn@tk r^}z"|jtjkrNt |ddƒdkrN‚W5d}~XYnXW5|j ¡XdS)NZwinerrorri&') rƒÚcloserrQr~Z SHUT_RDWRrRÚerrnoZENOTCONNrq)rTÚexcr=r=r>rQFs  ÿzIMAP4.shutdowncCs|jSrv)rrbr=r=r>r~Vsz IMAP4.socketcCsBd}| ddg|¡\}}|dr(||fS| ¡\}}| |||¡S)NZRECENTreéÿÿÿÿ)Ú_untagged_responseÚnoop©rTÚnameÚtypÚdatr=r=r>Úrecentbs  z IMAP4.recentcCs| |dg| ¡¡Srv)r”Úupper)rTÚcoder=r=r>ÚresponsesszIMAP4.responsecCsxd}|s d}|r.|d|dfdkr2d|}nd}|r@t|ƒ}nd}t t|¡}|jrbd|d}||_| ||||¡S) NrÚINBOXrr“©ú(ú)ú(%s)sUTF8 (ó))r ÚMapCRLFÚsubÚCRLFrYrFÚ_simple_command)rTÚmailboxÚflagsÚ date_timeÚmessager—rFr=r=r>Úappends    z IMAP4.appendcCsP| ¡}t|ƒj|_| d|¡\}}|dkrB| |d dd¡¡‚d|_||fS)Nrrer“rcÚreplacer)r›Ú_AuthenticatorÚprocessrFr§r?ÚdecoderE)rTZ 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§rbr=r=r>ÚcheckÁsz IMAP4.checkcCs$z| d¡\}}W5d|_X||fS)Nrr)rEr§©rTr˜r™r=r=r>rÉsz IMAP4.closecCs| d||¡S)Nrrµ)rTÚ message_setZ new_mailboxr=r=r>ÚcopyØsz IMAP4.copycCs | d|¡S)Nrrµ©rTr¨r=r=r>Úcreateàsz IMAP4.createcCs | d|¡S)Nrrµrºr=r=r>Údeleteèsz IMAP4.deletecCs| d||¡S)Nrrµ)rTr¨Úwhor=r=r>Ú deleteaclïszIMAP4.deleteaclcCsHd|jkrt d¡‚| d|¡\}}|dkr@d| ¡kr@| ¡||fS)NrzServer does not support ENABLErez UTF8=ACCEPT)rmrr?r§r›rd)rTr´r˜rŽr=r=r>Úenableös   z IMAP4.enablecCs d}| |¡\}}| |||¡S)Nrr³r–r=r=r>Úexpunges z IMAP4.expungecCs$d}| |||¡\}}| |||¡S)Nrr³)rTr¸Z message_partsr—r˜r™r=r=r>Úfetchs z IMAP4.fetchcCs| d|¡\}}| ||d¡S)NrZACLr³©rTr¨r˜r™r=r=r>Úgetaclsz IMAP4.getaclcCs"| d|||¡\}}| ||d¡S)Nr Ú ANNOTATIONr³)rTr¨ÚentryZ attributer˜r™r=r=r>Ú getannotation(szIMAP4.getannotationcCs| d|¡\}}| ||d¡S)Nr!ÚQUOTAr³)rTÚrootr˜r™r=r=r>Úgetquota0szIMAP4.getquotacCs@| d|¡\}}| ||d¡\}}| ||d¡\}}|||gfS)Nr"rÇZ QUOTAROOTr³)rTr¨r˜r™ZquotaZ quotarootr=r=r>Ú getquotaroot;szIMAP4.getquotarootú""Ú*cCs$d}| |||¡\}}| |||¡S)Nr$r³©rTZ directoryÚpatternr—r˜r™r=r=r>ÚlistFsz IMAP4.listcCs<| d|| |¡¡\}}|dkr.| |d¡‚d|_||fS)Nr%rer“r)r§Ú_quoter?rE)rTÚuserÚpasswordr˜r™r=r=r>ÚloginRs z IMAP4.logincCs|||_|_| d|j¡S)NzCRAM-MD5)rÑrÒr²Ú_CRAM_MD5_AUTH)rTrÑrÒr=r=r>Úlogin_cram_md5`szIMAP4.login_cram_md5cCsBddl}t|jtƒr |j d¡n|j}|jd| ||d¡ ¡S)Nrrcú Zmd5)ÚhmacÚ isinstancerÒÚstrÚencoderÑZHMACZ hexdigest)rTZ challenger×Úpwdr=r=r>rÔis ÿzIMAP4._CRAM_MD5_AUTHcCs$d|_| d¡\}}| ¡||fSrx)rEr§rQr·r=r=r>ryqsz 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µrbr=r=r>r•›sz IMAP4.noopcCs(d}| |||||¡\}}| ||d¡S)Nr)rr³)rTZ message_numZ message_partÚstartZlengthr—r˜r™r=r=r>Úpartial¦sz IMAP4.partialcCsd}| d|¡S)Nr*rµ)rTrÑr—r=r=r>Ú proxyauth²s zIMAP4.proxyauthcCs| d||¡S)Nr+rµ)rTZ 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)rYrr?r§r”)rTÚ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-rerrú READ-ONLYz%s is not writableÚEXISTS)rHrJr§rErAÚget)rTr¨rAr—r˜r™r=r=r>ÚselectÙs  ÿz IMAP4.selectcCs| d|||¡S)Nr.rµ)rTr¨r½Zwhatr=r=r>Úsetaclùsz IMAP4.setaclcGs |jd|žŽ\}}| ||d¡S)Nr/rÄ)r/r³)rTrzr˜r™r=r=r>Ú setannotationszIMAP4.setannotationcCs | d||¡\}}| ||d¡S)Nr0rÇr³)rTrÈZlimitsr˜r™r=r=r>Úsetquota szIMAP4.setquotacGsFd}|d|dfdkr d|}|j|||f|žŽ\}}| |||¡S)Nr1rr“rŸr¢r³)rTZ 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) Nr2zSSL support missingzTLS session already establishedzTLS not supported by serverre©Zserver_hostnamer€TzCouldn't establish TLS session)ÚHAVE_SSLr?rLr@rmÚsslÚ_create_stdlib_contextr§Ú wrap_socketrrUr‚rƒrkr”)rTÚ ssl_contextr—r˜r™r=r=r>Ústarttls s&    ÿ  zIMAP4.starttlscCs$d}| |||¡\}}| |||¡S)Nr3r³)rTr¨Únamesr—r˜r™r=r=r>Ústatus7sz IMAP4.statuscCs>|d|dfdkrd|}| d|||¡\}}| ||d¡S)Nrr“rŸr¢r4rr³)rTr¸Úcommandr©r˜r™r=r=r>ÚstoreCsz IMAP4.storecCs | d|¡S)Nr5rµrºr=r=r>Ú subscribeNszIMAP4.subscribecGs*d}|j|||f|žŽ\}}| |||¡S)Nr6r³)rTZthreading_algorithmrärír—r˜r™r=r=r>ÚthreadVsz IMAP4.threadc Gs†| ¡}|tkr| d|¡‚|jt|krL| d||jd t|¡f¡‚d}|j||f|žŽ\}}|dkrt|}nd}| |||¡S)NzUnknown IMAP4 UID command: %sú9command %s illegal in state %s, only allowed in states %sú, r7)r,r1r6r)r›rpr?rEÚjoinr§r”)rTrørzr—r˜r™r=r=r>Úuid`s ÿþz IMAP4.uidcCs | d|¡S)Nr8rµrºr=r=r>Ú unsubscribeyszIMAP4.unsubscribecGs,| ¡}|tkr|jft|<|j|f|žŽSrv)r›rprEr§©rTr—rzr=r=r>Úxatoms  z IMAP4.xatomcCs8|dkr d}|j}||kr*|| |¡n |g||<dS©Nó)rHrŠr¬)rTr˜r™Zurr=r=r>Ú_append_untagged—s zIMAP4._append_untaggedcCs,|j d¡}|r(| |d |jd¡¡‚dS)NÚBYEr“r­)rHrèr@r°rZ)rTÚbyer=r=r>Ú _check_bye¥s zIMAP4._check_byec Gsê|jt|kr4d|_| d||jd t|¡f¡‚dD]}||jkr8|j|=q8d|jkrj|jsj| d¡‚| ¡}t ||j ƒ}|d|}|D]0}|dkrœqŽt |t ƒr²t ||j ƒ}|d|}qŽ|j}|dk r d|_t |ƒt |jƒkrî|}nd}|t dt|ƒ|j ƒ}z| |t¡Wn2tk rN} z| d| ¡‚W5d} ~ XYnX|dkr^|S| ¡r||j|r^|Sq^|rŒ||jƒ}z| |¡| t¡Wn2tk rÖ} z| d| ¡‚W5d} ~ XYnX|s^qæq^|S) Nrürý©reÚNOÚBADræz#mailbox status changed to READ-ONLYó z {%s}zsocket error: %s)rErprFr?rþrHrJrAÚ_new_tagÚbytesrZrØrÙÚtypeÚ_commandrŠrr¦rRr@rjrGrI) rTr—rzr˜ÚtagrŽÚargrFZ literatorÚvalr=r=r>r«sb ÿþ   ÿ             zIMAP4._commandc CsÆ|dk}|s| ¡z|j||d\}}Wnj|jk r`}z| d||f¡‚W5d}~XYn6|jk r”}z| d||f¡‚W5d}~XYnX|s¢| ¡|dkr¾| d|||f¡‚||fS)Nr)Ú expect_byezcommand: %s => %sr z%s command error: %s %s)rÚ_get_tagged_responser@r?)rTr—rryr˜rŽrr=r=r>Ú_command_completeøs"$zIMAP4._command_completecCsJ| ¡\}}|dgkr | d¡‚t|d|jƒ}| ¡}t| ¡ƒ|_dS)Nz"no CAPABILITY response from serverr“)r´r?rÙrZr›ÚtupleÚsplitrmr·r=r=r>rk s    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¡}|dkrd}|r|d|}| |j |¡rZt|j d ¡ƒ}| |¡}| |||f¡| ¡}q| ||¡|d krª| t|¡rª|j d¡}t||jƒ}| ||j d¡¡|S) Nrzunexpected tagged response: %rrrŽZdata2zunexpected response: %rrr r†r )Ú _get_lineÚ_matchrhÚmoÚgrouprGr@rÙrZÚUntagged_responseraÚ ContinuationrIr_Úintr„rÚ Response_code)rTÚresprr˜r™Zdat2r†rŽr=r=r>rjsH                   zIMAP4._get_responsec Cs†|j|}|dk r|j|=|S|rDd}|j |d¡}|dk rD||fS| ¡z | ¡Wq|jk r~}z‚W5d}~XYqXqdS)Nr)rGrHÚpoprrjr@)rTrrÚresultr˜rrr=r=r>rcs  zIMAP4._get_tagged_responsecCs>| ¡}|s| d¡‚| d¡s.| d|¡‚|dd…}|S)Nzsocket error: EOFr z#socket error: unterminated line: %réþÿÿÿ)rˆr@Úendswithr‹r=r=r>r„s   zIMAP4._get_linecCs| |¡|_|jdk Srv)Úmatchr)rTZcreÚsr=r=r>r—s z IMAP4._matchcCs2|jtt|jƒ|jƒ}|jd|_d|j|<|S)Nr‡)rgrrÙrKrZrG)rTrr=r=r>r £s  zIMAP4._new_tagcCs$| dd¡}| dd¡}d|dS)Nú\z\\ú"z\")r­)rTrr=r=r>rЫs  z IMAP4._quotecGs| ||j|f|žŽ¡Srv)rrrr=r=r>r§³szIMAP4._simple_commandcCs8|dkr||fS||jkr$|dgfS|j |¡}||fS)Nr )rHr")rTr˜r™r—rŽr=r=r>r”¸s    zIMAP4._untagged_response)rËrÌ)rËrÌ)ržF)N)F)Sr:r;r<rPr?r@rAÚ IMAP4_PORTrWrMrdrOrurwr{rrNr„rˆrrQr~ršrr¬r²r´r¶rr¹r»r¼r¾r¿rÀrÁrÃrÆrÉrÊrÏrÓrÕrÔryrÜrÝrÞr•ràrárârårérêrërìrîrõr÷rùrúrûrÿrrrrrrrkrjrrrr rÐr§r”Ú_mesgZ_dump_urZ_logZ print_logr=r=r=r>r†s–.*                    M P ! $c@s6eZdZdedddfdd„Zdd„Zdefdd„ZdS) Ú IMAP4_SSLrBNcCs|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 insteadé)ÚcertfileÚkeyfile) Ú ValueErrorÚwarningsÚwarnÚDeprecationWarningr/r.rñròrôrrW)rTrUrVr/r.rôr1r=r=r>rWÿs$ÿÿzIMAP4_SSL.__init__cCst |¡}|jj||jdS)Nrï)rrrôrórU)rTrr=r=r>rs ÿzIMAP4_SSL._create_socketcCst |||¡dSrv)rrNrSr=r=r>rNszIMAP4_SSL.open)r:r;r<ÚIMAP4_SSL_PORTrWrrNr=r=r=r>r,ìs ÿ r,c@s>eZdZdd„Zddd„Zdd„Zdd „Zd d „Zd d „ZdS)rcCs||_t |¡dSrv)rørrW)rTrør=r=r>rW/szIMAP4_stream.__init__NcCsNd|_d|_d|_d|_tj|jttjtjddd|_ |j j |_ |j j |_ dS)NT)ÚbufsizeÚstdinÚstdoutÚshellZ close_fds)rUrVrrƒÚ subprocessÚPopenrørÚPIPEr¯r6Ú writefiler7ÚreadfilerSr=r=r>rN4sý zIMAP4_stream.opencCs |j |¡Srv)r=r„r…r=r=r>r„DszIMAP4_stream.readcCs |j ¡Srv)r=rˆrbr=r=r>rˆIszIMAP4_stream.readlinecCs|j |¡|j ¡dSrv)r<ÚwriteÚflushrr=r=r>rNs zIMAP4_stream.sendcCs"|j ¡|j ¡|j ¡dSrv)r=rr<r¯Úwaitrbr=r=r>rQTs  zIMAP4_stream.shutdown)NN) r:r;r<rWrNr„rˆrrQr=r=r=r>r#s   c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) r®cCs ||_dSrv)r±)rTZmechinstr=r=r>rWbsz_Authenticator.__init__cCs&| | |¡¡}|dkrdS| |¡S)Nó*)r±r°rÚ)rTrŽZretr=r=r>r¯esz_Authenticator.processcCsnd}t|tƒr| d¡}|rjt|ƒdkrB|dd…}|dd…}n|}d}t |¡}|r||dd…}q|S)Nrrcé0r“)rØrÙrÚrŠÚbinasciiZ b2a_base64)rTÚinpZoupÚtÚer=r=r>rÚks      z_Authenticator.encodecCs|sdSt |¡Sr)rCZ a2b_base64)rTrDr=r=r>r°ƒsz_Authenticator.decodeN)r:r;r<rWr¯rÚr°r=r=r=r>r®\sr®z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov DecrÖcCsi|]\}}| ¡|d“qS)r‡)rÚ)Ú.0Únr'r=r=r>Ú ‰srIr‡c CsØt |¡}|sdSt| d¡}| d¡}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ} t| d ¡ƒ} | d | d } |d krª| } ||||||d d d f } t | ¡| } t | ¡S) NÚmonÚzonenÚdayÚyearÚhourÚminÚsecÚzonehÚzonemé<ó-r“) Ú InternalDater&ÚMon2numrrÚcalendarZtimegmÚtimeÚ localtime)r!rrJrKrLrMrNrOrPrQrRZzoneZttÚutcr=r=r>r‹s$  cCs@d}d}tt|ƒƒ}|rr ®s cCs$t |¡}|sdSt| d¡ ¡ƒS)Nr=r©)ÚFlagsr&rrr)r!rr=r=r>r »s cCst|ttfƒr"t |tj¡ ¡}nât|tƒr¸z |j }WnZt k rt j r„|d}|dkrpt   t  |¡¡d}t jt jf| }nt j }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)r)r)zdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")rØrÚfloatrZ fromtimestamprrZZ astimezonerÚ tm_gmtoffrsrXÚdaylightrYÚmktimeÚaltzonerrbr0rÙÚformatÚMonthsZmonthÚstrftime)rªZdtZgmtoffZdstZdeltaZfmtr=r=r>r Æs2 ÿ      Ú__main__zd:s:)r=r=z-dz-s)rBzIMAP 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â)rmz/tmp/yyy)r©ú /tmp/yyz 2r¬ro)rÏ)z/tmpzyy*)rérn)rå)NZSUBJECTZtest)rÁ)Ú1z(FLAGS INTERNALDATE RFC822))rù)rpÚFLAGSz (\Deleted))rÞr=)rÀr=)ršr=)rr=)rér=)r)Z UIDVALIDITY)rÿ)r,ZALL)r)rç)ryr=cCsLt d||f¡tt|ƒ|Ž\}}t d|||f¡|dkrH|d‚|S)Nz%s %sz %s => %s %sr r)ÚMr+rq)Úcmdrzr˜r™r=r=r>Úrun's rtrzPROTOCOL_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 )TrirCr‘rfr[r~r9r|rXrWrrrÚiorrñrðÚ ImportErrorÚ__all__r¦rCr*r4rlr‰rpr\rr_rUr^r_r¤r rrar]r`rr,r¬rr®rriÚ enumeraterVrr r r r:ZgetoptZgetpassÚargvZoptlistrzr?rZstream_commandÚoptrrUZgetuserZUSERZPASSWDZ test_mesgZ test_seq1Z test_seq2rtrrrEr+rnrmrsZmlr&rrÚpathr™rÿÚprintr=r=r=r>ÚsXH  ÿ Ö/     ÿl4 9, #  )       òù           ÿ  ý