ž Ź˙fżĂc&@s‘dZdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z m Z m Z ddlmZyddlZeZWnek rÔeZYnXdddd d d gZd ZdZd ZdZddfZdZi'ddfd6dfd6ddddfd6dfd6dfd6dfd6ddfd6ddfd6ddfd6ddfd6dfd6dfd 6ddfd!6ddfd"6ddfd#6ddfd$6ddfd%6ddfd&6dfd'6ddddfd6ddfd(6ddfd)6ddddfd*6dfd+6dfd,6ddfd-6dfd.6ddfd/6ddfd06ddfd16ddfd26dfd36dfd46ddfd56dfd66ddfd76dfd86dfd96ddfd:6Zejd;ƒZejd<ƒZejd=ƒZ ejd>ej!ƒZ"ejd?ƒZ#ejd@ƒZ$ejdAƒZ%ejdBej!ƒZ&GdCd„dƒZ'erŔGdDdE„dEe'ƒZ(ej)dEƒnGdFd„de'ƒZ*GdGdH„dHƒZ+dIj,dJƒZ-dKdL„e.e-dMd…ƒDƒZ/dNd„Z0dOd „Z1dPd „Z2dQd „Z3e4dRkrddl5Z5ddl6Z6y)e5j5ej7dMd…dSƒ\Z8Z9Wn:e5j:k rÔZ;zfff\Z8Z9WYddZ;[;XnXe<Z=xWe8D]O\Z>Z;e>dTkr e?e;ƒZn(e>dUkr1e;Z=e9 r.e=fZ9nnqâWe9 rHdVfZ9ne9dZ@e6jAƒZBe6j6dWeBe@psdXfƒZCdYieBdZ6d[d\6ZDd]eBeCffd^d_ffd`d_daffddbffdcdbe<e<eDffdddedfffdgdbffdhe<didjffdkdldmffdndldodpffdqffdrffdsffdtfffZEdgffdudvffdwd.dxffdudyffdce<e<e<eDffdsffdzfffZFd{d|„ZGy’e=rŮe*e=ƒZHn e'e@ƒZHeHjIdkreEdMd…ZEneHjJd}eHjKƒeHjJd~eHjLfƒx!eED]\ZMZ9eGeMe9ƒq9WxheGdddd€fƒD]QZNejOdeNƒZPePrœePjQdMƒZRneNj,ƒdM ZReGd‚eRfƒqlWx„eFD]|\ZMZ9eGeMe9ƒZSeMe9fdwd.dxffkrqČneSdM j,ƒZTeT r%qČneGdwd dƒeTdM d„fƒqČWeUd…ƒWn4eUd†ƒe r‚eUd‡ej7dƒn‚YnXndS(ˆuöIMAP4 client. Based on RFC 2060. Public class: IMAP4 Public variable: Debug Public functions: Internaldate2tuple Int2AP ParseFlags Time2Internaldate u2.58iN(udatetimeutimezoneu timedelta(uDEFAULT_BUFFER_SIZEuIMAP4u IMAP4_streamuInternaldate2tupleuInt2APu ParseFlagsuTime2Internaldates iiáu IMAP4REV1i'uAUTHuSELECTEDuAPPENDuNONAUTHu AUTHENTICATEuLOGOUTu CAPABILITYuCHECKuCLOSEuCOPYuCREATEuDELETEu DELETEACLuEXAMINEuEXPUNGEuFETCHuGETACLu GETANNOTATIONuGETQUOTAu GETQUOTAROOTuMYRIGHTSuLISTuLOGINuLSUBu NAMESPACEuNOOPuPARTIALu PROXYAUTHuRENAMEuSEARCHuSELECTuSETACLu SETANNOTATIONuSETQUOTAuSORTuSTARTTLSuSTATUSuSTOREu SUBSCRIBEuTHREADuUIDu 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.*))?cBsČ|EeZdZdZGdd„deƒZGdd„deƒZGdd„deƒZded d „Z d d „Z d d„Z dd„Z dedd„Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„Zd7d8„Z d9d:„Z!d;d<„Z"d=d>„Z#d?d@dAdB„Z$dCdD„Z%dEdF„Z&dGdH„Z'dIdJ„Z(d?d@dKdL„Z)dMdN„Z*dOdP„Z+dQdR„Z,dSdT„Z-dUdV„Z.dWdX„Z/dYdZ„Z0d[d™d\d]„Z2d^d_„Z3d`da„Z4dbdc„Z5ddde„Z6d˜dfdg„Z8dhdi„Z9djdk„Z:dldm„Z;dndo„Z<dpdq„Z=drds„Z>dtdu„Z?dvdw„Z@dxdy„ZAdzd{„ZBd|d}„ZCd~d„ZDd€d„ZEd‚dƒ„ZFd„d…„ZGd†d‡„ZHdˆd‰„ZIdŠd‹„ZJdŒd„ZKdŽd„ZLd˜dd‘„ZMd’d“„ZNd”d•„ZOd–d—„ZPd˜S(šuIMAP4uëIMAP4 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. cBs|EeZdZdS(u IMAP4.errorN(u__name__u __module__u __qualname__(u __locals__((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuerror¤suerrorcBs|EeZdZdS(u IMAP4.abortN(u__name__u __module__u __qualname__(u __locals__((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuabortĽsuabortcBs|EeZdZdS(uIMAP4.readonlyN(u__name__u __module__u __qualname__(u __locals__((u,/opt/alt/python33/lib64/python3.3/imaplib.pyureadonlyŚsureadonlyucCsąt|_d|_d|_i|_i|_d|_d|_ d|_ d|_ |j ||ƒy|j ƒWn;tk rŹy|jƒWntjk r¤YnX‚YnXdS(NuLOGOUTuiF(uDebugudebugustateuNoneuliteralutagged_commandsuuntagged_responsesucontinuation_responseuFalseu is_readonlyutagnumu_tls_establisheduopenu_connectu Exceptionushutdownusocketuerror(uselfuhostuport((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu__init__¨s$          uIMAP4.__init__cCs]ttjddƒƒ|_tjd|jdtjƒ|_d|_d|_ i|_ |j dkr|j dt ƒ|j d |jƒn|jƒ|_d |jkrşd |_n-d |jkrŐd |_n|j|jƒ‚|jƒ|j dkr|j d|jfƒnx-tD]%}||jkr<q!n||_dSW|jdƒ‚dS(Nii˙˙s(?Ps"\d+) (?P[A-Z]+) (?P.*)i iiuimaplib version %sunew IMAP4 connection, tag=%suPREAUTHuAUTHuOKuNONAUTHiuCAPABILITIES: %ruserver not IMAP4 compliant(uInt2APurandomurandintutagpreureucompileuASCIIutagreu _cmd_log_lenu _cmd_log_idxu_cmd_logudebugu_mesgu __version__u _get_responseuwelcomeuuntagged_responsesustateuerroru_get_capabilitiesu capabilitiesuAllowedVersionsuPROTOCOL_VERSION(uselfuversion((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_connectÁs0        uIMAP4._connectcCs3|tkrt||jƒƒStd|ƒ‚dS(NuUnknown IMAP4 command: '%s'(uCommandsugetattruloweruAttributeError(uselfuattr((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu __getattr__ës uIMAP4.__getattr__cCstj|j|jfƒS(N(usocketucreate_connectionuhostuport(uself((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_create_socketösuIMAP4._create_socketcCs:||_||_|jƒ|_|jjdƒ|_dS(uŃSetup connection to remote server on "host:port" (default: localhost:standard IMAP4 port). This connection will be used by the routines: read, readline, send, shutdown. urbN(uhostuportu_create_socketusockumakefileufile(uselfuhostuport((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuopenůs  u IMAP4.opencCs|jj|ƒS(uRead 'size' bytes from remote.(ufileuread(uselfusize((u,/opt/alt/python33/lib64/python3.3/imaplib.pyureadsu IMAP4.readcCsB|jjtdƒ}t|ƒtkr>|jdtƒ‚n|S(uRead line from remote.iugot more than %d bytes(ufileureadlineu_MAXLINEulenuerror(uselfuline((u,/opt/alt/python33/lib64/python3.3/imaplib.pyureadline suIMAP4.readlinecCs|jj|ƒdS(uSend data to remote.N(usockusendall(uselfudata((u,/opt/alt/python33/lib64/python3.3/imaplib.pyusendsu IMAP4.sendcCs€|jjƒz^y|jjtjƒWn@tjk ri}z|jtjkrW‚nWYdd}~XnXWd|jjƒXdS(u Close I/O established in "open".N( ufileucloseusockushutdownusocketu SHUT_RDWRuerroruerrnouENOTCONN(uselfue((u,/opt/alt/python33/lib64/python3.3/imaplib.pyushutdowns uIMAP4.shutdowncCs|jS(ufReturn socket instance used to connect to IMAP4 server. socket = .socket() (usock(uself((u,/opt/alt/python33/lib64/python3.3/imaplib.pyusocket$su IMAP4.socketcCs]d}|jddg|ƒ\}}|dr8||fS|jƒ\}}|j|||ƒS(uReturn 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. uRECENTuOKiNi˙˙˙˙(u_untagged_responseuNoneunoop(uselfunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyurecent0s   u IMAP4.recentcCs|j|dg|jƒƒS(uĽReturn data for response 'code' if received, or None. Old value for response 'code' is cleared. (code, [data]) = .response(code) N(u_untagged_responseuNoneuupper(uselfucode((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuresponseAsuIMAP4.responsecCs‘d}|sd}n|rE|d|dfd krKd|}qKnd }|r`t|ƒ}nd }tjt|ƒ|_|j||||ƒS( u°Append message to named mailbox. (typ, [data]) = .append(mailbox, flags, date_time, message) All args except `message' can be None. uAPPENDuINBOXiiu(u)u(%s)i˙˙˙˙(u(u)N(uNoneuTime2InternaldateuMapCRLFusubuCRLFuliteralu_simple_command(uselfumailboxuflagsu date_timeumessageuname((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuappendOs u IMAP4.appendcCsk|jƒ}t|ƒj|_|jd|ƒ\}}|dkrX|j|dƒ‚nd|_||fS(usAuthenticate 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; the response argument it is passed will be a bytes. It should return bytes data that will be base64 encoded and sent to the server. It should return None if the client abort response '*' should be sent instead. u AUTHENTICATEuOKiuAUTHi˙˙˙˙(uupperu_Authenticatoruprocessuliteralu_simple_commanduerrorustate(uselfu mechanismu authobjectumechutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu authenticatefs   uIMAP4.authenticatecCs.d}|j|ƒ\}}|j|||ƒS(uT(typ, [data]) = .capability() Fetch capabilities list from server.u CAPABILITY(u_simple_commandu_untagged_response(uselfunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu capabilityƒsuIMAP4.capabilitycCs |jdƒS(uRCheckpoint mailbox on server. (typ, [data]) = .check() uCHECK(u_simple_command(uself((u,/opt/alt/python33/lib64/python3.3/imaplib.pyucheckŒsu IMAP4.checkc Cs0z|jdƒ\}}Wdd|_X||fS(uĚClose currently selected mailbox. Deleted messages are removed from writable mailbox. This is the recommended command before 'LOGOUT'. (typ, [data]) = .close() uCLOSENuAUTH(u_simple_commandustate(uselfutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuclose”s u IMAP4.closecCs|jd||ƒS(u‚Copy 'message_set' messages onto end of 'new_mailbox'. (typ, [data]) = .copy(message_set, new_mailbox) uCOPY(u_simple_command(uselfu message_setu new_mailbox((u,/opt/alt/python33/lib64/python3.3/imaplib.pyucopyŁsu IMAP4.copycCs|jd|ƒS(uPCreate new mailbox. (typ, [data]) = .create(mailbox) uCREATE(u_simple_command(uselfumailbox((u,/opt/alt/python33/lib64/python3.3/imaplib.pyucreateŤsu IMAP4.createcCs|jd|ƒS(uPDelete old mailbox. (typ, [data]) = .delete(mailbox) uDELETE(u_simple_command(uselfumailbox((u,/opt/alt/python33/lib64/python3.3/imaplib.pyudeletełsu IMAP4.deletecCs|jd||ƒS(u€Delete the ACLs (remove any rights) set for who on mailbox. (typ, [data]) = .deleteacl(mailbox, who) u DELETEACL(u_simple_command(uselfumailboxuwho((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu deleteaclşsuIMAP4.deleteaclcCs.d}|j|ƒ\}}|j|||ƒS(u÷Permanently 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. uEXPUNGE(u_simple_commandu_untagged_response(uselfunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuexpungeÁs u IMAP4.expungecCs4d}|j|||ƒ\}}|j|||ƒS(u#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. uFETCH(u_simple_commandu_untagged_response(uselfu message_setu message_partsunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyufetchĎs u IMAP4.fetchcCs+|jd|ƒ\}}|j||dƒS(uXGet the ACLs for a mailbox. (typ, [data]) = .getacl(mailbox) uGETACLuACL(u_simple_commandu_untagged_response(uselfumailboxutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyugetaclŢsu IMAP4.getaclcCs1|jd|||ƒ\}}|j||dƒS(ua(typ, [data]) = .getannotation(mailbox, entry, attribute) Retrieve ANNOTATIONs.u GETANNOTATIONu ANNOTATION(u_simple_commandu_untagged_response(uselfumailboxuentryu attributeutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu getannotationçsuIMAP4.getannotationcCs+|jd|ƒ\}}|j||dƒS(uŞGet the quota root's resource usage and limits. Part of the IMAP4 QUOTA extension defined in rfc2087. (typ, [data]) = .getquota(root) uGETQUOTAuQUOTA(u_simple_commandu_untagged_response(uselfurootutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyugetquotaďsuIMAP4.getquotacCs^|jd|ƒ\}}|j||dƒ\}}|j||dƒ\}}|||gfS(uœGet the list of quota roots for the named mailbox. (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = .getquotaroot(mailbox) u GETQUOTAROOTuQUOTAu QUOTAROOT(u_simple_commandu_untagged_response(uselfumailboxutypudatuquotau quotaroot((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu getquotarootúsuIMAP4.getquotarootu""u*cCs4d}|j|||ƒ\}}|j|||ƒS(uŤList mailbox names in directory matching pattern. (typ, [data]) = .list(directory='""', pattern='*') 'data' is list of LIST responses. uLIST(u_simple_commandu_untagged_response(uselfu directoryupatternunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyulistsu IMAP4.listcCsY|jd||j|ƒƒ\}}|dkrF|j|dƒ‚nd|_||fS(u”Identify client using plaintext password. (typ, [data]) = .login(user, password) NB: 'password' will be quoted. uLOGINuOKiuAUTHi˙˙˙˙(u_simple_commandu_quoteuerrorustate(uselfuuserupasswordutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyulogins $  u IMAP4.logincCs&|||_|_|jd|jƒS(ur Force use of CRAM-MD5 authentication. (typ, [data]) = .login_cram_md5(user, password) uCRAM-MD5(uuserupasswordu authenticateu_CRAM_MD5_AUTH(uselfuuserupassword((u,/opt/alt/python33/lib64/python3.3/imaplib.pyulogin_cram_md5suIMAP4.login_cram_md5cCsZddl}t|jtƒr0|jjdƒn|j}|jd|j||ƒjƒS(u1 Authobject to use with CRAM-MD5 authentication. iNuASCIIu (uhmacu isinstanceupasswordustruencodeuuseruHMACu hexdigest(uselfu challengeuhmacupwd((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_CRAM_MD5_AUTH(s $ uIMAP4._CRAM_MD5_AUTHc Cs…d|_y|jdƒ\}}Wn,ddtjƒdd…g}}YnX|jƒd|jkr{d|jdfS||fS(u|Shutdown connection to server. (typ, [data]) = .logout() Returns server 'BYE' response. uLOGOUTuNOu%s: %sNiuBYE(ustateu_simple_commandusysuexc_infoushutdownuuntagged_responses(uselfutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyulogout0s ) u IMAP4.logoutcCs4d}|j|||ƒ\}}|j|||ƒS(uĐList 'subscribed' mailbox names in directory matching pattern. (typ, [data, ...]) = .lsub(directory='""', pattern='*') 'data' are tuples of message part envelope and data. uLSUB(u_simple_commandu_untagged_response(uselfu directoryupatternunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyulsub@su IMAP4.lsubcCs+|jd|ƒ\}}|j||dƒS(uƒShow my ACLs for a mailbox (i.e. the rights that I have on mailbox). (typ, [data]) = .myrights(mailbox) uMYRIGHTS(u_simple_commandu_untagged_response(uselfumailboxutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyumyrightsKsuIMAP4.myrightscCs.d}|j|ƒ\}}|j|||ƒS(ub Returns IMAP namespaces ala rfc2342 (typ, [data, ...]) = .namespace() u NAMESPACE(u_simple_commandu_untagged_response(uselfunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu namespaceSsuIMAP4.namespacecCs/|jdkr"|j|jƒn|jdƒS(uFSend NOOP command. (typ, [data]) = .noop() iuNOOP(udebugu_dump_uruuntagged_responsesu_simple_command(uself((u,/opt/alt/python33/lib64/python3.3/imaplib.pyunoop]su IMAP4.noopcCs:d}|j|||||ƒ\}}|j||dƒS(uÂFetch truncated part of a message. (typ, [data, ...]) = .partial(message_num, message_part, start, length) 'data' is tuple of message part envelope and data. uPARTIALuFETCH(u_simple_commandu_untagged_response(uselfu message_numu message_partustartulengthunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyupartialhs!u IMAP4.partialcCsd}|jd|ƒS(ułAssume authentication as "user". Allows an authorised administrator to proxy into any user's mailbox. (typ, [data]) = .proxyauth(user) u PROXYAUTH(u_simple_command(uselfuuseruname((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu proxyauthts uIMAP4.proxyauthcCs|jd||ƒS(ukRename old mailbox name to new. (typ, [data]) = .rename(oldmailbox, newmailbox) uRENAME(u_simple_command(uselfu oldmailboxu newmailbox((u,/opt/alt/python33/lib64/python3.3/imaplib.pyurenamesu IMAP4.renamecGsXd}|r-|j|d||Œ\}}n|j||Œ\}}|j|||ƒS(uˇSearch mailbox for matching messages. (typ, [data]) = .search(charset, criterion, ...) 'data' is space separated list of matching message numbers. uSEARCHuCHARSET(u_simple_commandu_untagged_response(uselfucharsetucriteriaunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyusearch‰s !u IMAP4.searchuINBOXcCsŃi|_||_|r!d}nd}|j||ƒ\}}|dkr^d|_||fSd|_d|jkrľ| rľ|jdkrŸ|j|jƒn|jd|ƒ‚n||jjd d gƒfS( utSelect 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. uEXAMINEuSELECTuOKuAUTHuSELECTEDu READ-ONLYiu%s is not writableuEXISTSN( uuntagged_responsesu is_readonlyu_simple_commandustateudebugu_dump_urureadonlyugetuNone(uselfumailboxureadonlyunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuselect˜s       u IMAP4.selectcCs|jd|||ƒS(uZSet a mailbox acl. (typ, [data]) = .setacl(mailbox, who, what) uSETACL(u_simple_command(uselfumailboxuwhouwhat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyusetacl¸su IMAP4.setaclcGs+|jd|Œ\}}|j||dƒS(u_(typ, [data]) = .setannotation(mailbox[, entry, attribute]+) Set ANNOTATIONs.u SETANNOTATIONu ANNOTATION(u_simple_commandu_untagged_response(uselfuargsutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu setannotationŔsuIMAP4.setannotationcCs.|jd||ƒ\}}|j||dƒS(uiSet the quota root's resource limits. (typ, [data]) = .setquota(root, limits) uSETQUOTAuQUOTA(u_simple_commandu_untagged_response(uselfurootulimitsutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyusetquotaČsuIMAP4.setquotacGs^d}|d|dfdkr-d|}n|j||||Œ\}}|j|||ƒS( uIMAP4rev1 extension SORT command. (typ, [data]) = .sort(sort_criteria, charset, search_criteria, ...) uSORTiiu(u)u(%s)i˙˙˙˙(u(u)(u_simple_commandu_untagged_response(uselfu sort_criteriaucharsetusearch_criteriaunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyusortŃs  u IMAP4.sortcCsd}ts|jdƒ‚n|jr9|jdƒ‚n||jkrZ|jdƒ‚n|dkrtjtjƒ}|j tj O_ n|j |ƒ\}}|dkrî|j |j ƒ|_ |j jdƒ|_d|_|jƒn|jdƒ‚|j|||ƒS( NuSTARTTLSuSSL support missinguTLS session already establisheduTLS not supported by serveruOKurbuCouldn't establish TLS sessionT(uHAVE_SSLuerroru_tls_establisheduabortu capabilitiesuNoneusslu SSLContextuPROTOCOL_SSLv23uoptionsu OP_NO_SSLv2u_simple_commandu wrap_socketusockumakefileufileuTrueu_get_capabilitiesu_untagged_response(uselfu ssl_contextunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyustarttlsßs$     uIMAP4.starttlscCs4d}|j|||ƒ\}}|j|||ƒS(upRequest named status conditions for mailbox. (typ, [data]) = .status(mailbox, names) uSTATUS(u_simple_commandu_untagged_response(uselfumailboxunamesunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyustatus÷su IMAP4.statuscCsX|d|dfd kr'd|}n|jd|||ƒ\}}|j||dƒS( uAlters flag dispositions for messages in mailbox. (typ, [data]) = .store(message_set, command, flags) iiu(u)u(%s)uSTOREuFETCHi˙˙˙˙(u(u)(u_simple_commandu_untagged_response(uselfu message_setucommanduflagsutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyustores u IMAP4.storecCs|jd|ƒS(uYSubscribe to new mailbox. (typ, [data]) = .subscribe(mailbox) u SUBSCRIBE(u_simple_command(uselfumailbox((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu subscribesuIMAP4.subscribecGs7d}|j||||Œ\}}|j|||ƒS(u‹IMAPrev1 extension THREAD command. (type, [data]) = .thread(threading_algorithm, charset, search_criteria, ...) uTHREAD(u_simple_commandu_untagged_response(uselfuthreading_algorithmucharsetusearch_criteriaunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuthreadsu IMAP4.threadcGsż|jƒ}|tkr.|jd|ƒ‚n|jt|krp|jd||jdjt|ƒfƒ‚nd}|j|||Œ\}}|d krŚ|}nd}|j|||ƒS( uĺExecute "command arg ..." with messages identified by UID, rather than message number. (typ, [data]) = .uid(command, arg1, arg2, ...) Returns response appropriate to 'command'. uUnknown IMAP4 UID command: %su9command %s illegal in state %s, only allowed in states %su, uUIDuSEARCHuSORTuTHREADuFETCH(uSEARCHuSORTuTHREAD(uupperuCommandsuerrorustateujoinu_simple_commandu_untagged_response(uselfucommanduargsunameutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuuid s      u IMAP4.uidcCs|jd|ƒS(u_Unsubscribe from old mailbox. (typ, [data]) = .unsubscribe(mailbox) u UNSUBSCRIBE(u_simple_command(uselfumailbox((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu unsubscribe9suIMAP4.unsubscribecGs;|jƒ}|tkr+|jft|.xatom(name, arg, ...) Returns response appropriate to extension command `name'. (uupperuCommandsustateu_simple_command(uselfunameuargs((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuxatomAs  u IMAP4.xatomcCs|dkrd}n|j}|jdkr\|jd|t|j|dƒƒ|fƒn||kr|||j|ƒn |g|||jjdƒ}|r:|j|djddƒƒ‚ndS(NuBYEiuasciiureplacei˙˙˙˙(uuntagged_responsesugetuabortudecode(uselfubye((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu _check_byeesuIMAP4._check_byec Gsţ|jt|krKd|_|jd||jdjt|ƒfƒ‚nx*dD]"}||jkrR|j|=qRqRWd|jkrŁ|j rŁ|jdƒ‚n|j ƒ}t |dƒ}|d |}xO|D]G}|dkrëqÓnt |t ƒr t |dƒ}n|d |}qÓW|j}|dk r†d|_t |ƒt |jƒkr`|}q†d}|t d t|ƒdƒ}n|jd krŠ|jd |ƒn|jd |ƒy|j|tƒWnAtjtfk r} z|jd | ƒ‚WYdd} ~ XnX|dkr#|SxÔx!|jƒrI|j|r)|Sq)W|rb||jƒ}n|jd kr‹|jdt|ƒƒny|j|ƒ|jtƒWnAtjtfk rě} z|jd | ƒ‚WYdd} ~ XnX|s&Pq&q&|S(Nu9command %s illegal in state %s, only allowed in states %su, uOKuNOuBADu READ-ONLYu#mailbox status changed to READ-ONLYuASCIIs u {%s}iu> %rusocket error: %suwrite literal size %s(uOKuNOuBAD(ustateuCommandsuNoneuliteraluerrorujoinuuntagged_responsesu is_readonlyureadonlyu_new_tagubytesu isinstanceustrutypeu_commandulenudebugu_mesgu_logusenduCRLFusocketuOSErroruabortu _get_responseutagged_commandsucontinuation_response( uselfunameuargsutyputagudatauarguliteralu literatoruval((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_commandksh             &   &uIMAP4._commandcCs|dkr|jƒny|j|ƒ\}}Wn|jk ru}z|jd||fƒ‚WYdd}~XnA|jk rľ}z|jd||fƒ‚WYdd}~XnX|dkrĎ|jƒn|dkrú|jd|||fƒ‚n||fS(NuLOGOUTucommand: %s => %suBADu%s command error: %s %s(u _check_byeu_get_tagged_responseuabortuerror(uselfunameutagutypudatauval((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_command_complete¸s  +,   uIMAP4._command_completecCsk|jƒ\}}|dgkr3|jdƒ‚nt|ddƒ}|jƒ}t|jƒƒ|_dS(Nu"no CAPABILITY response from serveriuASCIIi˙˙˙˙(u capabilityuNoneuerrorustruupperutupleusplitu capabilities(uselfutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_get_capabilitiesÉs  uIMAP4._get_capabilitiescCsÁ|jƒ}|j|j|ƒr¤|jjdƒ}||jkrX|jd|ƒ‚n|jjdƒ}t|dƒ}|jjdƒ}||gf|j| %r(umatchumouNoneudebugu_mesgupatternugroups(uselfucreus((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_matchPs&u IMAP4._matchcCs@|jtt|jƒdƒ}|jd|_d|j|<|S(NuASCIIi(utagpreubytesustrutagnumuNoneutagged_commands(uselfutag((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_new_tag\s uIMAP4._new_tagcCs0|jddƒ}|jddƒ}d|dS(Nu\u\\u"u\"(ureplace(uselfuarg((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_quotedsu IMAP4._quotecGs|j||j||ŒƒS(N(u_command_completeu_command(uselfunameuargs((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_simple_commandlsuIMAP4._simple_commandcCsw|dkr||fS||jkr2|dgfS|jj|ƒ}|jdkrm|jd||fƒn||fS(NuNOiuuntagged_responses[%s] => %s(uuntagged_responsesuNoneupopudebugu_mesg(uselfutypudatunameudata((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_untagged_responseqs   uIMAP4._untagged_responsecCsl|dkrtjƒ}ntjdtj|ƒƒ}tjjd||dd|fƒtjjƒdS(Nu%M:%Su %s.%02d %s id(uNoneutimeustrftimeu localtimeusysustderruwriteuflush(uselfususecsutm((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_mesgs  %u IMAP4._mesgcCsU|jƒ}|sdSd}tdd„|ƒ}|jd||j|ƒfƒdS(Nu cSs3d|d|ddr+dj|dƒp.dfS(Nu%s: "%s"iiu" "u(ujoin(ux((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu‹su IMAP4._dump_ur..uuntagged responses dump:%s%s(uitemsumapu_mesgujoin(uselfudictulut((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_dump_ur†s  uIMAP4._dump_urcCsM|tjƒf|j|j<|jd7_|j|jkrId|_ndS(Nii(utimeu_cmd_logu _cmd_log_idxu _cmd_log_len(uselfuline((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_logŽsu IMAP4._logc Cs|jdt|jƒƒ|j|j}}xY|rˆy|j|j|ŒWnYnX|d7}||jkr{d}n|d8}q0WdS(Nulast %d IMAP4 interactions:ii(u_mesgulenu_cmd_logu _cmd_log_idxu _cmd_log_len(uselfuiun((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu print_log•s   uIMAP4.print_logNF(Qu__name__u __module__u __qualname__u__doc__u Exceptionuerroruabortureadonlyu IMAP4_PORTu__init__u_connectu __getattr__u_create_socketuopenureadureadlineusendushutdownusocketurecenturesponseuappendu authenticateu capabilityucheckucloseucopyucreateudeleteu deleteacluexpungeufetchugetaclu getannotationugetquotau getquotarootulistuloginulogin_cram_md5u_CRAM_MD5_AUTHulogoutulsubumyrightsu namespaceunoopupartialu proxyauthurenameusearchuFalseuselectusetaclu setannotationusetquotausortuNoneustarttlsustatusustoreu subscribeuthreaduuidu unsubscribeuxatomu_append_untaggedu _check_byeu_commandu_command_completeu_get_capabilitiesu _get_responseu_get_tagged_responseu _get_lineu_matchu_new_tagu_quoteu_simple_commandu_untagged_responseu_mesgu_dump_uru_logu print_log(u __locals__((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuIMAP4vs”, *                                  M  P        cBsS|EeZdZdZded d d dd„Zdd„Zdedd„Zd S( u IMAP4_SSLu3IMAP4 client class over SSL connection Instantiate with: IMAP4_SSL([host[, port[, keyfile[, certfile[, ssl_context]]]]]) 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); ssl_context - a SSLContext object that contains your certificate chain and private key (default: None) Note: if ssl_context is provided, then parameters keyfile or certfile should not be set otherwise ValueError is raised. for more documentation see the docstring of the parent class IMAP4. ucCs€|dk r'|dk r'tdƒ‚n|dk rN|dk rNtdƒ‚n||_||_||_tj|||ƒdS(Nu8ssl_context and keyfile arguments are mutually exclusiveu9ssl_context and certfile arguments are mutually exclusive(uNoneu ValueErrorukeyfileucertfileu ssl_contextuIMAP4u__init__(uselfuhostuportukeyfileucertfileu ssl_context((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu__init__¸s   uIMAP4_SSL.__init__cCsEtj|ƒ}|jr(|jj|ƒStj||j|jƒSdS(N(uIMAP4u_create_socketu ssl_contextu wrap_socketusslukeyfileucertfile(uselfusock((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_create_socketĹs uIMAP4_SSL._create_socketcCstj|||ƒdS(ućSetup 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(uIMAP4uopen(uselfuhostuport((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuopenĚsuIMAP4_SSL.openN( u__name__u __module__u __qualname__u__doc__uIMAP4_SSL_PORTuNoneu__init__u_create_socketuopen(u __locals__((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu IMAP4_SSLĽs u IMAP4_SSLcBsh|EeZdZdZdd„Zdddd„Zdd„Zdd „Zd d „Z d d „Z dS(u IMAP4_streamuíIMAP4 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(ucommanduIMAP4u__init__(uselfucommand((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu__init__ăs uIMAP4_stream.__init__c Csd|_d|_d|_d|_tj|jdtdtj dtj ddddƒ|_ |j j |_ |j j|_dS(u…Setup a stream connection. This connection will be used by the routines: read, readline, send, shutdown. ubufsizeustdinustdoutushellu close_fdsNT(uNoneuhostuportusockufileu subprocessuPopenucommanduDEFAULT_BUFFER_SIZEuPIPEuTrueuprocessustdinu writefileustdoutureadfile(uselfuhostuport((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuopenčs    uIMAP4_stream.opencCs|jj|ƒS(uRead 'size' bytes from remote.(ureadfileuread(uselfusize((u,/opt/alt/python33/lib64/python3.3/imaplib.pyureadřsuIMAP4_stream.readcCs |jjƒS(uRead line from remote.(ureadfileureadline(uself((u,/opt/alt/python33/lib64/python3.3/imaplib.pyureadlineýsuIMAP4_stream.readlinecCs!|jj|ƒ|jjƒdS(uSend data to remote.N(u writefileuwriteuflush(uselfudata((u,/opt/alt/python33/lib64/python3.3/imaplib.pyusendsuIMAP4_stream.sendcCs+|jjƒ|jjƒ|jjƒdS(u Close I/O established in "open".N(ureadfileucloseu writefileuprocessuwait(uself((u,/opt/alt/python33/lib64/python3.3/imaplib.pyushutdowns  uIMAP4_stream.shutdownN( u__name__u __module__u __qualname__u__doc__u__init__uNoneuopenureadureadlineusendushutdown(u __locals__((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu IMAP4_stream×s     cBsJ|EeZdZdZdd„Zdd„Zdd„Zdd „Zd S( u_AuthenticatorucPrivate class to provide en/decoding for base64-based authentication conversation. cCs ||_dS(N(umech(uselfumechinst((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu__init__su_Authenticator.__init__cCs5|j|j|ƒƒ}|dkr(dS|j|ƒS(Nu*(umechudecodeuNoneuencode(uselfudatauret((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuprocesss u_Authenticator.processcCsĽd}t|tƒr'|jdƒ}nxw|r t|ƒdkre|dd…}|dd…}n |}d}tj|ƒ}|r*||dd…}q*q*W|S(NsuASCIIi0ii˙˙˙˙(u isinstanceustruencodeulenubinasciiu b2a_base64(uselfuinpuouputue((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuencodes  u_Authenticator.encodecCs|s dStj|ƒS(Ns(ubinasciiu a2b_base64(uselfuinp((u,/opt/alt/python33/lib64/python3.3/imaplib.pyudecode7su_Authenticator.decodeN(u__name__u __module__u __qualname__u__doc__u__init__uprocessuencodeudecode(u __locals__((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu_Authenticators    u_Authenticatoru0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decu cCs)i|]\}}|d|jƒ“qS(i(uencode(u.0unus((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu =s u ic Cs7tj|ƒ}|sd St|jdƒ}|jdƒ}t|jdƒƒ}t|jdƒƒ}t|jdƒƒ}t|jdƒƒ}t|jdƒƒ}t|jdƒƒ} t|jd ƒƒ} | d | d } |d krö| } n||||||dddf } tj| ƒ| } tj | ƒS(u¨Parse an IMAP4 INTERNALDATE string. Return corresponding local time. The return value is a time.struct_time tuple or None if the string has wrong format. umonuzonenudayuyearuhouruminusecuzonehuzonemi<s-iNi˙˙˙˙i˙˙˙˙i˙˙˙˙( u InternalDateumatchuNoneuMon2numugroupuintucalendarutimegmutimeu localtime(urespumoumonuzonenudayuyearuhouruminusecuzonehuzonemuzoneuttuutc((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuInternaldate2tuple?s$  !cCs\d}d}tt|ƒƒ}x7|rWt|dƒ\}}|||d…|}q!W|S(u-Convert integer to A-P string representation.ssABCDEFGHIJKLMNOPii(uintuabsudivmod(unumuvaluAPumod((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuInt2APbs cCs2tj|ƒ}|sfSt|jdƒjƒƒS(u-Convert IMAP4 flags response to python tuple.uflags(uFlagsumatchutupleugroupusplit(urespumo((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu ParseFlagsoscCsŒt|ttfƒr3tj|tjƒjƒ}n6t|tƒrúy |j }Wntt k rĹt j rˇ|d}|d krt j t j|ƒƒd}nt jt jf| }n t j }YnXtd|ƒ}tdt|ƒ|dd…Œ}not|tƒr0|jdkr'tdƒ‚n|}n9t|tƒr]|d|d fdkr]|Std ƒ‚d jt|jƒ}|j|ƒS(učConvert 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, an instance of time.struct_time (as returned by time.localtime()), an aware datetime instance or a double-quoted string. In the last case, it is assumed to already be in the correct format. iiusecondsutzinfoNiudate_time must be awareiu"udate_time not of a known typeu"%d-{}-%Y %H:%M:%S %z"i˙˙˙˙i˙˙˙˙(u"u"(u isinstanceuintufloatudatetimeu fromtimestamputimezoneuutcu astimezoneutupleu tm_gmtoffuAttributeErrorutimeudaylightu localtimeumktimeualtzoneu timedeltautzinfouNoneu ValueErrorustruformatuMonthsumonthustrftime(u date_timeudtugmtoffudstudeltaufmt((u,/opt/alt/python33/lib64/python3.3/imaplib.pyuTime2Internaldatezs0       % ) u__main__ud:s:u-du-suuIMAP password for %s on %s: u localhostuJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)suuseru ulfuloginucreateu /tmp/xxx 1urenameu/tmp/yyyu /tmp/yyz 2uappendulistu/tmpuyy*uselectusearchuSUBJECTutestufetchu1u(FLAGS INTERNALDATE RFC822)ustoreuFLAGSu (\Deleted)u namespaceuexpungeurecentucloseuresponseu UIDVALIDITYuuiduALLuEXISTSulogoutcCsitjd||fƒtt|ƒ|Œ\}}tjd|||fƒ|dkre|d‚n|S(Nu%s %su %s => %s %suNOi(uMu_mesgugetattr(ucmduargsutypudat((u,/opt/alt/python33/lib64/python3.3/imaplib.pyurunŰs  urunuPROTOCOL_VERSION = %suCAPABILITIES = %ru/tmp/uyy%u .*"([^"]+)"$udeleteu%su:(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822.TEXT)u All tests OK.u Tests failed.u8 If you would like to see debugging output, try: %s -d5 (Vu__doc__u __version__ubinasciiuerrnourandomureusocketu subprocessusysutimeucalendarudatetimeutimezoneu timedeltauiouDEFAULT_BUFFER_SIZEussluTrueuHAVE_SSLu ImportErroruFalseu__all__uCRLFuDebugu IMAP4_PORTuIMAP4_SSL_PORTuAllowedVersionsu_MAXLINEuCommandsucompileu ContinuationuFlagsu InternalDateuASCIIuLiteraluMapCRLFu Response_codeuUntagged_responseuUntagged_statusuIMAP4u IMAP4_SSLuappendu IMAP4_streamu_AuthenticatorusplituMonthsu enumerateuMon2numuInternaldate2tupleuInt2APu ParseFlagsuTime2Internaldateu__name__ugetoptugetpassuargvuoptlistuargsuerroruvaluNoneustream_commanduoptuintuhostugetuseruUSERuPASSWDu test_mesgu test_seq1u test_seq2urunuMustateu_mesguPROTOCOL_VERSIONu capabilitiesucmdumlumatchumougroupupathudatuuiduprint(((u,/opt/alt/python33/lib64/python3.3/imaplib.pyu s8 l                                         ˙˙˙˙1/9,# # ) )%