Lc"@s$dZdZddkZddkZddkZddkZddkZddkZddkZdddddd gZ d Z d Z d Z d Z ddfZdZh&ddfd6dfd6ddddfd6dfd6dfd6dfd6ddfd6ddfd6ddfd6ddfd6dfd6dfd6ddfd 6ddfd!6ddfd"6ddfd#6ddfd$6ddfd%6dfd&6ddddfd6ddfd'6ddfd(6ddddfd)6dfd*6dfd+6ddfd,6dfd-6ddfd.6ddfd/6ddfd06ddfd16dfd26ddfd36dfd46ddfd56dfd66dfd76ddfd86Zeid9Zeid:Zeid;Zeid<Zeid=Zeid>Zeid?Zeid@ZdfdAYZyddkZWnej on%XdBefdCYZe idBdefdDYZdEfdFYZ h dGdH6dIdJ6dKdL6dMdN6dOdP6dQdR6dSdT6dUdV6dWdX6dYdZ6d[d\6d]d^6Z!d_Z"d`Z#daZ$dbZ%e&dcjoddk'Z'ddk(Z(y#e'i'ei)dGdd\Z*Z+Wn*e'i,j oZ-fff\Z*Z+nXe.Z/x]e*D]U\Z0Z-e0dejoe1e-Z n-e0dfjoe-Z/e+ o e/fZ+nnq{We+ o dgfZ+ne+d Z2e(i3Z4e(i(dhe4e2pdifZ5djhe4dk6dldm6Z6dne4e5ffdodpffdqdpdrffddsffdtdse.e.e6ffdudvdwffdxdsffdye.dzd{ffd|d}d~ffdd}ddffdffdffdffdfffZ7dxffddffdd-dffddffdte.e.e.e6ffdffdfffZ8dZ9ye/oee/Z:n ee2Z:e:i;djoe7dGZ7ne:i<de:i=e:i<de:i>fx!e7D]\Z?Z+e9e?e+qWxie9duddfD]RZ@eiAde@ZBeBoeBiCdGZDne@iEdZDe9deDfq Wxe8D]~\Z?Z+e9e?e+ZFe?e+fdd-dffjoqfneFdiEZGeG oqfne9dddeGddfqfWdGHWn+dGHe odei)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 IMAP4REV1i'tAUTHtSELECTEDtAPPENDtNONAUTHt 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.*))?cBseZdZdefdYZdefdYZdefdYZeidZ 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@dAZAdBZBdCZCdDZDdEZEdFZFdGZGdHZHdIZIdJZJRS(KsIMAP4 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/lib64/python2.6/imaplib.pyR0stabortcBseZRS((R1R2(((s/usr/lib64/python2.6/imaplib.pyR3streadonlycBseZRS((R1R2(((s/usr/lib64/python2.6/imaplib.pyR4ss[^\w!#$%&'*+,.:;<=>?^`|~-]tcCst|_d|_d|_h|_h|_d|_t|_ d|_ |i ||t t idd|_tid|id|_|i|_d|ijo d |_n0d |ijo d |_n|i|i|i\}}|dgjo|id nt|d ii|_x/tD]'}||ijoqFn||_dSW|iddS(NR R5iiis(?Ps"\d+) (?P[A-Z]+) (?P.*)tPREAUTHRtOKR s"no CAPABILITY response from serverisserver not IMAP4 compliant(tDebugtdebugtstatetNonetliteralttagged_commandstuntagged_responsestcontinuation_responsetFalset is_readonlyttagnumtopenRtrandomtrandintttagpretretcompilettagret _get_responsetwelcomeR0t capabilityttupletuppertsplitt capabilitiestAllowedVersionstPROTOCOL_VERSION(tselfthosttportttyptdattversion((s/usr/lib64/python2.6/imaplib.pyt__init__s:            cCs5|tjot||iStd|dS(NsUnknown IMAP4 command: '%s'(tCommandstgetattrtlowertAttributeError(RStattr((s/usr/lib64/python2.6/imaplib.pyt __getattr__s cCsC||_||_ti||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(RTRUtsockettcreate_connectiontsocktmakefiletfile(RSRTRU((s/usr/lib64/python2.6/imaplib.pyRCs  cCs|ii|S(sRead 'size' bytes from remote.(Retread(RStsize((s/usr/lib64/python2.6/imaplib.pyRfscCsD|iitd}t|tjo|idtn|S(sRead line from remote.isgot more than %d bytes(Retreadlinet_MAXLINEtlenR0(RStline((s/usr/lib64/python2.6/imaplib.pyRhscCs|ii|dS(sSend data to remote.N(Rctsendall(RStdata((s/usr/lib64/python2.6/imaplib.pytsendscCs|ii|iidS(s Close I/O established in "open".N(RetcloseRc(RS((s/usr/lib64/python2.6/imaplib.pytshutdowns cCs|iS(sfReturn socket instance used to connect to IMAP4 server. socket = .socket() (Rc(RS((s/usr/lib64/python2.6/imaplib.pyRa scCs_d}|iddg|\}}|do ||fS|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(t_untagged_responseR;tnoop(RStnameRVRW((s/usr/lib64/python2.6/imaplib.pytrecents   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(RrR;RN(RStcode((s/usr/lib64/python2.6/imaplib.pytresponse'scCsd}|p d}n|o-|d|dfdjod|}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. R tINBOXiit(t)s(%s)(RyRzN(R;RtMapCRLFtsubtCRLFR<t_simple_command(RStmailboxtflagst date_timetmessageRt((s/usr/lib64/python2.6/imaplib.pytappend5s 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(RNt_AuthenticatortprocessR<R~R0R:(RSt mechanismt authobjecttmechRVRW((s/usr/lib64/python2.6/imaplib.pyt authenticateLs   cCs.d}|i|\}}|i|||S(sT(typ, [data]) = .capability() Fetch capabilities list from server.R (R~Rr(RSRtRVRW((s/usr/lib64/python2.6/imaplib.pyRLiscCs |idS(sRCheckpoint mailbox on server. (typ, [data]) = .check() R(R~(RS((s/usr/lib64/python2.6/imaplib.pytcheckrscCs0z|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(R~R:(RSRVRW((s/usr/lib64/python2.6/imaplib.pyRozs cCs|id||S(sCopy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = .copy(message_set, new_mailbox) R(R~(RSt message_sett new_mailbox((s/usr/lib64/python2.6/imaplib.pytcopyscCs|id|S(sPCreate new mailbox. (typ, [data]) = .create(mailbox) R(R~(RSR((s/usr/lib64/python2.6/imaplib.pytcreatescCs|id|S(sPDelete old mailbox. (typ, [data]) = .delete(mailbox) R(R~(RSR((s/usr/lib64/python2.6/imaplib.pytdeletescCs|id||S(sDelete the ACLs (remove any rights) set for who on mailbox. (typ, [data]) = .deleteacl(mailbox, who) R(R~(RSRtwho((s/usr/lib64/python2.6/imaplib.pyt 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. R(R~Rr(RSRtRVRW((s/usr/lib64/python2.6/imaplib.pytexpunges cCs4d}|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. R(R~Rr(RSRt message_partsRtRVRW((s/usr/lib64/python2.6/imaplib.pytfetchs cCs+|id|\}}|i||dS(sXGet the ACLs for a mailbox. (typ, [data]) = .getacl(mailbox) RtACL(R~Rr(RSRRVRW((s/usr/lib64/python2.6/imaplib.pytgetaclscCs1|id|||\}}|i||dS(sa(typ, [data]) = .getannotation(mailbox, entry, attribute) Retrieve ANNOTATIONs.Rt ANNOTATION(R~Rr(RSRtentryt attributeRVRW((s/usr/lib64/python2.6/imaplib.pyt getannotationscCs+|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) RtQUOTA(R~Rr(RStrootRVRW((s/usr/lib64/python2.6/imaplib.pytgetquotascCs^|id|\}}|i||d\}}|i||d\}}|||gfS(sGet the list of quota roots for the named mailbox. (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) RRt QUOTAROOT(R~Rr(RSRRVRWtquotat quotaroot((s/usr/lib64/python2.6/imaplib.pyt getquotarootss""t*cCs4d}|i|||\}}|i|||S(sList mailbox names in directory matching pattern. (typ, [data]) = .list(directory='""', pattern='*') 'data' is list of LIST responses. R(R~Rr(RSt directorytpatternRtRVRW((s/usr/lib64/python2.6/imaplib.pytlistscCs[|id||i|\}}|djo|i|dnd|_||fS(sIdentify client using plaintext password. (typ, [data]) = .login(user, password) NB: 'password' will be quoted. RR7iR(R~t_quoteR0R:(RStusertpasswordRVRW((s/usr/lib64/python2.6/imaplib.pytlogins $  cCs&|||_|_|id|iS(sr Force use of CRAM-MD5 authentication. (typ, [data]) = .login_cram_md5(user, password) sCRAM-MD5(RRRt_CRAM_MD5_AUTH(RSRR((s/usr/lib64/python2.6/imaplib.pytlogin_cram_md5scCs0ddk}|id|i|i|iS(s1 Authobject to use with CRAM-MD5 authentication. iNt (thmacRtHMACRt hexdigest(RSt challengeR((s/usr/lib64/python2.6/imaplib.pyRs cCsd|_y|id\}}Wn%ddtid g}}nX|id|ijod|idfS||fS(s|Shutdown connection to server. (typ, [data]) = .logout() Returns server 'BYE' response. R tNOs%s: %sitBYE(R:R~tsystexc_infoRpR>(RSRVRW((s/usr/lib64/python2.6/imaplib.pytlogouts " 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. R(R~Rr(RSRRRtRVRW((s/usr/lib64/python2.6/imaplib.pytlsub$scCs+|id|\}}|i||dS(sShow my ACLs for a mailbox (i.e. the rights that I have on mailbox). (typ, [data]) = .myrights(mailbox) R(R~Rr(RSRRVRW((s/usr/lib64/python2.6/imaplib.pytmyrights/scCs.d}|i|\}}|i|||S(sb Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) = .namespace() R(R~Rr(RSRtRVRW((s/usr/lib64/python2.6/imaplib.pyt namespace7scCs |idS(sFSend NOOP command. (typ, [data]) = .noop() R (R~(RS((s/usr/lib64/python2.6/imaplib.pyRsAscCs: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!R(R~Rr(RSt message_numt message_parttstarttlengthRtRVRW((s/usr/lib64/python2.6/imaplib.pytpartialLs!cCsd}|id|S(sAssume authentication as "user". Allows an authorised administrator to proxy into any user's mailbox. (typ, [data]) = .proxyauth(user) R"(R~(RSRRt((s/usr/lib64/python2.6/imaplib.pyt proxyauthXs cCs|id||S(skRename old mailbox name to new. (typ, [data]) = .rename(oldmailbox, newmailbox) R#(R~(RSt oldmailboxt newmailbox((s/usr/lib64/python2.6/imaplib.pytrenameescGsZd}|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$tCHARSET(R~Rr(RStcharsettcriteriaRtRVRW((s/usr/lib64/python2.6/imaplib.pytsearchms "RxcCsh|_||_|o d}nd}|i||\}}|djod|_||fSd|_d|ijo| o|id|n||iidd 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-ONLYs%s is not writabletEXISTSN(R>RAR~R:R4tgetR;(RSRR4RtRVRW((s/usr/lib64/python2.6/imaplib.pytselect|s       cCs|id|||S(sZSet a mailbox acl. (typ, [data]) = .setacl(mailbox, who, what) R&(R~(RSRRtwhat((s/usr/lib64/python2.6/imaplib.pytsetaclscGs+|id|\}}|i||dS(s_(typ, [data]) = .setannotation(mailbox[, entry, attribute]+) Set ANNOTATIONs.R'R(R~Rr(RStargsRVRW((s/usr/lib64/python2.6/imaplib.pyt setannotationscCs.|id||\}}|i||dS(siSet the quota root's resource limits. (typ, [data]) = .setquota(root, limits) R(R(R~Rr(RSRtlimitsRVRW((s/usr/lib64/python2.6/imaplib.pytsetquotascGs`d}|d|dfdjod|}n|i||||\}}|i|||S(sIMAP4rev1 extension SORT command. (typ, [data]) = .sort(sort_criteria, charset, search_criteria, ...) R)iiRyRzs(%s)(RyRz(R~Rr(RSt sort_criteriaRtsearch_criteriaRtRVRW((s/usr/lib64/python2.6/imaplib.pytsorts cCs4d}|i|||\}}|i|||S(spRequest named status conditions for mailbox. (typ, [data]) = .status(mailbox, names) R*(R~Rr(RSRtnamesRtRVRW((s/usr/lib64/python2.6/imaplib.pytstatusscCsZ|d|dfdjod|}n|id|||\}}|i||dS( sAlters flag dispositions for messages in mailbox. (typ, [data]) = .store(message_set, command, flags) iiRyRzs(%s)R+R(RyRz(R~Rr(RSRtcommandRRVRW((s/usr/lib64/python2.6/imaplib.pytstorescCs|id|S(sYSubscribe to new mailbox. (typ, [data]) = .subscribe(mailbox) R,(R~(RSR((s/usr/lib64/python2.6/imaplib.pyt subscribescGs7d}|i||||\}}|i|||S(sIMAPrev1 extension THREAD command. (type, [data]) = .thread(threading_algorithm, charset, search_criteria, ...) R-(R~Rr(RStthreading_algorithmRRRtRVRW((s/usr/lib64/python2.6/imaplib.pytthreadscGs|i}|tjo|id|n|it|jo0|id||idit|fnd}|i|||\}}|d jo |}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: %ss9command %s illegal in state %s, only allowed in states %ss, R.R$R)R-R(sSEARCHsSORTsTHREAD(RNRZR0R:tjoinR~Rr(RSRRRtRVRW((s/usr/lib64/python2.6/imaplib.pytuids      cCs|id|S(s_Unsubscribe from old mailbox. (typ, [data]) = .unsubscribe(mailbox) R/(R~(RSR((s/usr/lib64/python2.6/imaplib.pyt unsubscribescGs=|i}|tjo|ift|.xatom(name, arg, ...) Returns response appropriate to extension command `name'. (RNRZR:R~(RSRtR((s/usr/lib64/python2.6/imaplib.pytxatom s  cCsS|djo d}n|i}||jo||i|n|g||R(RSRVRWtur((s/usr/lib64/python2.6/imaplib.pyt_append_untagged#s    cCs4|iid}|o|i|dndS(NRi(R>RR3(RStbye((s/usr/lib64/python2.6/imaplib.pyt _check_bye1sc Gst|it|jo9d|_|id||idit|fnx,d D]$}||ijo|i|=qTqTWd|ijo|i o|idn|i }d||f}x;|D]3}|djoqnd||i |f}qW|i}|dj oOd|_t |t |i jo |}qid}d |t |f}ny|id |tfWn1titfj o} |id | nX|djo|Sxx%|io|i|o|SqW|o||i}ny|i||itWn1titfj o} |id | nX|pPqq|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}s%s%sssocket error: %s(sOKsNOR(R:RZR;R<R0RR>RAR4t_new_tagt _checkquotettypet_commandRjRnR}RatOSErrorR3RJR=R?( RSRtRRVttagRmtargR<t literatortval((s/usr/lib64/python2.6/imaplib.pyR7s^              cCs|iy|i|\}}Wna|ij o"}|id||fn2|ij o"}|id||fnX|i|djo |id|||fn||fS(Nscommand: %s => %sRs%s command error: %s %s(Rt_get_tagged_responseR3R0(RSRtRRVRmR((s/usr/lib64/python2.6/imaplib.pyt_command_completes    cCsK|i}|i|i|ow|iid}||ijo|id|n|iid}|iid}||gf|i|R;tpop(RSRVRWRtRm((s/usr/lib64/python2.6/imaplib.pyRr3s   (KR1R2t__doc__t ExceptionR0R3R4RGRHRt IMAP4_PORTRYR_RCRfRhRnRpRaRuRwRRRLRRoRRRRRRRRRRRRRRRRRRRsRRRRR@RRRRRRRRRRRRRRRRRJRRRRRRR~Rr(((s/usr/lib64/python2.6/imaplib.pyRls,;                                   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)||_||_ti|||dS(N(tkeyfiletcertfileRRY(RSRTRURR((s/usr/lib64/python2.6/imaplib.pyRY{s  cCsO||_||_ti||f|_ti|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( RTRURaRbRctsslt wrap_socketRRtsslobj(RSRTRU((s/usr/lib64/python2.6/imaplib.pyRCs  cCsjg}d}xN||jo@|iit||d}|t|7}|i|qWdi|S(sRead 'size' bytes from remote.ii@R5(R RftminRjRR(RSRgtchunksRfRm((s/usr/lib64/python2.6/imaplib.pyRfs cCsJg}x=|iid}|i||djodi|Sq dS(sRead line from remote.is R5N(s R5(R RfRR(RSRktchar((s/usr/lib64/python2.6/imaplib.pyRhs   cCs]t|}xJ|djo<|ii|}||joPn||}||}qWdS(sSend data to remote.iN(RjR twrite(RSRmtbytestsent((s/usr/lib64/python2.6/imaplib.pyRns    cCs|iidS(s Close I/O established in "open".N(RcRo(RS((s/usr/lib64/python2.6/imaplib.pyRpscCs|iS(snReturn socket instance used to connect to IMAP4 server. socket = .socket() (Rc(RS((s/usr/lib64/python2.6/imaplib.pyRascCs|iS(sReturn SSLObject instance used to communicate with the IMAP4 server. ssl = ssl.wrap_socket(.socket) (R (RS((s/usr/lib64/python2.6/imaplib.pyR sN( R1R2RtIMAP4_SSL_PORTR;RYRCRfRhRnRpRaR (((s/usr/lib64/python2.6/imaplib.pyRls   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||_ti|dS(N(RRRY(RSR((s/usr/lib64/python2.6/imaplib.pyRYs c Csyd|_d|_d|_d|_ti|idtidtidt dt |_ |i i |_ |i i |_dS(sSetup a stream connection. This connection will be used by the routines: read, readline, send, shutdown. tstdintstdouttshellt close_fdsN(R;RTRURcRet subprocesstPopenRtPIPEtTrueRRt writefileRtreadfile(RSRTRU((s/usr/lib64/python2.6/imaplib.pyRCs    cCs|ii|S(sRead 'size' bytes from remote.(RRf(RSRg((s/usr/lib64/python2.6/imaplib.pyRfscCs |iiS(sRead line from remote.(RRh(RS((s/usr/lib64/python2.6/imaplib.pyRhscCs!|ii||iidS(sSend data to remote.N(RRtflush(RSRm((s/usr/lib64/python2.6/imaplib.pyRnscCs+|ii|ii|iidS(s Close I/O established in "open".N(RRoRRtwait(RS((s/usr/lib64/python2.6/imaplib.pyRps  N( R1R2RRYR;RCRfRhRnRp(((s/usr/lib64/python2.6/imaplib.pyRs     RcBs2eZdZdZdZdZdZRS(scPrivate class to provide en/decoding for base64-based authentication conversation. cCs ||_dS(N(R(RStmechinst((s/usr/lib64/python2.6/imaplib.pyRYscCs7|i|i|}|djodS|i|S(NR(RtdecodeR;tencode(RSRmtret((s/usr/lib64/python2.6/imaplib.pyRs cCsxd}xk|oct|djo|d }|d}n |}d}ti|}|o||d }q q W|S(NR5i0i(Rjtbinasciit b2a_base64(RStinptoupttte((s/usr/lib64/python2.6/imaplib.pyR! s  cCs|pdSti|S(NR5(R#t a2b_base64(RSR%((s/usr/lib64/python2.6/imaplib.pyR #s(R1R2RRYRR!R (((s/usr/lib64/python2.6/imaplib.pyRs    itJanitFebitMaritApritMayitJunitJulitAugi tSepi tOcti tNovi tDecc Cs}ti|}|pd St|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| }ti o|d o| ti } n| ti } ti| | S(sMConvert IMAP4 INTERNALDATE to UT. Returns Python time module tuple. tmontzonentdaytyearthourR tsectzonehtzonemi<t-iN( t InternalDateRR;tMon2numRRttimetmktimet localtimetdaylighttaltzonettimezone(RRR6R7R8R9R:R R;R<R=tzonettttutctlt((s/usr/lib64/python2.6/imaplib.pyR-s,  ! cCsTd}d}tt|}x/|o't|d\}}|||}q!W|S(s-Convert integer to A-P string representation.R5tABCDEFGHIJKLMNOPi(Rtabstdivmod(tnumRtAPtmod((s/usr/lib64/python2.6/imaplib.pyRYscCs4ti|}|pdSt|idiS(s-Convert IMAP4 flags response to python tuple.R((tFlagsRRMRRO(RR((s/usr/lib64/python2.6/imaplib.pyRfscCs t|ttfoti|}n`t|ttifo |}n=t|to |d|dfd jo|Stdti 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<(RR(t isinstanceRtfloatRARCRMt struct_timetstrt ValueErrortstrftimeRDRERFRM(RRHtdtRG((s/usr/lib64/python2.6/imaplib.pyRqs +  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)RRRuRoRwt UIDVALIDITYRtALLRRcCsktid||ftt||\}}tid|||f|djo|dn|S(Ns%s %ss %s => %s %sRi(tMt_mesgR[(tcmdRRVRW((s/usr/lib64/python2.6/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 (HRt __version__R#RDRGRaRRRAt__all__R}R8RRRQRiRZRHRRQR?RR{RRRRR t ImportErrorRRRRR@RRRRR1tgetopttgetpasstargvtoptlistRR0RR;tstream_commandtoptRRTtgetusertUSERtPASSWDt test_mesgt test_seq1t test_seq2RfRcR:RdRRRPRetmlRRRtpathRORWR(((s/usr/lib64/python2.6/imaplib.pyt s0 T                                    V 9,-- ,  #