%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/imaplib.cpython-38.pyc

U

n©ßafÑã*@sždZdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZm
Z
ddlmZzddlZdZWnek
r˜dZYnXdd	d
ddd
gZdZdZdZdZdZdZddddddddddddddddddddddddddddddddddddddddddœ)Ze d¡Ze d¡Ze d¡Ze dej¡Z e d¡Z!e d¡Z"e d¡Z#e d ej¡Z$dZ%d Z&Gd!d„dƒZ'er¨Gd"d#„d#e'ƒZ(e )d#¡Gd$d	„d	e'ƒZ*Gd%d&„d&ƒZ+d' ,d(¡Z-d)d*„e.e-d+d…ƒDƒZ/d,d
„Z0d-d„Z1d.d„Z2d/d
„Z3e4d0kršddl5Z5ddl6Z6ze5 5ej7d+d…d1¡\Z8Z9Wn.e5j:k
rpZ;zd2\Z8Z9W5dZ;[;XYnXdZ<e8D]8\Z=Z;e=d3kr–e>e;ƒZne=d4krze;Z<e9sze<fZ9qze9s¾d5Z9e9dZ?e6 @¡ZAe6 6d6eAe?pÞd7f¡ZBd8eAd9d:œZCd;eAeBffd<d=d>d?d@ddeCffdAdBdCdDdEdFdGdHdIfZDdJdKdLdMd?dddeCffdHdNfZEdOdP„ZFze<rbe*e<ƒZGne'e?ƒZGeGjHdQkr‚eDd+d…ZDeG IdReGjJ¡eG IdSeGjKf¡eDD]\ZLZ9eFeLe9ƒq¨eFdTdUƒD]<ZMe NdVeM¡ZOeOrêeO Pd+¡ZQneM ,¡dWZQeFdXeQfƒqÈeED]T\ZLZ9eFeLe9ƒZReLe9fdLkr.q
eRdW ,¡ZSeSsDq
eFdYdZd[eSdWd\fƒq
eTd]ƒWn.eTd^ƒes’eTd_ej7dƒ‚YnXdS)`zöIMAP4 client.

Based on RFC 2060.

Public class:           IMAP4
Public variable:        Debug
Public functions:       Internaldate2tuple
                        Int2AP
                        ParseFlags
                        Time2Internaldate
z2.58éN)ÚdatetimeÚtimezoneÚ	timedelta)ÚDEFAULT_BUFFER_SIZETFÚIMAP4ÚIMAP4_streamÚInternaldate2tupleÚInt2APÚ
ParseFlagsÚTime2Internaldateó
éiá)Z	IMAP4REV1ri@B)ÚAUTHÚSELECTED)ÚNONAUTH)rrrÚLOGOUT)r)r))ÚAPPENDÚAUTHENTICATEÚ
CAPABILITYÚCHECKÚCLOSEÚCOPYÚCREATEÚDELETEÚ	DELETEACLÚENABLEÚEXAMINEÚEXPUNGEÚFETCHÚGETACLÚ
GETANNOTATIONÚGETQUOTAÚGETQUOTAROOTÚMYRIGHTSÚLISTÚLOGINrÚLSUBZMOVEÚ	NAMESPACEÚNOOPÚPARTIALÚ	PROXYAUTHÚRENAMEÚSEARCHÚSELECTÚSETACLÚ
SETANNOTATIONÚSETQUOTAÚSORTÚSTARTTLSÚSTATUSÚSTOREÚ	SUBSCRIBEÚTHREADÚUIDÚUNSUBSCRIBEs\+( (?P<data>.*))?s.*FLAGS \((?P<flags>[^\)]*)\)sÕ.*INTERNALDATE "(?P<day>[ 0123][0-9])-(?P<mon>[A-Z][a-z][a-z])-(?P<year>[0-9][0-9][0-9][0-9]) (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9]) (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])"s.*{(?P<size>\d+)}$s
\r\n|\r|\ns%\[(?P<type>[A-Z-]+)( (?P<data>.*))?\]s$\* (?P<type>[A-Z-]+)( (?P<data>.*))?s3\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?c@s°eZdZdZGdd„deƒZGdd„deƒZGdd„deƒZdefd	d
„Z	dd„Z
d
d„Zdd„Zdd„Z
dd„Zdd„Zdd„Zdefdd„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@„Z$dAdB„Z%dCdD„Z&dEdF„Z'dGdH„Z(d¤dKdL„Z)dMdN„Z*dOdP„Z+dQdR„Z,dSdT„Z-d¥dUdV„Z.dWdX„Z/dYdZ„Z0d[d\„Z1d]d^„Z2d_d`„Z3dadb„Z4dcdd„Z5d¦dgdh„Z6didj„Z7dkdl„Z8dmdn„Z9dodp„Z:d§drds„Z;dtdu„Z<dvdw„Z=dxdy„Z>dzd{„Z?d|d}„Z@d~d„ZAd€d„ZBd‚dƒ„ZCd„d…„ZDd†d‡„ZEdˆd‰„ZFdŠd‹„ZGdŒd„ZHd¨dŽd„ZIdd‘„ZJd’d“„ZKd”d•„ZLd–d—„ZMd˜d™„ZNdšd›„ZOd©dœd„ZPdždŸ„ZQd d¡„ZRd¢d£„ZSdqS)ªraë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 <instance>.error("<reason>").
    IMAP4 server errors raise <instance>.abort("<reason>"),
    which is a sub-class of 'error'. Mailbox status changes
    from READ-WRITE to READ-ONLY raise the exception class
    <instance>.readonly("<reason>"), 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.
    c@seZdZdS)zIMAP4.errorN©Ú__name__Ú
