m %UIc@sdZdZdkZdkZdkZdkZdkZdkZdkZddddddd gZ d Z d Z d Z d Z ddfZhdddf<ddf<dddddf<ddf<ddf<ddf<dddf<dddf<dddf<dddf<ddf<ddf<dddf<d ddf<d!ddf<d"ddf<d#ddf<d$df<dddddf<d%ddf<d&ddf<d'ddddf<d(df<d)df<d*ddf<d+df<d,ddf<d-ddf<d.ddf<d/df<d0ddf<d1df<d2ddf<d3df<d4df<d5ddfYZdefd?YZdefd@YZdAfdBYZhdCdD<dEdF<dGdH<dIdJ<dKdL<dMdN<dOdP<dQdR<dSdT<dUdV<dWdX<dYdZe>oe>i?dDZ@ne<iAdZ@e5de@fqWxe4D]~\Z;Z'e5e;e'ZBe;e'fdd+dffjoq_neBdiAZCeC oq_ne5dddeCddfq_WdGHWn+dGHe odei%d GHnnXndS(sIMAP4 client. Based on RFC 2060. Public class: IMAP4 Public variable: Debug Public functions: Internaldate2tuple Int2AP ParseFlags Time2Internaldate s2.55NtIMAP4t IMAP4_SSLt IMAP4_streamtInternaldate2tupletInt2APt ParseFlagstTime2Internaldates iiit IMAP4REV1tAPPENDtAUTHtSELECTEDt AUTHENTICATEtNONAUTHt CAPABILITYtLOGOUTtCHECKtCLOSEtCOPYtCREATEtDELETEt DELETEACLtEXAMINEtEXPUNGEtFETCHtGETACLtGETQUOTAt GETQUOTAROOTtMYRIGHTStLISTtLOGINtLSUBt NAMESPACEtNOOPtPARTIALt PROXYAUTHtRENAMEtSEARCHtSELECTtSETACLtSETQUOTAtSORTtSTATUStSTOREt SUBSCRIBEtTHREADtUIDt UNSUBSCRIBEs\+( (?P.*))?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.*))?cBstZdZdefdYZdefdYZdefdYZeidZ de d Z d Z de d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d d!d"Z"d#Z#d$Z$d%Z%d&Z&d d!d'Z'd(Z(d)Z)d*Z*d+Z+d,Z,d-Z-d.Z.d/e/d0Z0d1Z1d2Z2d3Z3d4Z4d5Z5d6Z6d7Z7d8Z8d9Z9d:Z:d;Z;d<Z<d=Z=d>Z>d?Z?d@Z@dAZAdBZBdCZCdDZDdEZEdFZFdGZGRS(HsIMAP4 client class. Instantiate with: IMAP4([host[, port]]) host - host's name (default: localhost); port - port number (default: standard IMAP4 port). All IMAP4rev1 commands are supported by methods of the same name (in lower-case). All arguments to commands are converted to strings, except for AUTHENTICATE, and the last argument to APPEND which is passed as an IMAP4 literal. If necessary (the string contains any non-printing characters or white-space and isn't enclosed with either parentheses or double quotes) each string is quoted. However, the 'password' argument to the LOGIN command is always quoted. If you want to avoid having an argument string quoted (eg: the 'flags' argument to STORE) then enclose the string in parentheses (eg: "(\Deleted)"). Each command returns a tuple: (type, [data, ...]) where 'type' is usually 'OK' or 'NO', and 'data' is either the text from the tagged response, or untagged results from command. Each 'data' is either a string, or a tuple. If a tuple, then the first part is the header of the response, and the second part contains the data (ie: 'literal' value). Errors raise the exception class .error(""). IMAP4 server errors raise .abort(""), which is a sub-class of 'error'. Mailbox status changes from READ-WRITE to READ-ONLY raise the exception class .readonly(""), which is a sub-class of 'abort'. "error" exceptions imply a program error. "abort" exceptions imply the connection should be reset, and the command re-tried. "readonly" exceptions imply the command should be re-tried. Note: to use this module, you must read the RFCs pertaining to the IMAP4 protocol, as the semantics of the arguments to each IMAP4 command are left to the invoker, not to mention the results. terrorcBstZRS(N(t__name__t __module__(((t$/data/zmath/lib/python2.4/imaplib.pyR/stabortcBstZRS(N(R0R1(((R2R3streadonlycBstZRS(N(R0R1(((R2R4ss[^\w!#$%&'*+,.:;<=>?^`|~-]tcCst|_d|_d|_h|_h|_d|_d|_ d|_ |i ||ttidd|_tid|id|_|i|_d|ijo d|_n0d |ijo d |_n|i|id }|i|||ijo|id nt|i|d ii|_x2tD]*}||ijoqNn||_ dSqNW|iddS(NRR5ii|s(?Ps"\d+) (?P[A-Z]+) (?P.*)tPREAUTHR tOKR R s"no CAPABILITY response from serverisserver not IMAP4 compliant(!tDebugtselftdebugtstatetNonetliteralttagged_commandstuntagged_responsestcontinuation_responset is_readonlyttagnumtopenthosttportRtrandomtrandintttagpretretcompilettagret _get_responsetwelcomeR/tcapt_simple_commandttupletuppertsplitt capabilitiestAllowedVersionstversiontPROTOCOL_VERSION(R9RDRERNRU((R2t__init__s>           & cCs8|tjot||iSntd|dS(NsUnknown IMAP4 command: '%s'(tattrtCommandstgetattrR9tlowertAttributeError(R9RX((R2t __getattr__s cCs\||_||_tititi|_|ii||f|iid|_ dS(sSetup connection to remote server on "host:port" (default: localhost:standard IMAP4 port). This connection will be used by the routines: read, readline, send, shutdown. trbN( RDR9REtsockettAF_INETt SOCK_STREAMtsocktconnecttmakefiletfile(R9RDRE((R2RCs   cCs|ii|S(sRead 'size' bytes from remote.N(R9Retreadtsize(R9Rg((R2RfscCs |iiS(sRead line from remote.N(R9Retreadline(R9((R2RhscCs|ii|dS(sSend data to remote.N(R9Rbtsendalltdata(R9Rj((R2tsendscCs|ii|iidS(s Close I/O established in "open".N(R9RetcloseRb(R9((R2tshutdowns cCs|iS(sfReturn socket instance used to connect to IMAP4 server. socket = .socket() N(R9Rb(R9((R2R_scCsbd}|iddg|\}}|do||fSn|i\}}|i|||S(sReturn most recent 'RECENT' responses if any exist, else prompt server for an update using the 'NOOP' command. (typ, [data]) = .recent() 'data' is None if no new messages, else list of RECENT responses, most recent last. tRECENTR7iN(tnameR9t_untagged_responseR<ttyptdattnoop(R9RrRqRo((R2trecent s cCs|i|dg|iS(sReturn data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = .response(code) N(R9RptcodeR<RQ(R9Ru((R2tresponsescCsd}|p d}n|o-|d|dfd jod|}qQnd}|ot|}nd}tit||_ |i ||||S( sAppend message to named mailbox. (typ, [data]) = .append(mailbox, flags, date_time, message) All args except `message' can be None. RtINBOXiit(t)s(%s)N(RxRy( RotmailboxtflagsR<t date_timeRtMapCRLFtsubtCRLFtmessageR9R=RO(R9RzR{R|RRo((R2tappend(s cCsm|i}t|i|_|id|\}}|djo|i |dnd|_ ||fS(s,Authenticate command - requires response processing. 'mechanism' specifies which authentication mechanism is to be used - it must appear in .capabilities in the form AUTH=. 'authobject' must be a callable object: data = authobject(response) It will be called to process server continuation responses. It should return data that will be encoded and sent to server. It should return None if the client abort response '*' should be sent instead. R R7iR N( t mechanismRQtmecht_Authenticatort authobjecttprocessR9R=RORqRrR/R;(R9RRRRrRq((R2t authenticate?s   cCs |idS(sRCheckpoint mailbox on server. (typ, [data]) = .check() RN(R9RO(R9((R2tcheck\scCs0z|id\}}Wdd|_X||fS(sClose currently selected mailbox. Deleted messages are removed from writable mailbox. This is the recommended command before 'LOGOUT'. (typ, [data]) = .close() RNR (R9RORqRrR;(R9RrRq((R2Rlds  cCs|id||S(sCopy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = .copy(message_set, new_mailbox) RN(R9ROt message_sett new_mailbox(R9RR((R2tcopysscCs|id|S(sPCreate new mailbox. (typ, [data]) = .create(mailbox) RN(R9RORz(R9Rz((R2tcreate{scCs|id|S(sPDelete old mailbox. (typ, [data]) = .delete(mailbox) RN(R9RORz(R9Rz((R2tdeletescCs|id||S(sDelete the ACLs (remove any rights) set for who on mailbox. (typ, [data]) = .deleteacl(mailbox, who) RN(R9RORztwho(R9RzR((R2t deleteaclscCs.d}|i|\}}|i|||S(sPermanently remove deleted items from selected mailbox. Generates 'EXPUNGE' response for each deleted message. (typ, [data]) = .expunge() 'data' is list of 'EXPUNGE'd message numbers in order received. RN(RoR9RORqRrRp(R9RrRqRo((R2texpungescCs4d}|i|||\}}|i|||S(s#Fetch (parts of) messages. (typ, [data, ...]) = .fetch(message_set, message_parts) 'message_parts' should be a string of selected parts enclosed in parentheses, eg: "(UID BODY[TEXT])". 'data' are tuples of message part envelope and data. RN(RoR9RORt message_partsRqRrRp(R9RRRoRrRq((R2tfetchs cCs+|id|\}}|i||dS(sXGet the ACLs for a mailbox. (typ, [data]) = .getacl(mailbox) RtACLN(R9RORzRqRrRp(R9RzRrRq((R2tgetaclscCs+|id|\}}|i||dS(sGet the quota root's resource usage and limits. Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = .getquota(root) RtQUOTAN(R9ROtrootRqRrRp(R9RRrRq((R2tgetquotascCs^|id|\}}|i||d\}}|i||d\}}|||gfS(sGet the list of quota roots for the named mailbox. (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) RRt QUOTAROOTN(R9RORzRqRrRptquotat quotaroot(R9RzRRRrRq((R2t getquotaroots s""t*cCs4d}|i|||\}}|i|||S(sList mailbox names in directory matching pattern. (typ, [data]) = .list(directory='""', pattern='*') 'data' is list of LIST responses. RN(RoR9ROt directorytpatternRqRrRp(R9RRRoRrRq((R2tlistscCs[|id||i|\}}|djo|i|dnd|_||fS(sIdentify client using plaintext password. (typ, [data]) = .login(user, password) NB: 'password' will be quoted. RR7iR N( R9ROtusert_quotetpasswordRqRrR/R;(R9RRRrRq((R2tlogins $  cCs&|||_|_|id|iS(sr Force use of CRAM-MD5 authentication. (typ, [data]) = .login_cram_md5(user, password) sCRAM-MD5N(RRR9Rt_CRAM_MD5_AUTH(R9RR((R2tlogin_cram_md5scCs-dk}|id|i|i|iS(s1 Authobject to use with CRAM-MD5 authentication. Nt (thmacR9RtHMACRt challenget hexdigest(R9RR((R2Rs cCsd|_y|id\}}Wn%ddtid g}}nX|id|ijod|idfSn||fS(s|Shutdown connection to server. (typ, [data]) = .logout() Returns server 'BYE' response. RtNOs%s: %sitBYEN( R9R;RORqRrtsystexc_infoRmR?(R9RrRq((R2tlogouts " cCs4d}|i|||\}}|i|||S(sList 'subscribed' mailbox names in directory matching pattern. (typ, [data, ...]) = .lsub(directory='""', pattern='*') 'data' are tuples of message part envelope and data. RN(RoR9RORRRqRrRp(R9RRRoRrRq((R2tlsubscCs+|id|\}}|i||dS(sShow my ACLs for a mailbox (i.e. the rights that I have on mailbox). (typ, [data]) = .myrights(mailbox) RN(R9RORzRqRrRp(R9RzRrRq((R2tmyrightsscCs.d}|i|\}}|i|||S(sb Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) = .namespace() RN(RoR9RORqRrRp(R9RrRqRo((R2t namespacescCs |idS(sFSend NOOP command. (typ, [data]) = .noop() R N(R9RO(R9((R2Rs#scCs:d}|i|||||\}}|i ||dS(sFetch truncated part of a message. (typ, [data, ...]) = .partial(message_num, message_part, start, length) 'data' is tuple of message part envelope and data. R!RN( RoR9ROt message_numt message_parttstarttlengthRqRrRp(R9RRRRRoRrRq((R2tpartial.s!cCsd}|id|S(sAssume authentication as "user". Allows an authorised administrator to proxy into any user's mailbox. (typ, [data]) = .proxyauth(user) R"N(RoR9ROR(R9RRo((R2t proxyauth:scCs|id||S(skRename old mailbox name to new. (typ, [data]) = .rename(oldmailbox, newmailbox) R#N(R9ROt oldmailboxt newmailbox(R9RR((R2trenameGscGsZd}|o"|i|d||\}}n|i||\}}|i|||S(sSearch mailbox for matching messages. (typ, [data]) = .search(charset, criterion, ...) 'data' is space separated list of matching message numbers. R$tCHARSETN(RotcharsetR9ROtcriteriaRqRrRp(R9RRRoRrRq((R2tsearchOs "RwcCsh|_||_|d j o d}nd}|i||\}}|djod|_ ||fSnd|_ d|ijo| o|id|n||ii dd gfS( ssSelect a mailbox. Flush all untagged responses. (typ, [data]) = .select(mailbox='INBOX', readonly=None) 'data' is count of messages in mailbox ('EXISTS' response). Mandated responses are ('FLAGS', 'EXISTS', 'RECENT', 'UIDVALIDITY'), so other responses should be obtained via .response('FLAGS') etc. RR%R7R R s READ-ONLYs%s is not writabletEXISTSN( R9R?R4RAR<RoRORzRqRrR;tget(R9RzR4RoRrRq((R2tselect^s        cCs|id|||S(sZSet a mailbox acl. (typ, [data]) = .setacl(mailbox, who, what) R&N(R9RORzRtwhat(R9RzRR((R2tsetacl~scCs.|id||\}}|i||dS(siSet the quota root's resource limits. (typ, [data]) = .setquota(root, limits) R'RN(R9RORtlimitsRqRrRp(R9RRRrRq((R2tsetquotascGs`d}|d|dfdjod|}n|i||||\}}|i|||S( sIMAP4rev1 extension SORT command. (typ, [data]) = .sort(sort_criteria, charset, search_criteria, ...) R(iiRxRys(%s)N(RxRy( Rot sort_criteriaR9RORtsearch_criteriaRqRrRp(R9RRRRoRrRq((R2tsorts cCs4d}|i|||\}}|i|||S(spRequest named status conditions for mailbox. (typ, [data]) = .status(mailbox, names) R)N(RoR9RORztnamesRqRrRp(R9RzRRoRrRq((R2tstatusscCsZ|d|dfd jod|}n|id|||\}}|i||dS( sAlters flag dispositions for messages in mailbox. (typ, [data]) = .store(message_set, command, flags) iiRxRys(%s)R*RN(RxRy(R{R9RORtcommandRqRrRp(R9RRR{RrRq((R2tstores cCs|id|S(sYSubscribe to new mailbox. (typ, [data]) = .subscribe(mailbox) R+N(R9RORz(R9Rz((R2t subscribescGs7d}|i||||\}}|i|||S(sIMAPrev1 extension THREAD command. (type, [data]) = .thread(threading_alogrithm, charset, search_criteria, ...) R,N( RoR9ROtthreading_algorithmRRRqRrRp(R9RRRRoRrRq((R2tthreadscGs|i}|tjo|id|n|it|jo |id||ifnd}|i|||\}}|djo |}nd}|i |||S( sExecute "command arg ..." with messages identified by UID, rather than message number. (typ, [data]) = .uid(command, arg1, arg2, ...) Returns response appropriate to 'command'. sUnknown IMAP4 UID command: %sscommand %s illegal in state %sR-R$R(RN(sSEARCHsSORT( RRQRYR9R/R;RoROtargsRqRrRp(R9RRRoRrRq((R2tuids     cCs|id|S(s_Unsubscribe from old mailbox. (typ, [data]) = .unsubscribe(mailbox) R.N(R9RORz(R9Rz((R2t unsubscribescGs=|i}|tjo|ift|.xatom(name, arg, ...) Returns response appropriate to extension command `name'. N(RoRQRYR9R;ROR(R9RoR((R2txatoms   cCsS|djo d}n|i}||jo||i|n|g||R@( R9RoRRRRjR=RRRq((R2Rs^             cCs|iy|i|\}}Wna|ij o"}|id||fn2|i j o"}|i d||fnX|i|djo |i d|||fn||fS(Nscommand: %s => %sRs%s command error: %s %s( R9Rt_get_tagged_responseRRqRjR3RRoR/(R9RoRRRqRj((R2t_command_completeWs    cCsN|i}|i|i|ow|iid}||ijo|i d|n|iid}|iid}||gf|i|R3RqRrR<tdat2tUntagged_responsetUntagged_statust ContinuationR@tLiteraltintRgRfRjRt Response_code(R9RRrRRjRqRRg((R2RLesF   ,cCsdx]|i|}|dj o|i|=|Sny|iWq|ij o }qXqWdS(Ni(R9R>RtresultR<RLR3R(R9RRR((R2Rs   cCs4|i}|p|idn|d }|S(Nssocket error: EOFi(R9RhtlineR3(R9R((R2Rs   cCs|i||_|idj S(N(tcretmatchtsR9RR<(R9RR((R2RscCs7d|i|if}|id|_d|i|<|S(Ns%s%si(R9RHRBRR<R>(R9R((R2Rs cCst|tdj o|Snt|djo)|d|dfdd fjo|Sn|o!|ii|djo|Sn|i|S( NR5iiiRxRyt"(RxRy(RR(RRRR9t mustquoteRR<R(R9R((R2Rs4 cCs,|idd}|idd}d|S(Ns\s\\Rs\"s"%s"(Rtreplace(R9R((R2RscGs|i||i||S(N(R9RRoRR(R9RoR((R2ROscCsX|djo||fSn||ijo|dgfSn|ii|}||fS(NR(RqRrRoR9R?R<tpopRj(R9RqRrRoRj((R2Rps (HR0R1t__doc__t ExceptionR/R3R4RIRJRt IMAP4_PORTRWR]RCRfRhRkRmR_RtRvRRRRlRRRRRRRRRRRRRRRRRRsRRRRR<RRRRRRRRRRRRRRRRLRRRRRRRORp(((R2R`s ,<                                 H  L      cBshtZdZdeeedZdedZdZdZdZ dZ dZ d Z RS( sIMAP4 client class over SSL connection Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile]]]]) host - host's name (default: localhost); port - port number (default: standard IMAP4 SSL port). keyfile - PEM formatted file that contains your private key (default: None); certfile - PEM formatted certificate chain file (default: None); for more documentation see the docstring of the parent class IMAP4. R5cCs)||_||_ti|||dS(N(tkeyfileR9tcertfileRRWRDRE(R9RDRERR((R2RWJs  cCsh||_||_tititi|_|ii||fti|i|i |i |_ dS(sSetup connection to remote server on "host:port". (default: localhost:standard IMAP4 SSL port). This connection will be used by the routines: read, readline, send, shutdown. N( RDR9RER_R`RaRbRctsslRRtsslobj(R9RDRE((R2RCPs   cCsag}d}xE||jo7|ii||}|t|7}|i|qWdi|S(sRead 'size' bytes from remote.iR5N( tchunksRfRgR9RRjRRtjoin(R9RgRfRRj((R2Rf]s cCsOg}xB|iid}|i||djodi|Sq q WdS(sRead line from remote.is R5N(RR9RRftcharRR(R9RR((R2Rhjs  cCs]t|}xJ|djo<|ii|}||joPn||}||}qWdS(sSend data to remote.iN(RRjtbytesR9Rtwritetsent(R9RjRR((R2Rkts    cCs|iidS(s Close I/O established in "open".N(R9RbRl(R9((R2RmscCs|iS(sfReturn socket instance used to connect to IMAP4 server. socket = .socket() N(R9Rb(R9((R2R_scCs|iS(stReturn SSLObject instance used to communicate with the IMAP4 server. ssl = .socket.ssl() N(R9R(R9((R2Rs( R0R1RtIMAP4_SSL_PORTR<RWRCRfRhRkRmR_R(((R2R;s   cBsJtZdZdZeedZdZdZdZdZ RS(sIMAP4 client class over a stream Instantiate with: IMAP4_stream(command) where "command" is a string that can be passed to os.popen2() for more documentation see the docstring of the parent class IMAP4. cCs||_ti|dS(N(RR9RRW(R9R((R2RWs cCsFd|_d|_d|_d|_ti|i\|_ |_ dS(sSetup a stream connection. This connection will be used by the routines: read, readline, send, shutdown. N( R<R9RDRERbRetostpopen2Rt writefiletreadfile(R9RDRE((R2RCs     cCs|ii|S(sRead 'size' bytes from remote.N(R9R RfRg(R9Rg((R2RfscCs |iiS(sRead line from remote.N(R9R Rh(R9((R2RhscCs!|ii||iidS(sSend data to remote.N(R9R RRjtflush(R9Rj((R2RkscCs|ii|iidS(s Close I/O established in "open".N(R9R RlR (R9((R2Rms ( R0R1RRWR<RCRfRhRkRm(((R2Rs     RcBs2tZdZdZdZdZdZRS(scPrivate class to provide en/decoding for base64-based authentication conversation. cCs ||_dS(N(tmechinstR9R(R9R((R2RWscCs:|i|i|}|djodSn|i|S(NR(R9RtdecodeRjtretR<tencode(R9RjR((R2Rs cCsxd}xk|oct|djo|d }|d}n |}d}ti|}|o||d }q q W|S(NR5i0i(touptinpRtttbinasciit b2a_base64te(R9RRRR((R2Rs  cCs|pdSnti|S(NR5(RRt a2b_base64(R9R((R2Rs(R0R1RRWRRR(((R2Rs    tJanitFebitMaritApritMayitJunitJulitAugitSepi tOcti tNovi tDeci c Csti|}|pd Snt|id} |id}t |id}t |id} t |id}t |id}t |id} t |id} t |id }| d |d }|d jo | }n| | |||| d d d f } ti| }ti|}tio|d o|ti}n|ti}ti||S(sMConvert IMAP4 INTERNALDATE to UT. Returns Python time module tuple. tmontzonentdaytyearthourtmintsectzonehtzonemi<t-iN(t InternalDateRRRR<tMon2numRR&R'RR(R)R*R+R,R-R.tzonetttttimetmktimetutct localtimetlttdaylighttaltzonettimezone(RR6R2R*R+R'R.R(R8R3R,R&R-R)R((R2Rs.  ! cCsTd}d}tt|}x/|o't|d\}}|||}q!W|S(s-Convert integer to A-P string representation.R5tABCDEFGHIJKLMNOPiN(RtAPRtabstnumtdivmodtmod(R?RR=RA((R2R%s cCs7ti|}|pfSnt|idiS(s-Convert IMAP4 flags response to python tuple.R{N(tFlagsRRRRPRRR(RR((R2R2s cCst|ttfoti|}nct|ttifo |}n@t|t o#|d|dfd jo|Sn t dti d|}|ddjod|d}nti o|doti }n ti }d|d t|d d dS( syConvert 'date_time' to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"' iiRsdate_time not of a known types%d-%b-%Y %H:%M:%St0Ris %+03d%02di<N(RR(t isinstanceR|RtfloatR4R7R3RPt struct_timetstrt ValueErrortstrftimetdtR9R:R2R;R@(R|R2R3RJ((R2R=s +  t__main__sd:s:s-ds-sR5sIMAP password for %s on %s: t localhostsJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)sRtlfs RRs /tmp/xxx 1Rs/tmp/yyys /tmp/yyz 2RRs/tmpsyy*RRtSUBJECTttestRt1s(FLAGS INTERNALDATE RFC822)RtFLAGSs (\Deleted)RRRtRlRvt UIDVALIDITYRtALLRRcCsktid||ftt||\}}tid|||f|djo|dn|S(Ns%s %ss %s => %s %sRi(tMt_mesgtcmdRRZRqRr(RVRRrRq((R2truns  sPROTOCOL_VERSION = %ssCAPABILITIES = %rs/tmp/syy%s .*"([^"]+)"$iRs%ss:(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822.TEXT)s All tests OK.s Tests failed.s8 If you would like to see debugging output, try: %s -d5 (DRt __version__RR RFRIR_RR4t__all__RR8RR RTRYRJRRBR0RR}RRRRRRRR1RRRRR0tgetopttgetpasstargvtoptlistRR/RR<tstream_commandtoptRRDtgetusertUSERtPASSWDt test_mesgt test_seq1t test_seq2RWRTR;RURVRSRVtmlRRRtpathRRRrR(5R_RRRFRRRaRgRRR0RRYRRbRIRcRrRZRXRR^RYReRWRRTRR RRRDRBRR8R}RRdRfR[R_R1RRRRVRTRR4R]RR R((R2t? s ?  *[4,r ,  #       ]    "