^Rc@sdZdZddlZddlZddlZddlZddlZddlZddlZddl Z dddddd gZ d Z d Z d Z d ZddfZi&ddfd6dfd6ddddfd6dfd6dfd6dfd6ddfd6ddfd6ddfd6ddfd6dfd6dfd6ddfd6ddfd 6ddfd!6ddfd"6ddfd#6ddfd$6dfd%6ddddfd6ddfd&6ddfd'6ddddfd(6dfd)6dfd*6ddfd+6dfd,6ddfd-6ddfd.6ddfd/6ddfd06dfd16ddfd26dfd36ddfd46dfd56dfd66ddfd76Zejd8Zejd9Zejd:Zejd;Zejd<Zejd=Zejd>Zejd?Zdfd@YZyddlZWnek r2n$XdAefdBYZe jdAdefdCYZdDfdEYZ i dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6dZd[6d\d]6Z!d^Z"d_Z#d`Z$daZ%e&dbkr ddl'Z'ddl(Z(y#e'j'ej)dFdc\Z*Z+Wn(e'j,k rnZ-fff\Z*Z+nXe.Z/xWe*D]O\Z0Z-e0ddkre1e-Z n(e0dekre-Z/e+ re/fZ+nnq|We+ rdffZ+ne+d Z2e(j3Z4e(j(dge4e2p dhfZ5diie4dj6dkdl6Z6dme4e5ffdndoffdpdodqffddrffdsdre.e.e6ffdtdudvffdwdrffdxe.dydzffd{d|d}ffd~d|ddffdffdffdffdfffZ7dwffddffdd,dffddffdse.e.e.e6ffdffdfffZ8dZ9ye/rpee/Z:n ee2Z:e:j;dkre7dFZ7ne:j<de:j=e:j<de:j>fx!e7D]\Z?Z+e9e?e+qWxge9dtddfD]PZ@ejAde@ZBeBr-eBjCdFZDne@jEdZDe9deDfqWxe8D]z\Z?Z+e9e?e+ZFe?e+fdd,dffkrqXneFdjEZGeG rqXne9dddeGddfqXWdGHWn)dGHe rdej)d GHnnXndS(sIMAP4 client. Based on RFC 2060. Public class: IMAP4 Public variable: Debug Public functions: Internaldate2tuple Int2AP ParseFlags Time2Internaldate s2.58iNtIMAP4t IMAP4_streamtInternaldate2tupletInt2APt ParseFlagstTime2Internaldates iiit IMAP4REV1tAUTHtSELECTEDtAPPENDtNONAUTHt AUTHENTICATEtLOGOUTt CAPABILITYtCHECKtCLOSEtCOPYtCREATEtDELETEt DELETEACLtEXAMINEtEXPUNGEtFETCHtGETACLt GETANNOTATIONtGETQUOTAt GETQUOTAROOTtMYRIGHTStLISTtLOGINtLSUBt NAMESPACEtNOOPtPARTIALt PROXYAUTHtRENAMEtSEARCHtSELECTtSETACLt SETANNOTATIONtSETQUOTAtSORTtSTATUStSTOREt 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.*))?cBseZdZdefdYZdefdYZdefdYZejdZ de d Z d Z de d Z d Zd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#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/d0Z0d1e1d2Z2d3Z3d4Z4d5Z5d6Z6d7Z7d8Z8d9Z9d:Z:d;Z;d<Z<d=Z=d>Z>d?Z?d@Z@dAZAdBZBdCZCdDZDdEZEdFZFdGZGdHZHdIZIdJZJdOdKZLdLZMdMZNdNZORS(PsIMAP4 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. Also, most IMAP servers implement a sub-set of the commands available here. terrorcBseZRS((t__name__t __module__(((s/usr/lib/python2.7/imaplib.pyR0stabortcBseZRS((R1R2(((s/usr/lib/python2.7/imaplib.pyR3streadonlycBseZRS((R1R2(((s/usr/lib/python2.7/imaplib.pyR4ss[^\w!#$%&'*+,.:;<=>?^`|~-]tcCst|_d|_d|_i|_i|_d|_t|_ d|_ |j ||t t jdd|_tjd|jd|_d|_d|_i|_|jd kr|jd t|jd |jn|j|_d |jkr d |_n-d|jkr'd|_n|j|j|j\}}|dgkrl|jdnt|djj|_|jdkr|jd|jfnx-t D]%}||jkrqn||_!dSW|jddS(NR R5iiis(?Ps"\d+) (?P[A-Z]+) (?P.*)i isimaplib version %ssnew IMAP4 connection, tag=%stPREAUTHRtOKR s"no CAPABILITY response from serveriisCAPABILITIES: %rsserver not IMAP4 compliant("tDebugtdebugtstatetNonetliteralttagged_commandstuntagged_responsestcontinuation_responsetFalset is_readonlyttagnumtopenRtrandomtrandintttagpretretcompilettagret _cmd_log_lent _cmd_log_idxt_cmd_logt_mesgt __version__t _get_responsetwelcomeR0t capabilityttupletuppertsplitt capabilitiestAllowedVersionstPROTOCOL_VERSION(tselfthosttportttyptdattversion((s/usr/lib/python2.7/imaplib.pyt__init__sH               cCs3|tkrt||jStd|dS(NsUnknown IMAP4 command: '%s'(tCommandstgetattrtlowertAttributeError(RXtattr((s/usr/lib/python2.7/imaplib.pyt __getattr__s cCsC||_||_tj||f|_|jjd|_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(RYRZtsockettcreate_connectiontsocktmakefiletfile(RXRYRZ((s/usr/lib/python2.7/imaplib.pyRCs  cCs|jj|S(sRead 'size' bytes from remote.(Rjtread(RXtsize((s/usr/lib/python2.7/imaplib.pyRkscCs |jjS(sRead line from remote.(Rjtreadline(RX((s/usr/lib/python2.7/imaplib.pyRmscCs|jj|dS(sSend data to remote.N(Rhtsendall(RXtdata((s/usr/lib/python2.7/imaplib.pytsendscCsn|jjzLy|jjtjWn.tjk rW}|jtjkrXqXnXWd|jjXdS(s Close I/O established in "open".N( RjtcloseRhtshutdownRft SHUT_RDWRR0terrnotENOTCONN(RXte((s/usr/lib/python2.7/imaplib.pyRrs cCs|jS(sfReturn socket instance used to connect to IMAP4 server. socket = .socket() (Rh(RX((s/usr/lib/python2.7/imaplib.pyRfscCs]d}|jddg|\}}|dr8||fS|j\}}|j|||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(t_untagged_responseR;tnoop(RXtnameR[R\((s/usr/lib/python2.7/imaplib.pytrecents   cCs|j|dg|jS(sReturn data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = .response(code) N(RxR;RS(RXtcode((s/usr/lib/python2.7/imaplib.pytresponse"scCsd}|sd}n|rE|d|dfdkrKd|}qKnd }|r`t|}nd }tjt||_|j||||S( sAppend message to named mailbox. (typ, [data]) = .append(mailbox, flags, date_time, message) All args except `message' can be None. R tINBOXiit(t)s(%s)(RRN(R;RtMapCRLFtsubtCRLFR<t_simple_command(RXtmailboxtflagst date_timetmessageRz((s/usr/lib/python2.7/imaplib.pytappend0s cCsk|j}t|j|_|jd|\}}|dkrX|j|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(RSt_AuthenticatortprocessR<RR0R:(RXt mechanismt authobjecttmechR[R\((s/usr/lib/python2.7/imaplib.pyt authenticateGs   cCs.d}|j|\}}|j|||S(sT(typ, [data]) = .capability() Fetch capabilities list from server.R (RRx(RXRzR[R\((s/usr/lib/python2.7/imaplib.pyRQdscCs |jdS(sRCheckpoint mailbox on server. (typ, [data]) = .check() R(R(RX((s/usr/lib/python2.7/imaplib.pytcheckmscCs0z|jd\}}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(RR:(RXR[R\((s/usr/lib/python2.7/imaplib.pyRqus cCs|jd||S(sCopy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = .copy(message_set, new_mailbox) R(R(RXt message_sett new_mailbox((s/usr/lib/python2.7/imaplib.pytcopyscCs|jd|S(sPCreate new mailbox. (typ, [data]) = .create(mailbox) R(R(RXR((s/usr/lib/python2.7/imaplib.pytcreatescCs|jd|S(sPDelete old mailbox. (typ, [data]) = .delete(mailbox) R(R(RXR((s/usr/lib/python2.7/imaplib.pytdeletescCs|jd||S(sDelete the ACLs (remove any rights) set for who on mailbox. (typ, [data]) = .deleteacl(mailbox, who) R(R(RXRtwho((s/usr/lib/python2.7/imaplib.pyt deleteaclscCs.d}|j|\}}|j|||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. R(RRx(RXRzR[R\((s/usr/lib/python2.7/imaplib.pytexpunges cCs4d}|j|||\}}|j|||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. R(RRx(RXRt message_partsRzR[R\((s/usr/lib/python2.7/imaplib.pytfetchs cCs+|jd|\}}|j||dS(sXGet the ACLs for a mailbox. (typ, [data]) = .getacl(mailbox) RtACL(RRx(RXRR[R\((s/usr/lib/python2.7/imaplib.pytgetaclscCs1|jd|||\}}|j||dS(sa(typ, [data]) = .getannotation(mailbox, entry, attribute) Retrieve ANNOTATIONs.Rt ANNOTATION(RRx(RXRtentryt attributeR[R\((s/usr/lib/python2.7/imaplib.pyt getannotationscCs+|jd|\}}|j||dS(sGet the quota root's resource usage and limits. Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = .getquota(root) RtQUOTA(RRx(RXtrootR[R\((s/usr/lib/python2.7/imaplib.pytgetquotascCs^|jd|\}}|j||d\}}|j||d\}}|||gfS(sGet the list of quota roots for the named mailbox. (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) RRt QUOTAROOT(RRx(RXRR[R\tquotat quotaroot((s/usr/lib/python2.7/imaplib.pyt getquotarootss""t*cCs4d}|j|||\}}|j|||S(sList mailbox names in directory matching pattern. (typ, [data]) = .list(directory='""', pattern='*') 'data' is list of LIST responses. R(RRx(RXt directorytpatternRzR[R\((s/usr/lib/python2.7/imaplib.pytlistscCsY|jd||j|\}}|dkrF|j|dnd|_||fS(sIdentify client using plaintext password. (typ, [data]) = .login(user, password) NB: 'password' will be quoted. RR7iR(Rt_quoteR0R:(RXtusertpasswordR[R\((s/usr/lib/python2.7/imaplib.pytlogins $  cCs&|||_|_|jd|jS(sr Force use of CRAM-MD5 authentication. (typ, [data]) = .login_cram_md5(user, password) sCRAM-MD5(RRRt_CRAM_MD5_AUTH(RXRR((s/usr/lib/python2.7/imaplib.pytlogin_cram_md5scCs0ddl}|jd|j|j|jS(s1 Authobject to use with CRAM-MD5 authentication. iNt (thmacRtHMACRt hexdigest(RXt challengeR((s/usr/lib/python2.7/imaplib.pyR s cCs~d|_y|jd\}}Wn%ddtjd g}}nX|jd|jkrtd|jdfS||fS(s|Shutdown connection to server. (typ, [data]) = .logout() Returns server 'BYE' response. R tNOs%s: %sitBYE(R:Rtsystexc_infoRrR>(RXR[R\((s/usr/lib/python2.7/imaplib.pytlogouts " cCs4d}|j|||\}}|j|||S(sList 'subscribed' mailbox names in directory matching pattern. (typ, [data, ...]) = .lsub(directory='""', pattern='*') 'data' are tuples of message part envelope and data. R(RRx(RXRRRzR[R\((s/usr/lib/python2.7/imaplib.pytlsubscCs+|jd|\}}|j||dS(sShow my ACLs for a mailbox (i.e. the rights that I have on mailbox). (typ, [data]) = .myrights(mailbox) R(RRx(RXRR[R\((s/usr/lib/python2.7/imaplib.pytmyrights*scCs.d}|j|\}}|j|||S(sb Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) = .namespace() R(RRx(RXRzR[R\((s/usr/lib/python2.7/imaplib.pyt namespace2scCs/|jdkr"|j|jn|jdS(sFSend NOOP command. (typ, [data]) = .noop() iR (R9t_dump_urR>R(RX((s/usr/lib/python2.7/imaplib.pyRy<scCs:d}|j|||||\}}|j||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!R(RRx(RXt message_numt message_parttstarttlengthRzR[R\((s/usr/lib/python2.7/imaplib.pytpartialGs!cCsd}|jd|S(sAssume authentication as "user". Allows an authorised administrator to proxy into any user's mailbox. (typ, [data]) = .proxyauth(user) R"(R(RXRRz((s/usr/lib/python2.7/imaplib.pyt proxyauthSs cCs|jd||S(skRename old mailbox name to new. (typ, [data]) = .rename(oldmailbox, newmailbox) R#(R(RXt oldmailboxt newmailbox((s/usr/lib/python2.7/imaplib.pytrename`scGsXd}|r-|j|d||\}}n|j||\}}|j|||S(sSearch mailbox for matching messages. (typ, [data]) = .search(charset, criterion, ...) 'data' is space separated list of matching message numbers. R$tCHARSET(RRx(RXtcharsettcriteriaRzR[R\((s/usr/lib/python2.7/imaplib.pytsearchhs !R~cCsi|_||_|r!d}nd}|j||\}}|dkr^d|_||fSd|_d|jkr| r|jdkr|j|jn|jd|n||jjd d gfS( stSelect a mailbox. Flush all untagged responses. (typ, [data]) = .select(mailbox='INBOX', readonly=False) '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%R7RRs READ-ONLYis%s is not writabletEXISTSN( R>RARR:R9RR4tgetR;(RXRR4RzR[R\((s/usr/lib/python2.7/imaplib.pytselectws       cCs|jd|||S(sZSet a mailbox acl. (typ, [data]) = .setacl(mailbox, who, what) R&(R(RXRRtwhat((s/usr/lib/python2.7/imaplib.pytsetaclscGs+|jd|\}}|j||dS(s_(typ, [data]) = .setannotation(mailbox[, entry, attribute]+) Set ANNOTATIONs.R'R(RRx(RXtargsR[R\((s/usr/lib/python2.7/imaplib.pyt setannotationscCs.|jd||\}}|j||dS(siSet the quota root's resource limits. (typ, [data]) = .setquota(root, limits) R(R(RRx(RXRtlimitsR[R\((s/usr/lib/python2.7/imaplib.pytsetquotascGs^d}|d|dfdkr-d|}n|j||||\}}|j|||S(sIMAP4rev1 extension SORT command. (typ, [data]) = .sort(sort_criteria, charset, search_criteria, ...) R)iiRRs(%s)(RR(RRx(RXt sort_criteriaRtsearch_criteriaRzR[R\((s/usr/lib/python2.7/imaplib.pytsorts  cCs4d}|j|||\}}|j|||S(spRequest named status conditions for mailbox. (typ, [data]) = .status(mailbox, names) R*(RRx(RXRtnamesRzR[R\((s/usr/lib/python2.7/imaplib.pytstatusscCsX|d|dfdkr'd|}n|jd|||\}}|j||dS( sAlters flag dispositions for messages in mailbox. (typ, [data]) = .store(message_set, command, flags) iiRRs(%s)R+R(RR(RRx(RXRtcommandRR[R\((s/usr/lib/python2.7/imaplib.pytstores cCs|jd|S(sYSubscribe to new mailbox. (typ, [data]) = .subscribe(mailbox) R,(R(RXR((s/usr/lib/python2.7/imaplib.pyt subscribescGs7d}|j||||\}}|j|||S(sIMAPrev1 extension THREAD command. (type, [data]) = .thread(threading_algorithm, charset, search_criteria, ...) R-(RRx(RXtthreading_algorithmRRRzR[R\((s/usr/lib/python2.7/imaplib.pytthreadscGs|j}|tkr.|jd|n|jt|krp|jd||jdjt|fnd}|j|||\}}|d kr|}nd}|j|||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: %ss9command %s illegal in state %s, only allowed in states %ss, R.R$R)R-R(sSEARCHsSORTsTHREAD(RSR_R0R:tjoinRRx(RXRRRzR[R\((s/usr/lib/python2.7/imaplib.pytuids      cCs|jd|S(s_Unsubscribe from old mailbox. (typ, [data]) = .unsubscribe(mailbox) R/(R(RXR((s/usr/lib/python2.7/imaplib.pyt unsubscribescGs;|j}|tkr+|jft|.xatom(name, arg, ...) Returns response appropriate to extension command `name'. (RSR_R:R(RXRzR((s/usr/lib/python2.7/imaplib.pytxatoms  cCs|dkrd}n|j}|jdkr\|jd|t|j|d|fn||kr|||j|n |g||R9RMtlenRR(RXR[R\tur((s/usr/lib/python2.7/imaplib.pyt_append_untaggeds   & cCs2|jjd}|r.|j|dndS(NRi(R>RR3(RXtbye((s/usr/lib/python2.7/imaplib.pyt _check_bye,sc Gs|jt|krKd|_|jd||jdjt|fnx*dD]"}||jkrR|j|=qRqRWd|jkr|j r|jdn|j }d||f}x9|D]1}|dkrqnd||j |f}qW|j}|dk r\d|_t |t |j kr=|}q\d}d |t |f}n|jd kr|jd |n|jd |y|jd |tfWn/tjtfk r} |jd | nX|dkr|Sxx!|jr|j|r|SqW|r,||j}n|jd krU|jdt |ny|j||jtWn/tjtfk r} |jd | nX|sPqq|S(Ns9command %s illegal in state %s, only allowed in states %ss, R7RtBADs READ-ONLYs#mailbox status changed to READ-ONLYs%s %ss%s {%s}is> %ss%s%sssocket error: %sswrite literal size %s(sOKsNOR(R:R_R;R<R0RR>RAR4t_new_tagt _checkquotettypet_commandRR9RMt_logRpRRftOSErrorR3ROR=R?( RXRzRR[ttagRotargR<t literatortval((s/usr/lib/python2.7/imaplib.pyR2sb               cCs|dkr|jny|j|\}}Wn]|jk rc}|jd||fn/|jk r}|jd||fnX|dkr|jn|dkr|jd|||fn||fS(NR scommand: %s => %sRs%s command error: %s %s(Rt_get_tagged_responseR3R0(RXRzRR[RoR((s/usr/lib/python2.7/imaplib.pyt_command_complete|s     cCs|j}|j|j|r|jjd}||jkrX|jd|n|jjd}|jjd}||gf|j| %r(tmatchRR;R9RMRtgroups(RXtcrets((s/usr/lib/python2.7/imaplib.pyRs&cCs7d|j|jf}|jd|_d|j|<|S(Ns%s%si(RFRBR;R=(RXR((s/usr/lib/python2.7/imaplib.pyRs cCst|tdk r|St|dkrR|d|dfdd fkrR|S|rt|jj|dkrt|S|j|S( NR5iiiRRt"(RR(R R (RRt mustquoteRR;R(RXR((s/usr/lib/python2.7/imaplib.pyRs2cCs,|jdd}|jdd}d|S(Ns\s\\R s\"s"%s"(treplace(RXR((s/usr/lib/python2.7/imaplib.pyR$scGs|j||j||S(N(RR(RXRzR((s/usr/lib/python2.7/imaplib.pyR,scCsw|dkr||fS||jkr2|dgfS|jj|}|jdkrm|jd||fn||fS(NRisuntagged_responses[%s] => %s(R>R;tpopR9RM(RXR[R\RzRo((s/usr/lib/python2.7/imaplib.pyRx1s   cCsl|dkrtj}ntjdtj|}tjjd||dd|ftjjdS(Ns%M:%Ss %s.%02d %s id(R;ttimetstrftimet localtimeRtstderrtwritetflush(RXR tsecsttm((s/usr/lib/python2.7/imaplib.pyRM@s  %cCsR|j}|sdSd}td|}|jd||j|fdS(Ns cSs3d|d|ddr+dj|dp.dfS(Ns%s: "%s"iis" "R5(R(tx((s/usr/lib/python2.7/imaplib.pytLssuntagged responses dump:%s%s(titemstmapRMR(RXtdicttltt((s/usr/lib/python2.7/imaplib.pyRGs  cCsM|tjf|j|j<|jd7_|j|jkrId|_ndS(Nii(RRLRKRJ(RXR((s/usr/lib/python2.7/imaplib.pyROscCs|jdt|j|j|j}}xX|ry|j|j|WnnX|d7}||jkrzd}n|d8}q0WdS(Nslast %d IMAP4 interactions:ii(RMRRLRKRJ(RXtitn((s/usr/lib/python2.7/imaplib.pyRVs   N(PR1R2t__doc__t ExceptionR0R3R4RGRHR t IMAP4_PORTR^RdRCRkRmRpRrRfR{R}RRRQRRqRRRRRRRRRRRRRRRRRRRyRRRRR@RRRRRRRRRRRRRRRRRORRRRRRRRxR;RMRRR(((s/usr/lib/python2.7/imaplib.pyRcs,;                                  J  L          t IMAP4_SSLcBsheZdZded d dZdedZdZdZdZ 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)||_||_tj|||dS(N(tkeyfiletcertfileRR^(RXRYRZR$R%((s/usr/lib/python2.7/imaplib.pyR^ys  cCsd||_||_tj||f|_tj|j|j|j|_ |j j d|_ 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. ReN( RYRZRfRgRhtsslt wrap_socketR$R%tsslobjRiRj(RXRYRZ((s/usr/lib/python2.7/imaplib.pyRCs   !cCs|jj|S(sRead 'size' bytes from remote.(RjRk(RXRl((s/usr/lib/python2.7/imaplib.pyRkscCs |jjS(sRead line from remote.(RjRm(RX((s/usr/lib/python2.7/imaplib.pyRmscCsYt|}xF|dkrT|jj|}||kr=Pn||}||}qWdS(sSend data to remote.iN(RR(R(RXRotbytestsent((s/usr/lib/python2.7/imaplib.pyRps   cCs|jj|jjdS(s Close I/O established in "open".N(RjRqRh(RX((s/usr/lib/python2.7/imaplib.pyRrs cCs|jS(snReturn socket instance used to connect to IMAP4 server. socket = .socket() (Rh(RX((s/usr/lib/python2.7/imaplib.pyRfscCs|jS(sReturn SSLObject instance used to communicate with the IMAP4 server. ssl = ssl.wrap_socket(.socket) (R((RX((s/usr/lib/python2.7/imaplib.pyR&sN( R1R2R tIMAP4_SSL_PORTR;R^RCRkRmRpRrRfR&(((s/usr/lib/python2.7/imaplib.pyR#js     cBsJeZdZdZdddZdZdZdZdZ RS(sIMAP4 client class over a stream Instantiate with: IMAP4_stream(command) where "command" is a string that can be passed to subprocess.Popen() for more documentation see the docstring of the parent class IMAP4. cCs||_tj|dS(N(RRR^(RXR((s/usr/lib/python2.7/imaplib.pyR^s c Csyd|_d|_d|_d|_tj|jdtjdtjdt dt |_ |j j |_ |j j |_dS(sSetup a stream connection. This connection will be used by the routines: read, readline, send, shutdown. tstdintstdouttshellt close_fdsN(R;RYRZRhRjt subprocesstPopenRtPIPEtTrueRR,t writefileR-treadfile(RXRYRZ((s/usr/lib/python2.7/imaplib.pyRCs    cCs|jj|S(sRead 'size' bytes from remote.(R5Rk(RXRl((s/usr/lib/python2.7/imaplib.pyRkscCs |jjS(sRead line from remote.(R5Rm(RX((s/usr/lib/python2.7/imaplib.pyRmscCs!|jj||jjdS(sSend data to remote.N(R4RR(RXRo((s/usr/lib/python2.7/imaplib.pyRpscCs+|jj|jj|jjdS(s Close I/O established in "open".N(R5RqR4Rtwait(RX((s/usr/lib/python2.7/imaplib.pyRrs  N( R1R2R R^R;RCRkRmRpRr(((s/usr/lib/python2.7/imaplib.pyRs     RcBs2eZdZdZdZdZdZRS(scPrivate class to provide en/decoding for base64-based authentication conversation. cCs ||_dS(N(R(RXtmechinst((s/usr/lib/python2.7/imaplib.pyR^scCs5|j|j|}|dkr(dS|j|S(NR(RtdecodeR;tencode(RXRotret((s/usr/lib/python2.7/imaplib.pyRs cCsrd}xe|rmt|dkr8|d }|d}n |}d}tj|}|r ||d }q q W|S(NR5i0i(Rtbinasciit b2a_base64(RXtinptoupRRv((s/usr/lib/python2.7/imaplib.pyR9s    cCs|s dStj|S(NR5(R;t a2b_base64(RXR=((s/usr/lib/python2.7/imaplib.pyR8s(R1R2R R^RR9R8(((s/usr/lib/python2.7/imaplib.pyRs    itJanitFebitMaritApritMayitJunitJulitAugi tSepi tOcti tNovi tDecc Csvtj|}|sd St|jd}|jd}t|jd}t|jd}t|jd}t|jd}t|jd}t|jd} t|jd } | d | d } |d kr| } n||||||d d d f } tj| } tj| }tj rX|d rX| tj } n | tj } tj| | S(sParse an IMAP4 INTERNALDATE string. Return corresponding local time. The return value is a time.struct_time instance or None if the string has wrong format. tmontzonentdaytyearthourtmintsectzonehtzonemi<t-iN( t InternalDateRR;tMon2numRRRtmktimeRtdaylighttaltzonettimezone(RRRLRMRNRORPRQRRRSRTtzonettttutctlt((s/usr/lib/python2.7/imaplib.pyR!s,  ! cCsRd}d}tt|}x-|rMt|d\}}|||}q!W|S(s-Convert integer to A-P string representation.R5tABCDEFGHIJKLMNOPi(Rtabstdivmod(tnumRtAPtmod((s/usr/lib/python2.7/imaplib.pyRNs cCs2tj|}|sdSt|jdjS(s-Convert IMAP4 flags response to python tuple.R((tFlagsRRRRRT(RR((s/usr/lib/python2.7/imaplib.pyR[scCst|ttfr'tj|}nZt|ttjfrH|}n9t|tru|d|dfd kru|Stdtj d|}|ddkrd|d}ntj r|drtj }n tj }d|d t |d d dS( sConvert date_time to IMAP4 INTERNALDATE representation. Return string in form: '"DD-Mmm-YYYY HH:MM:SS +HHMM"'. The date_time argument can be a number (int or float) representing seconds since epoch (as returned by time.time()), a 9-tuple representing local time (as returned by time.localtime()), or a double-quoted string. In the last case, it is assumed to already be in the correct format. iiR sdate_time not of a known types%d-%b-%Y %H:%M:%St0Ris %+03d%02di<(R R (t isinstanceRtfloatRRRRt struct_timetstrt ValueErrorRRYRZR[Rb(RR]tdtR\((s/usr/lib/python2.7/imaplib.pyRfs  )   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)sRs tlfRRs /tmp/xxx 1Rs/tmp/yyys /tmp/yyz 2RRs/tmpsyy*RRtSUBJECTttestRt1s(FLAGS INTERNALDATE RFC822)RtFLAGSs (\Deleted)RRR{RqR}t UIDVALIDITYRtALLRRcCsitjd||ftt||\}}tjd|||f|dkre|dn|S(Ns%s %ss %s => %s %sRi(tMRMR`(tcmdRR[R\((s/usr/lib/python2.7/imaplib.pytruns  sPROTOCOL_VERSION = %ssCAPABILITIES = %rs/tmp/syy%s .*"([^"]+)"$Rs%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 (HR RNR;RtRDRGRfR0RRt__all__RR8R"R+RVR_RHRRfRVRRRRRRR&t ImportErrorR#RRRRWRRRRR1tgetopttgetpasstargvtoptlistRR0RR;tstream_commandtoptRRYtgetusertUSERtPASSWDt test_mesgt test_seq1t test_seq2RyRwR:RMRWRURxtmlRRRtpathRTR\R(((s/usr/lib/python2.7/imaplib.pyt s( `                                     L 9,-- - #