__module__Ú__qualname__©r=r=ú#/usr/local/lib/python3.8/imaplib.pyÚerror´sr?c@seZdZdS)zIMAP4.abortNr9r=r=r=r>Úabortµsr@c@seZdZdS)zIMAP4.readonlyNr9r=r=r=r>Úreadonly¶srAÚcCs”t|_d|_d|_i|_i|_d|_d|_d|_d|_	| 
¡| ||¡z| ¡Wn8t
k
rŽz| ¡Wntk
r†YnX‚YnXdS)NrrBFr)ÚDebugÚdebugÚstateÚliteralÚtagged_commandsÚuntagged_responsesÚcontinuation_responseÚis_readonlyÚtagnumÚ_tls_establishedÚ_mode_asciiÚopenÚ_connectÚ	ExceptionÚshutdownÚOSError©ÚselfÚhostÚportr=r=r>Ú__init__¸s&zIMAP4.__init__cCs0d|_d|_t ttj¡|_t ttj¡|_dS)NFÚascii)	Úutf8_enabledÚ	_encodingÚreÚcompileÚ_LiteralÚASCIIÚLiteralÚ_Untagged_statusÚUntagged_status©rTr=r=r>rMÑszIMAP4._mode_asciicCs(d|_d|_t t¡|_t t¡|_dS)NTúutf-8)rYrZr[r\r]r_r`rarbr=r=r>Ú
_mode_utf8ØszIMAP4._mode_utf8cCsòtt dd¡ƒ|_t d|jdtj¡|_d|_d|_	i|_
|jdkrf| dt
¡| d	|j¡| ¡|_d
|jkr‚d|_nd|jkr”d
|_n| |j¡‚| ¡|jdkrÄ| d|jf¡tD]}||jkrØqÈ||_dS| d¡‚dS)Niiÿÿs(?P<tag>s"\d+) (?P<type>[A-Z]+) (?P<data>.*)é
rézimaplib version %sznew IMAP4 connection, tag=%sZPREAUTHrÚOKrézCAPABILITIES: %rzserver not IMAP4 compliant)r	ÚrandomÚrandintÚtagprer[r\r^ÚtagreÚ_cmd_log_lenÚ_cmd_log_idxÚ_cmd_logrDÚ_mesgÚ__version__Ú
_get_responseZwelcomerHrEr?Ú_get_capabilitiesÚcapabilitiesÚAllowedVersionsÚPROTOCOL_VERSION)rTÚversionr=r=r>rOßs:ÿþþ





zIMAP4._connectcCs&|tkrt|| ¡ƒStd|ƒ‚dS)NzUnknown IMAP4 command: '%s')ÚCommandsÚgetattrÚlowerÚAttributeError)rTÚattrr=r=r>Ú__getattr__	szIMAP4.__getattr__cCs|S©Nr=rbr=r=r>Ú	__enter__szIMAP4.__enter__cGs4|jdkrdSz| ¡Wntk
r.YnXdS)Nr)rEÚlogoutrR)rTÚargsr=r=r>Ú__exit__s
zIMAP4.__exit__cCs4|js
dn|j}t d||j|j¡t ||jf¡S)Nzimaplib.open)rUÚsysÚauditrVÚsocketÚcreate_connection)rTrUr=r=r>Ú_create_socketszIMAP4._create_socketcCs(||_||_| ¡|_|j d¡|_dS)zÑ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.
        ÚrbN)rUrVr‡ÚsockÚmakefileÚfilerSr=r=r>rN's
z
IMAP4.opencCs|j |¡S©zRead 'size' bytes from remote.)r‹Úread©rTÚsizer=r=r>r3sz
IMAP4.readcCs.|j td¡}t|ƒtkr*| dt¡‚|S)úRead line from remote.rfzgot more than %d bytes)r‹ÚreadlineÚ_MAXLINEÚlenr?©rTÚliner=r=r>r‘8szIMAP4.readlinecCst d||¡|j |¡dS)úSend data to remote.zimaplib.sendN)rƒr„r‰Úsendall©rTÚdatar=r=r>Úsend@sz
IMAP4.sendc
Cst|j ¡zXz|j tj¡Wn@tk
r^}z"|jtjkrNt	|ddƒdkrN‚W5d}~XYnXW5|j ¡XdS)ú Close I/O established in "open".Úwinerrorri&'N)
r‹Úcloser‰rQr…Ú	SHUT_RDWRrRÚerrnoZENOTCONNry)rTÚexcr=r=r>rQFs
ÿzIMAP4.shutdowncCs|jS)zfReturn socket instance used to connect to IMAP4 server.

        socket = <instance>.socket()
        )r‰rbr=r=r>r…VszIMAP4.socketcCsBd}| ddg|¡\}}|dr(||fS| ¡\}}| |||¡S)aReturn most recent 'RECENT' responses if any exist,
        else prompt server for an update using the 'NOOP' command.

        (typ, [data]) = <instance>.recent()

        'data' is None if no new messages,
        else list of RECENT responses, most recent last.
        ZRECENTrgNéÿÿÿÿ)Ú_untagged_responseÚnoop©rTÚnameÚtypÚdatr=r=r>Úrecentbs	zIMAP4.recentcCs| |dg| ¡¡S)z¥Return data for response 'code' if received, or None.

        Old value for response 'code' is cleared.

        (code, [data]) = <instance>.response(code)
        N)r¢Úupper)rTÚcoder=r=r>ÚresponsesszIMAP4.responsecCsxd}|sd}|r.|d|dfdkr2d|}nd}|r@t|ƒ}nd}t t|¡}|jrbd|d	}||_| ||||¡S)
z°Append message to named mailbox.

        (typ, [data]) = <instance>.append(mailbox, flags, date_time, message)

                All args except `message' can be None.
        rÚINBOXrr¡©ú(ú)ú(%s)NsUTF8 (ó))rÚMapCRLFÚsubÚCRLFrYrFÚ_simple_command)rTÚmailboxÚflagsÚ	date_timeÚmessager¥rFr=r=r>Úappends

zIMAP4.appendcCsP| ¡}t|ƒj|_| d|¡\}}|dkrB| |d dd¡¡‚d|_||fS)asAuthenticate command - requires response processing.

        'mechanism' specifies which authentication mechanism is to
        be used - it must appear in <instance>.capabilities in the
        form AUTH=<mechanism>.

        '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.
        rrgr¡rcÚreplacer)r©Ú_AuthenticatorÚprocessrFrµr?ÚdecoderE)rTZ	mechanismZ
authobjectÚmechr¦r§r=r=r>Úauthenticate›szIMAP4.authenticatecCs d}| |¡\}}| |||¡S)zT(typ, [data]) = <instance>.capability()
        Fetch capabilities list from server.r©rµr¢r¤r=r=r>Ú
capability¸szIMAP4.capabilitycCs
| d¡S)zRCheckpoint mailbox on server.

        (typ, [data]) = <instance>.check()
        r©rµrbr=r=r>ÚcheckÁszIMAP4.checkcCs$z| d¡\}}W5d|_X||fS)zÌClose currently selected mailbox.

        Deleted messages are removed from writable mailbox.
        This is the recommended command before 'LOGOUT'.

        (typ, [data]) = <instance>.close()
        rr)rErµ©rTr¦r§r=r=r>rÉszIMAP4.closecCs| d||¡S)z‚Copy 'message_set' messages onto end of 'new_mailbox'.

        (typ, [data]) = <instance>.copy(message_set, new_mailbox)
        rrÃ)rTÚmessage_setZnew_mailboxr=r=r>ÚcopyØsz
IMAP4.copycCs| d|¡S)zPCreate new mailbox.

        (typ, [data]) = <instance>.create(mailbox)
        rrérTr¶r=r=r>ÚcreateàszIMAP4.createcCs| d|¡S)zPDelete old mailbox.

        (typ, [data]) = <instance>.delete(mailbox)
        rrÃrÈr=r=r>ÚdeleteèszIMAP4.deletecCs| d||¡S)z€Delete the ACLs (remove any rights) set for who on mailbox.

        (typ, [data]) = <instance>.deleteacl(mailbox, who)
        rrÃ)rTr¶Úwhor=r=r>Ú	deleteaclïszIMAP4.deleteaclcCsHd|jkrt d¡‚| d|¡\}}|dkr@d| ¡kr@| ¡||fS)zkSend an RFC5161 enable string to the server.

        (typ, [data]) = <intance>.enable(capability)
        rzServer does not support ENABLErgzUTF8=ACCEPT)rtrr?rµr©rd)rTrÂr¦r™r=r=r>Úenableös

zIMAP4.enablecCs d}| |¡\}}| |||¡S)z÷Permanently remove deleted items from selected mailbox.

        Generates 'EXPUNGE' response for each deleted message.

        (typ, [data]) = <instance>.expunge()

        'data' is list of 'EXPUNGE'd message numbers in order received.
        rrÁr¤r=r=r>Úexpunges	z
IMAP4.expungecCs$d}| |||¡\}}| |||¡S)a#Fetch (parts of) messages.

        (typ, [data, ...]) = <instance>.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.
        rrÁ)rTrÆZ
message_partsr¥r¦r§r=r=r>Úfetchs
zIMAP4.fetchcCs| d|¡\}}| ||d¡S)zXGet the ACLs for a mailbox.

        (typ, [data]) = <instance>.getacl(mailbox)
        rZACLrÁ©rTr¶r¦r§r=r=r>ÚgetaclszIMAP4.getaclcCs"| d|||¡\}}| ||d¡S)za(typ, [data]) = <instance>.getannotation(mailbox, entry, attribute)
        Retrieve ANNOTATIONs.r Ú
ANNOTATIONrÁ)rTr¶ÚentryZ	attributer¦r§r=r=r>Ú
getannotation(szIMAP4.getannotationcCs| d|¡\}}| ||d¡S)zªGet the quota root's resource usage and limits.

        Part of the IMAP4 QUOTA extension defined in rfc2087.

        (typ, [data]) = <instance>.getquota(root)
        r!ÚQUOTArÁ)rTÚrootr¦r§r=r=r>Úgetquota0szIMAP4.getquotacCs@| d|¡\}}| ||d¡\}}| ||d¡\}}|||gfS)zœGet the list of quota roots for the named mailbox.

        (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
        r"rÕZ	QUOTAROOTrÁ)rTr¶r¦r§ZquotaZ	quotarootr=r=r>Úgetquotaroot;szIMAP4.getquotarootú""Ú*cCs$d}| |||¡\}}| |||¡S)z«List mailbox names in directory matching pattern.

        (typ, [data]) = <instance>.list(directory='""', pattern='*')

        'data' is list of LIST responses.
        r$rÁ©rTZ	directoryÚpatternr¥r¦r§r=r=r>ÚlistFsz
IMAP4.listcCs<| d|| |¡¡\}}|dkr.| |d¡‚d|_||fS)z”Identify client using plaintext password.

        (typ, [data]) = <instance>.login(user, password)

        NB: 'password' will be quoted.
        r%rgr¡r)rµÚ_quoter?rE)rTÚuserÚpasswordr¦r§r=r=r>ÚloginRs
zIMAP4.logincCs|||_|_| d|j¡S)zr Force use of CRAM-MD5 authentication.

        (typ, [data]) = <instance>.login_cram_md5(user, password)
        zCRAM-MD5)rßràrÀÚ_CRAM_MD5_AUTH)rTrßràr=r=r>Úlogin_cram_md5`szIMAP4.login_cram_md5cCsBddl}t|jtƒr |j d¡n|j}|jd| ||d¡ ¡S)z1 Authobject to use with CRAM-MD5 authentication. rNrcú Úmd5)ÚhmacÚ
isinstanceràÚstrÚencoderßZHMACÚ	hexdigest)rTZ	challengeræÚpwdr=r=r>râis
ÿzIMAP4._CRAM_MD5_AUTHcCs$d|_| d¡\}}| ¡||fS)z|Shutdown connection to server.

        (typ, [data]) = <instance>.logout()

        Returns server 'BYE' response.
        r)rErµrQrÅr=r=r>r€qszIMAP4.logoutcCs$d}| |||¡\}}| |||¡S)zÐList 'subscribed' mailbox names in directory matching pattern.

        (typ, [data, ...]) = <instance>.lsub(directory='""', pattern='*')

        'data' are tuples of message part envelope and data.
        r&rÁrÛr=r=r>Úlsub~sz
IMAP4.lsubcCs| d|¡\}}| ||d¡S)zƒShow my ACLs for a mailbox (i.e. the rights that I have on mailbox).

        (typ, [data]) = <instance>.myrights(mailbox)
        r#rÁrÐr=r=r>Úmyrights‰szIMAP4.myrightscCs d}| |¡\}}| |||¡S)zb Returns IMAP namespaces ala rfc2342

        (typ, [data, ...]) = <instance>.namespace()
        r'rÁr¤r=r=r>Ú	namespace‘szIMAP4.namespacecCs |jdkr| |j¡| d¡S)zFSend NOOP command.

        (typ, [data]) = <instance>.noop()
        rhr()rDÚ_dump_urrHrµrbr=r=r>r£›s
z
IMAP4.noopcCs(d}| |||||¡\}}| ||d¡S)zÂFetch truncated part of a message.

        (typ, [data, ...]) = <instance>.partial(message_num, message_part, start, length)

        'data' is tuple of message part envelope and data.
        r)rrÁ)rTZmessage_numZmessage_partÚstartÚlengthr¥r¦r§r=r=r>Úpartial¦sz
IMAP4.partialcCsd}| d|¡S)z³Assume authentication as "user".

        Allows an authorised administrator to proxy into any user's
        mailbox.

        (typ, [data]) = <instance>.proxyauth(user)
        r*rÃ)rTrßr¥r=r=r>Ú	proxyauth²s	zIMAP4.proxyauthcCs| d||¡S)zkRename old mailbox name to new.

        (typ, [data]) = <instance>.rename(oldmailbox, newmailbox)
        r+rÃ)rTZ
oldmailboxZ
newmailboxr=r=r>Úrename¿szIMAP4.renamecGsTd}|r2|jrt d¡‚|j|d|f|žŽ\}}n|j|f|žŽ\}}| |||¡S)zéSearch mailbox for matching messages.

        (typ, [data]) = <instance>.search(charset, criterion, ...)

        'data' is space separated list of matching message numbers.
        If UTF8 is enabled, charset MUST be None.
        r,z'Non-None charset not valid in UTF8 modeÚCHARSET)rYrr?rµr¢)rTÚcharsetZcriteriar¥r¦r§r=r=r>ÚsearchÇs
zIMAP4.searchr¬FcCsŒi|_||_|rd}nd}| ||¡\}}|dkr@d|_||fSd|_d|jkrx|sx|jdkrj| |j¡| d|¡‚||j d	d
g¡fS)atSelect a mailbox.

        Flush all untagged responses.

        (typ, [data]) = <instance>.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 <instance>.response('FLAGS') etc.
        rr-rgrrú	READ-ONLYrfz%s is not writableÚEXISTSN)rHrJrµrErDrïrAÚget)rTr¶rAr¥r¦r§r=r=r>ÚselectÙs"
ÿ
zIMAP4.selectcCs| d|||¡S)zZSet a mailbox acl.

        (typ, [data]) = <instance>.setacl(mailbox, who, what)
        r.rÃ)rTr¶rËZwhatr=r=r>ÚsetaclùszIMAP4.setaclcGs |jd|žŽ\}}| ||d¡S)z_(typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+)
        Set ANNOTATIONs.r/rÒ)r/rÁ)rTrr¦r§r=r=r>Ú
setannotationszIMAP4.setannotationcCs | d||¡\}}| ||d¡S)ziSet the quota root's resource limits.

        (typ, [data]) = <instance>.setquota(root, limits)
        r0rÕrÁ)rTrÖZlimitsr¦r§r=r=r>Úsetquota	szIMAP4.setquotacGsFd}|d|dfdkr d|}|j|||f|žŽ\}}| |||¡S)zIMAP4rev1 extension SORT command.

        (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
        r1rr¡r­r°rÁ)rTZ
sort_criteriaröÚsearch_criteriar¥r¦r§r=r=r>Úsorts
z
IMAP4.sortNcCs¦d}ts| d¡‚|jr"| d¡‚||jkr6| d¡‚|dkrFt ¡}| |¡\}}|dkrŽ|j|j	|j
d|_	|j	 d¡|_d|_| 
¡n
| d	¡‚| |||¡S)
Nr2zSSL support missingzTLS session already establishedzTLS not supported by serverrg©Zserver_hostnamerˆTzCouldn't establish TLS session)ÚHAVE_SSLr?rLr@rtÚsslÚ_create_stdlib_contextrµÚwrap_socketr‰rUrŠr‹rsr¢)rTÚssl_contextr¥r¦r§r=r=r>Ústarttls s&



ÿ

zIMAP4.starttlscCs$d}| |||¡\}}| |||¡S)zpRequest named status conditions for mailbox.

        (typ, [data]) = <instance>.status(mailbox, names)
        r3rÁ)rTr¶Únamesr¥r¦r§r=r=r>Ústatus7szIMAP4.statuscCs>|d|dfdkrd|}| d|||¡\}}| ||d¡S)zAlters flag dispositions for messages in mailbox.

        (typ, [data]) = <instance>.store(message_set, command, flags)
        rr¡r­r°r4rrÁ)rTrÆÚcommandr·r¦r§r=r=r>ÚstoreCszIMAP4.storecCs| d|¡S)zYSubscribe to new mailbox.

        (typ, [data]) = <instance>.subscribe(mailbox)
        r5rÃrÈr=r=r>Ú	subscribeNszIMAP4.subscribecGs*d}|j|||f|žŽ\}}| |||¡S)z‹IMAPrev1 extension THREAD command.

        (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
        r6rÁ)rTZthreading_algorithmrörÿr¥r¦r§r=r=r>ÚthreadVszIMAP4.threadc	Gs†| ¡}|tkr| d|¡‚|jt|krL| d||jd t|¡f¡‚d}|j||f|žŽ\}}|dkrt|}nd}| |||¡S)zåExecute "command arg ..." with messages identified by UID,
                rather than message number.

        (typ, [data]) = <instance>.uid(command, arg1, arg2, ...)

        Returns response appropriate to 'command'.
        zUnknown IMAP4 UID command: %sú9command %s illegal in state %s, only allowed in states %sú, r7)r,r1r6r)r©rxr?rEÚjoinrµr¢)rTr
rr¥r¦r§r=r=r>Úuid`sÿþz	IMAP4.uidcCs| d|¡S)z_Unsubscribe from old mailbox.

        (typ, [data]) = <instance>.unsubscribe(mailbox)
        r8rÃrÈr=r=r>ÚunsubscribeyszIMAP4.unsubscribecGs,| ¡}|tkr|jft|<|j|f|žŽS)aAllow simple extension commands
                notified by server in CAPABILITY response.

        Assumes command is legal in current state.

        (typ, [data]) = <instance>.xatom(name, arg, ...)

        Returns response appropriate to extension command `name'.
        )r©rxrErµ©rTr¥rr=r=r>Úxatoms
zIMAP4.xatomc	Csb|dkrd}|j}|jdkr<| d|t| |d¡ƒ|f¡||krT|| |¡n
|g||<dS)Nóéz#untagged_responses[%s] %s += ["%r"]rB)rHrDrpr“rúrº)rTr¦r§Úurr=r=r>Ú_append_untagged—s
ÿzIMAP4._append_untaggedcCs,|j d¡}|r(| |d |jd¡¡‚dS)NÚBYEr¡r»)rHrúr@r¾rZ)rTÚbyer=r=r>Ú
_check_bye¥szIMAP4._check_byec

Gs2|jt|kr4d|_| d||jd t|¡f¡‚dD]}||jkr8|j|=q8d|jkrj|jsj| d¡‚| ¡}t	||j
ƒ}|d|}|D]0}|dkrœqŽt|tƒr²t	||j
ƒ}|d|}qŽ|j}|dk	r
d|_t
|ƒt
|jƒkrî|}nd}|t	dt|ƒ|j
ƒ}|jdkr&| d	|¡n| d	|¡z| |t¡Wn2tk
rx}	z| d
|	¡‚W5d}	~	XYnX|dkrˆ|S| ¡r¦|j|rˆ|Sqˆ|r¶||jƒ}|jdkrÔ| dt|ƒ¡z| |¡| t¡Wn2tk
r}	z| d
|	¡‚W5d}	~	XYnX|sˆq.qˆ|S)Nrr©rgÚNOÚBADrøz#mailbox status changed to READ-ONLYó z {%s}éz> %rzsocket error: %szwrite literal size %s)rErxrFr?rrHrJrAÚ_new_tagÚbytesrZrçrèÚtypeÚ_commandr“rDrpÚ_logršr´rRr@rrrGrI)
rTr¥rr¦Útagr™ÚargrFZ	literatorÚvalr=r=r>r$«slÿþ


ÿ


 



 zIMAP4._commandc
CsÆ|dk}|s| ¡z|j||d\}}Wnj|jk
r`}z| d||f¡‚W5d}~XYn6|jk
r”}z| d||f¡‚W5d}~XYnX|s¢| ¡|dkr¾| d|||f¡‚||fS)Nr)Ú
expect_byezcommand: %s => %srz%s command error: %s %s)rÚ_get_tagged_responser@r?)rTr¥r&r€r¦r™r(r=r=r>Ú_command_completeøs"$zIMAP4._command_completecCsJ| ¡\}}|dgkr | d¡‚t|d|jƒ}| ¡}t| ¡ƒ|_dS)Nz"no CAPABILITY response from serverr¡)rÂr?rèrZr©ÚtupleÚsplitrtrÅr=r=r>rs
s

zIMAP4._get_capabilitiescCsò| ¡}| |j|¡rr|j d¡}||jkr:| d|¡‚|j d¡}t||jƒ}|j d¡}||gf|j|<nd}| t	|¡sœ| |j
|¡rœ|j d¡}|jdkrÒ| t|¡rÄ|j d¡|_dS| d|¡‚|j d¡}t||jƒ}|j d¡}|dkrd}|r|d|}| |j
|¡rvt|j d	¡ƒ}|jd
krP| d|¡| |¡}| |||f¡| ¡}q| ||¡|dkrÆ| t|¡rÆ|j d¡}t||jƒ}| ||j d¡¡|jd
krî|dkrî| d||f¡|S)Nr&zunexpected tagged response: %rr#r™Zdata2zunexpected response: %rrrrr zread literal size %srrf)rrrz%s response: %r)Ú	_get_lineÚ_matchrlÚmoÚgrouprGr@rèrZÚUntagged_responseraÚContinuationrIr_ÚintrDrprrÚ
Response_code)rTÚrespr&r¦r§Zdat2rr™r=r=r>rrsP



zIMAP4._get_responsec
Cs˜|j|}|dk	r|j|=|S|rDd}|j |d¡}|dk	rD||fS| ¡z| ¡Wq|jk
r}z|jdkr~| ¡‚W5d}~XYqXqdS)Nrrf)rGrHÚpoprrrr@rDÚ	print_log)rTr&r)Úresultr¦rr(r=r=r>r*cs 

zIMAP4._get_tagged_responsecCsf| ¡}|s| d¡‚| d¡s.| d|¡‚|dd…}|jdkrT| d|¡n| d|¡|S)Nzsocket error: EOFrz#socket error: unterminated line: %réþÿÿÿr z< %r)r‘r@ÚendswithrDrpr%r”r=r=r>r.„s


zIMAP4._get_linecCsD| |¡|_|jdk	r:|jdkr:| d|j|j ¡f¡|jdk	S)Nrz	matched %r => %r)Úmatchr0rDrprÜÚgroups)rTZcreÚsr=r=r>r/—szIMAP4._matchcCs2|jtt|jƒ|jƒ}|jd|_d|j|<|S)Nrf)rkr"rèrKrZrG)rTr&r=r=r>r!£s
zIMAP4._new_tagcCs$| dd¡}| dd¡}d|dS)Nú\z\\ú"z\")r»)rTr'r=r=r>rÞ«szIMAP4._quotecGs| ||j|f|žŽ¡Sr~)r+r$rr=r=r>rµ³szIMAP4._simple_commandcCsT|dkr||fS||jkr$|dgfS|j |¡}|jdkrL| d||f¡||fS)Nrrzuntagged_responses[%s] => %s)rHr7rDrp)rTr¦r§r¥r™r=r=r>r¢¸s


zIMAP4._untagged_responsecCsN|dkrt ¡}t dt |¡¡}tj d||dd|f¡tj ¡dS)Nz%M:%Sz
  %s.%02d %s
éd)ÚtimeÚstrftimeÚ	localtimerƒÚstderrÚwriteÚflush)rTr>ZsecsZtmr=r=r>rpÆs
zIMAP4._mesgcCs>| ¡}|sdSd}tdd„|ƒ}| d|| |¡f¡dS)Nz
		cSs*d|d|ddr"d |d¡p$dfS)Nz%s: "%s"rrfz" "rB)r)Úxr=r=r>Ú<lambda>Òrz IMAP4._dump_ur.<locals>.<lambda>zuntagged responses dump:%s%s)ÚitemsÚmaprpr)rTÚdictÚlÚtr=r=r>rïÍszIMAP4._dump_urcCs8|t ¡f|j|j<|jd7_|j|jkr4d|_dS)Nrfr)rBrornrmr”r=r=r>r%Õsz
IMAP4._logcCsl| dt|jƒ¡|j|j}}|rhz|j|j|ŽWnYnX|d7}||jkr^d}|d8}q"dS)Nzlast %d IMAP4 interactions:rfr)rpr“rornrm)rTÚiÚnr=r=r>r8Üs
zIMAP4.print_log)rÙrÚ)rÙrÚ)r¬F)N)F)N)Tr:r;r<Ú__doc__rPr?r@rAÚ
IMAP4_PORTrWrMrdrOr}rr‚r‡rNrr‘ršrQr…r¨r«rºrÀrÂrÄrrÇrÉrÊrÌrÍrÎrÏrÑrÔr×rØrÝrárãrâr€rìrírîr£ròrórôr÷rûrürýrþrrr	rrr
rrrrrr$r+rsrrr*r.r/r!rÞrµr¢rprïr%r8r=r=r=r>r†sž,*
		
	



 	

M	P
!
c@s:eZdZdZdedddfdd„Zdd„Zdefdd	„ZdS)
Ú	IMAP4_SSLa3IMAP4 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.
        rBNcCs|dk	r|dk	rtdƒ‚|dk	r0|dk	r0tdƒ‚|dk	s@|dk	rVddl}| dtd¡||_||_|dkrxtj||d}||_t	 
|||¡dS)Nz8ssl_context and keyfile arguments are mutually exclusivez9ssl_context and certfile arguments are mutually exclusiverzEkeyfile and certfile are deprecated, use a custom ssl_context insteadé)ÚcertfileÚkeyfile)Ú
ValueErrorÚwarningsÚwarnÚDeprecationWarningrVrUrrrrrW)rTrUrVrVrUrrXr=r=r>rWÿs$ÿÿzIMAP4_SSL.__init__cCst |¡}|jj||jdS)Nr)rr‡rrrU)rTr‰r=r=r>r‡s
ÿzIMAP4_SSL._create_socketcCst |||¡dS)zæ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)rrNrSr=r=r>rNszIMAP4_SSL.open)r:r;r<rQÚIMAP4_SSL_PORTrWr‡rNr=r=r=r>rSìsÿ
rSc@sBeZdZdZdd„Zddd„Zdd„Zd	d
„Zdd„Zd
d„Z	dS)rzæIMAP4 client class over a stream

    Instantiate with: IMAP4_stream(command)

            "command" - a string that can be passed to subprocess.Popen()

    for more documentation see the docstring of the parent class IMAP4.
    cCs||_t |¡dSr~)r
rrW)rTr
r=r=r>rW/szIMAP4_stream.__init__NcCsNd|_d|_d|_d|_tj|jttjtjddd|_	|j	j
|_|j	j|_
dS)z…Setup a stream connection.
        This connection will be used by the routines:
            read, readline, send, shutdown.
        NT)ÚbufsizeÚstdinÚstdoutÚshellÚ	close_fds)rUrVr‰r‹Ú
subprocessÚPopenr
rÚPIPEr½r]Ú	writefiler^ÚreadfilerSr=r=r>rN4sý
zIMAP4_stream.opencCs|j |¡SrŒ)rerrŽr=r=r>rDszIMAP4_stream.readcCs
|j ¡S)r)rer‘rbr=r=r>r‘IszIMAP4_stream.readlinecCs|j |¡|j ¡dS)r–N)rdrFrGr˜r=r=r>ršNszIMAP4_stream.sendcCs"|j ¡|j ¡|j ¡dS)r›N)rerrdr½Úwaitrbr=r=r>rQTs

zIMAP4_stream.shutdown)NN)
r:r;r<rQrWrNrr‘ršrQr=r=r=r>r#s

c@s0eZdZdZdd„Zdd„Zdd„Zdd	„Zd
S)r¼zcPrivate class to provide en/decoding
            for base64-based authentication conversation.
    cCs
||_dSr~)r¿)rTZmechinstr=r=r>rWbsz_Authenticator.__init__cCs&| | |¡¡}|dkrdS| |¡S)Nó*)r¿r¾ré)rTr™Úretr=r=r>r½esz_Authenticator.processcCsnd}t|tƒr| d¡}|rjt|ƒdkrB|dd…}|dd…}n|}d}t |¡}|r||dd…}q|S)Nrrcé0r¡)rçrèrér“ÚbinasciiZ
b2a_base64)rTÚinpZouprNÚer=r=r>réks	


z_Authenticator.encodecCs|sdSt |¡S)Nr)rjZ
a2b_base64)rTrkr=r=r>r¾ƒsz_Authenticator.decodeN)r:r;r<rQrWr½rér¾r=r=r=r>r¼\s
r¼z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov DecräcCsi|]\}}| ¡|d“qS)rf)ré)Ú.0rPr>r=r=r>Ú
<dictcomp>‰srnrfc	CsØt |¡}|sdSt| d¡}| d¡}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d	¡ƒ}	t| d
¡ƒ}
|	d|
d}|dkrª|}||||||d
d
d
f	}t |¡|}
t |
¡S)z¨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.
    NÚmonÚzonenÚdayÚyearÚhourÚminÚsecÚzonehÚzonemé<ó-r¡)	ÚInternalDater<ÚMon2numr1r4ÚcalendarZtimegmrBrD)r6r0rorprqrrrsrtrurvrwZzoneÚttÚutcr=r=r>r‹s$

cCs@d}d}tt|ƒƒ}|r<t|dƒ\}}|||d…|}q|S)z-Convert integer to A-P string representation.rsABCDEFGHIJKLMNOPérf)r4ÚabsÚdivmod)Únumr(ZAPÚmodr=r=r>r	®scCs$t |¡}|sdSt| d¡ ¡ƒS)z-Convert IMAP4 flags response to python tuple.r=r·)ÚFlagsr<r,r1r-)r6r0r=r=r>r
»s
cCst|ttfƒr"t |tj¡ ¡}nât|tƒr¸z
|j	}WnZt
k
rtjr„|d}|dkrpt 
t |¡¡d}tjtjf|}ntj}YnXt|d}t|dd…dt|ƒiŽ}nLt|tƒrÚ|jdkrÔtdƒ‚|}n*t|tƒrü|d|dfd	krü|Std
ƒ‚d t|j¡}| |¡S)aè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.
    ér¡)ZsecondsNéÚtzinfozdate_time must be awarer)r@r@zdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")rçr4ÚfloatrZ
fromtimestamprr~Z
astimezoner,Ú	tm_gmtoffr{rBÚdaylightrDÚmktimeÚaltzonerr‡rWrèÚformatÚMonthsZmonthrC)r¸ZdtZgmtoffÚdstZdeltaÚfmtr=r=r>rÆs2ÿ





Ú__main__zd:s:)r=r=z-dz-s)rBzIMAP password for %s on %s: Ú	localhostzJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)sÚ
)rßZlfrá)rÉ)ú
/tmp/xxx 1)rô)r”z/tmp/yyy)r©ú
/tmp/yyz 2rºr–)rÝ)z/tmpzyy*)rûr•)r÷)NZSUBJECTÚtest)rÏ)Ú1z(FLAGS INTERNALDATE RFC822))r)r˜ÚFLAGSz
(\Deleted))rîr=)rÎr=)r¨r=)rr=)rûr=)r«)ZUIDVALIDITY)r)r,ZALL)r«)rù)r€r=cCsLt d||f¡tt|ƒ|Ž\}}t d|||f¡|dkrH|d‚|S)Nz%s %sz%s => %s %srr)ÚMrpry)Úcmdrr¦r§r=r=r>Úrun'srœrzPROTOCOL_VERSION = %szCAPABILITIES = %rrÝ)z/tmp/zyy%z.*"([^"]+)"$r¡rÊrrz%sz:(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822.TEXT)z
All tests OK.z
Tests failed.z8
If you would like to see debugging output,
try: %s -d5
)UrQrqrjrŸrir[r…rarƒrBr|rrrÚiorrrÚImportErrorÚ__all__r´rCrRr[rur’rxr\r3r„rzr^r_r²r5r2rar]r`rrSrºrr¼r-rŽÚ	enumerater{rr	r
rr:ZgetoptZgetpassÚargvZoptlistrr?r(Zstream_commandÚoptr4rUZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2rœršrErprvrtr›Úmlr<r0r1Úpathr§rÚprintr=r=r=r>Ú<module>sZH
ÿ	Ö/



	

ÿl4
9,
#
)





òù


ÿ
ý

Zerion Mini Shell 1.0