U
    aúdfÑ  ã                *   @   sž  d Z dZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZmZ ddlmZ zddlZdZW n ek
r˜   dZY nX dd	d
dddgZdZdZdZdZdZdZddddddddddddddddddddddddddddddddddddddddddœ)Ze d¡Ze d¡Ze d¡Ze dej¡Z e d¡Z!e d¡Z"e d¡Z#e d ej¡Z$dZ%d Z&G d!d„ dƒZ'er¨G d"d#„ d#e'ƒZ(e )d#¡ G d$d	„ d	e'ƒZ*G d%d&„ d&ƒZ+d' ,d(¡Z-d)d*„ e.e-d+d… ƒD ƒZ/d,d
„ Z0d-d„ Z1d.d„ Z2d/d„ Z3e4d0kršddl5Z5ddl6Z6ze5 5ej7d+d… d1¡\Z8Z9W n. e5j:k
rp Z; zd2\Z8Z9W 5 dZ;[;X Y nX dZ<e8D ]8\Z=Z;e=d3kr–e>e;ƒZne=d4krze;Z<e9sze<fZ9qze9s¾d5Z9e9d Z?e6 @¡ ZAe6 6d6eAe?pÞd7f ¡ZBd8eAd9d:œ ZCd;eAeBffd<d=d>d?d@ddeCffdAdBdCdDdEdFdGdHdIfZDdJdKdLdMd?dddeCffdHdNfZEdOdP„ ZFze<rbe*e<ƒZGne'e?ƒZGeGjHdQkr‚eDd+d… ZDeG IdReGjJ ¡ eG IdSeGjKf ¡ eDD ]\ZLZ9eFeLe9ƒ q¨eFdTdUƒD ]<ZMe NdVeM¡ZOeOrêeO Pd+¡ZQneM ,¡ dW ZQeFdXeQfƒ qÈeED ]T\ZLZ9eFeLe9ƒZReLe9fdLkr.q
eRdW  ,¡ ZSeSsDq
eFdYdZd[eSdW  d\fƒ q
eTd]ƒ W n.   eTd^ƒ es’eTd_ej7d  ƒ ‚ Y nX dS )`zöIMAP4 client.

Based on RFC 2060.

Public class:           IMAP4
Public variable:        Debug
Public functions:       Internaldate2tuple
                        Int2AP
                        ParseFlags
                        Time2Internaldate
z2.58é    N)ÚdatetimeÚtimezoneÚ	timedelta)ÚDEFAULT_BUFFER_SIZETFÚIMAP4ÚIMAP4_streamÚInternaldate2tupleÚInt2APÚ
ParseFlagsÚTime2Internaldateó   
é   iá  )Z	IMAP4REV1r   i@B )ÚAUTHÚSELECTED)ÚNONAUTH)r   r   r   ÚLOGOUT)r   )r   ))ÚAPPENDÚAUTHENTICATEÚ
CAPABILITYÚCHECKÚCLOSEÚCOPYÚCREATEÚDELETEÚ	DELETEACLÚENABLEÚEXAMINEÚEXPUNGEÚFETCHÚGETACLÚGETANNOTATIONÚGETQUOTAÚGETQUOTAROOTÚMYRIGHTSÚLISTÚLOGINr   ÚLSUBZMOVEÚ	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°  e Zd ZdZG dd„ deƒZG dd„ deƒZG dd„ deƒZdefd	d
„Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdefdd„Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Zd7d8„ 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 )ªr   aë  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   e Zd ZdS )zIMAP4.errorN©Ú__name__Ú
__module__Ú__qualname__© r=   r=   ú/usr/lib/python3.8/imaplib.pyÚerror´   s    r?   c                   @   s   e Zd ZdS )zIMAP4.abortNr9   r=   r=   r=   r>   Úabortµ   s    r@   c                   @   s   e Zd ZdS )zIMAP4.readonlyNr9   r=   r=   r=   r>   Úreadonly¶   s    rA   Ú c                 C   s”   t | _d| _d | _i | _i | _d| _d| _d| _d| _	|  
¡  |  ||¡ z|  ¡  W n8 tk
rŽ   z|  ¡  W n tk
r†   Y nX ‚ Y nX d S )Nr   rB   Fr   )Ú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&    zIMAP4.__init__c                 C   s0   d| _ d| _t ttj¡| _t ttj¡| _d S )NFÚascii)	Úutf8_enabledÚ	_encodingÚreÚcompileÚ_LiteralÚASCIIÚLiteralÚ_Untagged_statusÚUntagged_status©rT   r=   r=   r>   rM   Ñ   s    zIMAP4._mode_asciic                 C   s(   d| _ d| _t t¡| _t t¡| _d S )NTúutf-8)rY   rZ   r[   r\   r]   r_   r`   ra   rb   r=   r=   r>   Ú
_mode_utf8Ø   s    zIMAP4._mode_utf8c                 C   sò   t t dd¡ƒ| _t d| j d tj¡| _d| _d| _	i | _
| jdkrf|  dt ¡ |  d	| j ¡ |  ¡ | _d
| jkr‚d| _nd| jkr”d| _n|  | j¡‚|  ¡  | jdkrÄ|  d| jf ¡ tD ]}|| jkrØqÈ|| _ d S |  d¡‚d S )Ni   iÿÿ  s   (?P<tag>s"   \d+) (?P<type>[A-Z]+) (?P<data>.*)é
   r   é   zimaplib version %sznew IMAP4 connection, tag=%sZPREAUTHr   ÚOKr   é   zCAPABILITIES: %rzserver not IMAP4 compliant)r	   ÚrandomZrandintÚtagprer[   r\   r^   ÚtagreÚ_cmd_log_lenÚ_cmd_log_idxÚ_cmd_logrD   Ú_mesgÚ__version__Ú_get_responseZwelcomerH   rE   r?   Ú_get_capabilitiesÚcapabilitiesÚAllowedVersionsÚPROTOCOL_VERSION)rT   Úversionr=   r=   r>   rO   ß   s:    ÿþþ





zIMAP4._connectc                 C   s&   |t krt| | ¡ ƒS td| ƒ‚d S )NzUnknown IMAP4 command: '%s')ÚCommandsÚgetattrÚlowerÚAttributeError)rT   Úattrr=   r=   r>   Ú__getattr__	  s    zIMAP4.__getattr__c                 C   s   | S ©Nr=   rb   r=   r=   r>   Ú	__enter__  s    zIMAP4.__enter__c                 G   s4   | j dkrd S z|  ¡  W n tk
r.   Y nX d S )Nr   )rE   ÚlogoutrR   )rT   Úargsr=   r=   r>   Ú__exit__  s    
zIMAP4.__exit__c                 C   s4   | j s
d n| j }t d| | j | j¡ t || jf¡S )Nzimaplib.open)rU   ÚsysÚauditrV   ÚsocketZcreate_connection)rT   rU   r=   r=   r>   Ú_create_socket  s    zIMAP4._create_socketc                 C   s(   || _ || _|  ¡ | _| j d¡| _dS )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)rU   rV   r…   ÚsockÚmakefileÚfilerS   r=   r=   r>   rN   '  s    
z
IMAP4.openc                 C   s   | j  |¡S ©zRead 'size' bytes from remote.)r‰   Úread©rT   Úsizer=   r=   r>   r‹   3  s    z
IMAP4.readc                 C   s.   | j  td ¡}t|ƒtkr*|  dt ¡‚|S )úRead line from remote.rf   zgot more than %d bytes)r‰   ÚreadlineÚ_MAXLINEÚlenr?   ©rT   Úliner=   r=   r>   r   8  s    zIMAP4.readlinec                 C   s   t  d| |¡ | j |¡ dS )úSend data to remote.zimaplib.sendN)r‚   rƒ   r‡   Zsendall©rT   Údatar=   r=   r>   Úsend@  s    z
IMAP4.sendc              
   C   st   | j  ¡  zXz| j tj¡ W n@ tk
r^ } z"|jtjkrNt	|ddƒdkrN‚ W 5 d}~X Y nX W 5 | j ¡  X dS )ú Close I/O established in "open".Zwinerrorr   i&'  N)
r‰   Úcloser‡   rQ   r„   Z	SHUT_RDWRrR   ÚerrnoZENOTCONNrx   )rT   Úexcr=   r=   r>   rQ   F  s    
ÿzIMAP4.shutdownc                 C   s   | j S )zfReturn socket instance used to connect to IMAP4 server.

        socket = <instance>.socket()
        )r‡   rb   r=   r=   r>   r„   V  s    zIMAP4.socketc                 C   sB   d}|   ddg|¡\}}|d r(||fS |  ¡ \}}|   |||¡S )a  Return 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.
        ZRECENTrg   Néÿÿÿÿ)Ú_untagged_responseÚnoop©rT   ÚnameÚtypÚdatr=   r=   r>   Úrecentb  s    	zIMAP4.recentc                 C   s   |   |dg| ¡ ¡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>   Úresponses  s    zIMAP4.responsec                 C   sx   d}|sd}|r.|d |d fdkr2d| }nd}|r@t |ƒ}nd}t t|¡}| jrbd| 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   ÚINBOXr   rœ   ©ú(ú)ú(%s)Ns   UTF8 (ó   ))r   ÚMapCRLFÚsubÚCRLFrY   rF   Ú_simple_command)rT   ÚmailboxÚflagsÚ	date_timeÚmessager    rF   r=   r=   r>   Úappend  s    

zIMAP4.appendc                 C   sP   |  ¡ }t|ƒj| _|  d|¡\}}|dkrB|  |d  dd¡¡‚d| _||fS )as  Authenticate 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.
        r   rg   rœ   rc   Úreplacer   )r¤   Ú_AuthenticatorÚprocessrF   r°   r?   ÚdecoderE   )rT   Z	mechanismZ
authobjectÚmechr¡   r¢   r=   r=   r>   Úauthenticate›  s    zIMAP4.authenticatec                 C   s    d}|   |¡\}}|  |||¡S )zT(typ, [data]) = <instance>.capability()
        Fetch capabilities list from server.r   ©r°   r   rŸ   r=   r=   r>   Ú
capability¸  s    zIMAP4.capabilityc                 C   s
   |   d¡S )zRCheckpoint mailbox on server.

        (typ, [data]) = <instance>.check()
        r   ©r°   rb   r=   r=   r>   ÚcheckÁ  s    zIMAP4.checkc                 C   s$   z|  d¡\}}W 5 d| _ X ||fS )zÌClose currently selected mailbox.

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

        (typ, [data]) = <instance>.close()
        r   r   )rE   r°   ©rT   r¡   r¢   r=   r=   r>   r™   É  s    zIMAP4.closec                 C   s   |   d||¡S )z‚Copy 'message_set' messages onto end of 'new_mailbox'.

        (typ, [data]) = <instance>.copy(message_set, new_mailbox)
        r   r¾   )rT   Úmessage_setZnew_mailboxr=   r=   r>   ÚcopyØ  s    z
IMAP4.copyc                 C   s   |   d|¡S )zPCreate new mailbox.

        (typ, [data]) = <instance>.create(mailbox)
        r   r¾   ©rT   r±   r=   r=   r>   Úcreateà  s    zIMAP4.createc                 C   s   |   d|¡S )zPDelete old mailbox.

        (typ, [data]) = <instance>.delete(mailbox)
        r   r¾   rÃ   r=   r=   r>   Údeleteè  s    zIMAP4.deletec                 C   s   |   d||¡S )z€Delete the ACLs (remove any rights) set for who on mailbox.

        (typ, [data]) = <instance>.deleteacl(mailbox, who)
        r   r¾   )rT   r±   Úwhor=   r=   r>   Ú	deleteaclï  s    zIMAP4.deleteaclc                 C   sH   d| j krt d¡‚|  d|¡\}}|dkr@d| ¡ kr@|  ¡  ||fS )zkSend an RFC5161 enable string to the server.

        (typ, [data]) = <intance>.enable(capability)
        r   zServer does not support ENABLErg   zUTF8=ACCEPT)rs   r   r?   r°   r¤   rd   )rT   r½   r¡   r–   r=   r=   r>   Úenableö  s    

zIMAP4.enablec                 C   s    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.
        r   r¼   rŸ   r=   r=   r>   Úexpunge  s    	zIMAP4.expungec                 C   s$   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.
        r   r¼   )rT   rÁ   Zmessage_partsr    r¡   r¢   r=   r=   r>   Úfetch  s    
zIMAP4.fetchc                 C   s   |   d|¡\}}|  ||d¡S )zXGet the ACLs for a mailbox.

        (typ, [data]) = <instance>.getacl(mailbox)
        r   ZACLr¼   ©rT   r±   r¡   r¢   r=   r=   r>   Úgetacl  s    zIMAP4.getaclc                 C   s"   |   d|||¡\}}|  ||d¡S )za(typ, [data]) = <instance>.getannotation(mailbox, entry, attribute)
        Retrieve ANNOTATIONs.r    Ú
ANNOTATIONr¼   )rT   r±   ÚentryZ	attributer¡   r¢   r=   r=   r>   Úgetannotation(  s    zIMAP4.getannotationc                 C   s   |   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>   Úgetquota0  s    zIMAP4.getquotac                 C   s@   |   d|¡\}}|  ||d¡\}}|  ||d¡\}}|||gfS )zœGet the list of quota roots for the named mailbox.

        (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
        r"   rÐ   Z	QUOTAROOTr¼   )rT   r±   r¡   r¢   ZquotaZ	quotarootr=   r=   r>   Úgetquotaroot;  s    zIMAP4.getquotarootú""Ú*c                 C   s$   d}|   |||¡\}}|  |||¡S )z«List mailbox names in directory matching pattern.

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

        'data' is list of LIST responses.
        r$   r¼   ©rT   Z	directoryÚpatternr    r¡   r¢   r=   r=   r>   ÚlistF  s    z
IMAP4.listc                 C   s<   |   d||  |¡¡\}}|dkr.|  |d ¡‚d| _||fS )z”Identify client using plaintext password.

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

        NB: 'password' will be quoted.
        r%   rg   rœ   r   )r°   Ú_quoter?   rE   )rT   ÚuserÚpasswordr¡   r¢   r=   r=   r>   ÚloginR  s
    zIMAP4.loginc                 C   s   || | _ | _|  d| j¡S )zr Force use of CRAM-MD5 authentication.

        (typ, [data]) = <instance>.login_cram_md5(user, password)
        zCRAM-MD5)rÚ   rÛ   r»   Ú_CRAM_MD5_AUTH)rT   rÚ   rÛ   r=   r=   r>   Úlogin_cram_md5`  s    zIMAP4.login_cram_md5c                 C   sB   ddl }t| jtƒr | j d¡n| j}| jd | ||d¡ ¡  S )z1 Authobject to use with CRAM-MD5 authentication. r   Nrc   ú Zmd5)ÚhmacÚ
isinstancerÛ   ÚstrÚencoderÚ   ZHMACZ	hexdigest)rT   Z	challengerà   Úpwdr=   r=   r>   rÝ   i  s
    ÿzIMAP4._CRAM_MD5_AUTHc                 C   s$   d| _ |  d¡\}}|  ¡  ||fS )z|Shutdown connection to server.

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

        Returns server 'BYE' response.
        r   )rE   r°   rQ   rÀ   r=   r=   r>   r   q  s    zIMAP4.logoutc                 C   s$   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~  s    z
IMAP4.lsubc                 C   s   |   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‰  s    zIMAP4.myrightsc                 C   s    d}|   |¡\}}|  |||¡S )zb Returns IMAP namespaces ala rfc2342

        (typ, [data, ...]) = <instance>.namespace()
        r'   r¼   rŸ   r=   r=   r>   Ú	namespace‘  s    zIMAP4.namespacec                 C   s    | j dkr|  | j¡ |  d¡S )zFSend NOOP command.

        (typ, [data]) = <instance>.noop()
        rh   r(   )rD   Ú_dump_urrH   r°   rb   r=   r=   r>   rž   ›  s    
z
IMAP4.noopc                 C   s(   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)   r   r¼   )rT   Zmessage_numZmessage_partÚstartZlengthr    r¡   r¢   r=   r=   r>   Úpartial¦  s    zIMAP4.partialc                 C   s   d}|   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¾   )rT   rÚ   r    r=   r=   r>   Ú	proxyauth²  s    	zIMAP4.proxyauthc                 C   s   |   d||¡S )zkRename old mailbox name to new.

        (typ, [data]) = <instance>.rename(oldmailbox, newmailbox)
        r+   r¾   )rT   Z
oldmailboxZ
newmailboxr=   r=   r>   Úrename¿  s    zIMAP4.renamec                 G   sT   d}|r2| j rt 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)rY   r   r?   r°   r   )rT   ÚcharsetZcriteriar    r¡   r¢   r=   r=   r>   ÚsearchÇ  s    
zIMAP4.searchr§   Fc                 C   sŒ   i | _ || _|rd}nd}|  ||¡\}}|dkr@d| _||fS d| _d| j krx|sx| jdkrj|  | j ¡ |  d| ¡‚|| j  d	d
g¡fS )at  Select 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.
        r   r-   rg   r   r   ú	READ-ONLYrf   z%s is not writableÚEXISTSN)rH   rJ   r°   rE   rD   rè   rA   Úget)rT   r±   rA   r    r¡   r¢   r=   r=   r>   ÚselectÙ  s"    
ÿ
zIMAP4.selectc                 C   s   |   d|||¡S )zZSet a mailbox acl.

        (typ, [data]) = <instance>.setacl(mailbox, who, what)
        r.   r¾   )rT   r±   rÆ   Zwhatr=   r=   r>   Úsetaclù  s    zIMAP4.setaclc                 G   s    | j d|žŽ \}}|  ||d¡S )z_(typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+)
        Set ANNOTATIONs.r/   rÍ   )r/   r¼   )rT   r€   r¡   r¢   r=   r=   r>   Úsetannotation  s    zIMAP4.setannotationc                 C   s    |   d||¡\}}|  ||d¡S )ziSet the quota root's resource limits.

        (typ, [data]) = <instance>.setquota(root, limits)
        r0   rÐ   r¼   )rT   rÑ   Zlimitsr¡   r¢   r=   r=   r>   Úsetquota	  s    zIMAP4.setquotac                 G   sF   d}|d |d fdkr d| }| j |||f|žŽ \}}|  |||¡S )zIMAP4rev1 extension SORT command.

        (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
        r1   r   rœ   r¨   r«   r¼   )rT   Zsort_criteriarî   Úsearch_criteriar    r¡   r¢   r=   r=   r>   Úsort  s
    z
IMAP4.sortNc                 C   s¦   d}t s|  d¡‚| jr"|  d¡‚|| jkr6|  d¡‚|d krFt ¡ }|  |¡\}}|dkrŽ|j| j	| j
d| _	| j	 d¡| _d| _|  ¡  n
|  d	¡‚|  |||¡S )
Nr2   zSSL support missingzTLS session already establishedzTLS not supported by serverrg   ©Zserver_hostnamer†   TzCouldn't establish TLS session)ÚHAVE_SSLr?   rL   r@   rs   ÚsslÚ_create_stdlib_contextr°   Úwrap_socketr‡   rU   rˆ   r‰   rr   r   )rT   Ússl_contextr    r¡   r¢   r=   r=   r>   Ústarttls   s&    



ÿ

zIMAP4.starttlsc                 C   s$   d}|   |||¡\}}|  |||¡S )zpRequest named status conditions for mailbox.

        (typ, [data]) = <instance>.status(mailbox, names)
        r3   r¼   )rT   r±   Únamesr    r¡   r¢   r=   r=   r>   Ústatus7  s    zIMAP4.statusc                 C   s>   |d |d fdkrd| }|   d|||¡\}}|  ||d¡S )zAlters flag dispositions for messages in mailbox.

        (typ, [data]) = <instance>.store(message_set, command, flags)
        r   rœ   r¨   r«   r4   r   r¼   )rT   rÁ   Úcommandr²   r¡   r¢   r=   r=   r>   ÚstoreC  s    zIMAP4.storec                 C   s   |   d|¡S )zYSubscribe to new mailbox.

        (typ, [data]) = <instance>.subscribe(mailbox)
        r5   r¾   rÃ   r=   r=   r>   Ú	subscribeN  s    zIMAP4.subscribec                 G   s*   d}| j |||f|žŽ \}}|  |||¡S )z‹IMAPrev1 extension THREAD command.

        (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
        r6   r¼   )rT   Zthreading_algorithmrî   r÷   r    r¡   r¢   r=   r=   r>   ÚthreadV  s    zIMAP4.threadc              	   G   s†   |  ¡ }|tkr|  d| ¡‚| jt| krL|  d|| jd t| ¡f ¡‚d}| j||f|žŽ \}}|dkrt|}nd}|  |||¡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'.
        zUnknown IMAP4 UID command: %sú9command %s illegal in state %s, only allowed in states %sú, r7   )r,   r1   r6   r   )r¤   rw   r?   rE   Újoinr°   r   )rT   r  r€   r    r¡   r¢   r=   r=   r>   Úuid`  s    ÿþz	IMAP4.uidc                 C   s   |   d|¡S )z_Unsubscribe from old mailbox.

        (typ, [data]) = <instance>.unsubscribe(mailbox)
        r8   r¾   rÃ   r=   r=   r>   Úunsubscribey  s    zIMAP4.unsubscribec                 G   s,   |  ¡ }|tkr| jft|< | j|f|žŽ S )a  Allow 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¤   rw   rE   r°   ©rT   r    r€   r=   r=   r>   Úxatom  s    
zIMAP4.xatomc              	   C   sb   |d krd}| j }| jdkr<|  d|t| |d¡ƒ|f ¡ ||krT||  |¡ n
|g||< d S )Nó    é   z#untagged_responses[%s] %s += ["%r"]rB   )rH   rD   ro   r‘   rò   rµ   )rT   r¡   r¢   Zurr=   r=   r>   Ú_append_untagged—  s    
ÿzIMAP4._append_untaggedc                 C   s,   | j  d¡}|r(|  |d  | jd¡¡‚d S )NÚBYErœ   r¶   )rH   rò   r@   r¹   rZ   )rT   Úbyer=   r=   r>   Ú
_check_bye¥  s    zIMAP4._check_byec           
   
   G   s2  | j t| kr4d | _|  d|| j d t| ¡f ¡‚dD ]}|| jkr8| j|= q8d| jkrj| jsj|  d¡‚|  ¡ }t	|| j
ƒ}|d | }|D ]0}|d krœqŽt|tƒr²t	|| j
ƒ}|d | }qŽ| j}|d k	r
d | _t|ƒt| jƒkrî|}nd }|t	dt|ƒ | j
ƒ }| jdkr&|  d	| ¡ n|  d	| ¡ z|  |t ¡ W n2 tk
rx }	 z|  d
|	 ¡‚W 5 d }	~	X Y nX |d krˆ|S |  ¡ r¦| j| rˆ|S qˆ|r¶|| jƒ}| jdkrÔ|  dt|ƒ ¡ z|  |¡ |  t¡ W n2 tk
r }	 z|  d
|	 ¡‚W 5 d }	~	X Y nX |sˆq.qˆ|S )Nr  r  ©rg   ÚNOÚBADrð   z#mailbox status changed to READ-ONLYó    z {%s}é   z> %rzsocket error: %szwrite literal size %s)rE   rw   rF   r?   r  rH   rJ   rA   Ú_new_tagÚbytesrZ   rá   râ   ÚtypeÚ_commandr‘   rD   ro   Ú_logr—   r¯   rR   r@   rq   rG   rI   )
rT   r    r€   r¡   Útagr–   ÚargrF   Z	literatorÚvalr=   r=   r>   r  «  sl    ÿþ


ÿ
 

 



 zIMAP4._commandc              
   C   sÆ   |dk}|s|   ¡  z| j||d\}}W nj | jk
r` } z|  d||f ¡‚W 5 d }~X Y n6 | jk
r” } z|  d||f ¡‚W 5 d }~X Y nX |s¢|   ¡  |dkr¾|  d|||f ¡‚||fS )Nr   )Ú
expect_byezcommand: %s => %sr  z%s command error: %s %s)r  Ú_get_tagged_responser@   r?   )rT   r    r  r   r¡   r–   r  r=   r=   r>   Ú_command_completeø  s    "$zIMAP4._command_completec                 C   sJ   |   ¡ \}}|d gkr |  d¡‚t|d | jƒ}| ¡ }t| ¡ ƒ| _d S )Nz"no CAPABILITY response from serverrœ   )r½   r?   râ   rZ   r¤   ÚtupleÚsplitrs   rÀ   r=   r=   r>   rr   
  s    

zIMAP4._get_capabilitiesc                 C   sò  |   ¡ }|  | j|¡rr| j d¡}|| jkr:|  d| ¡‚| j d¡}t|| jƒ}| j d¡}||gf| j|< nd }|  t	|¡sœ|  | j
|¡rœ| j d¡}| jd krÒ|  t|¡rÄ| j d¡| _d S |  d| ¡‚| j d¡}t|| jƒ}| j d¡}|d krd}|r|d | }|  | j|¡rvt| j d	¡ƒ}| jd
krP|  d| ¡ |  |¡}|  |||f¡ |   ¡ }q|  ||¡ |dkrÆ|  t|¡rÆ| j d¡}t|| jƒ}|  || j d¡¡ | jdkrî|dkrî|  d||f ¡ |S )Nr  zunexpected tagged response: %rr  r–   Zdata2zunexpected response: %rr  r  r   r  zread literal size %sr  rf   )r  r  r  z%s response: %r)Ú	_get_lineÚ_matchrk   ÚmoÚgrouprG   r@   râ   rZ   ÚUntagged_responsera   ÚContinuationrI   r_   ÚintrD   ro   r‹   r  ÚResponse_code)rT   Úrespr  r¡   r¢   Zdat2r   r–   r=   r=   r>   rq     sP    


  
zIMAP4._get_responsec              
   C   s˜   | j | }|d k	r| j |= |S |rDd}| j |d ¡}|d k	rD||fS |  ¡  z|  ¡  W q  | jk
r } z| jdkr~|  ¡  ‚ W 5 d }~X Y q X q d S )Nr  rf   )rG   rH   Úpopr  rq   r@   rD   Ú	print_log)rT   r  r   Úresultr¡   r  r  r=   r=   r>   r!  c  s     

zIMAP4._get_tagged_responsec                 C   sf   |   ¡ }|s|  d¡‚| d¡s.|  d| ¡‚|d d… }| jdkrT|  d| ¡ n|  d| ¡ |S )Nzsocket error: EOFr   z#socket error: unterminated line: %réþÿÿÿr  z< %r)r   r@   ÚendswithrD   ro   r  r’   r=   r=   r>   r%  „  s    


zIMAP4._get_linec                 C   sD   |  |¡| _| jd k	r:| jdkr:|  d|j| j ¡ f ¡ | jd k	S )Nr  z	matched %r => %r)Úmatchr'  rD   ro   r×   Úgroups)rT   ZcreÚsr=   r=   r>   r&  —  s    zIMAP4._matchc                 C   s2   | j tt| jƒ| jƒ }| jd | _d | j|< |S )Nrf   )rj   r  râ   rK   rZ   rG   )rT   r  r=   r=   r>   r  £  s    
zIMAP4._new_tagc                 C   s$   |  dd¡}|  dd¡}d| d S )Nú\z\\ú"z\")r¶   )rT   r  r=   r=   r>   rÙ   «  s    zIMAP4._quotec                 G   s   |   || j|f|žŽ ¡S r}   )r"  r  r  r=   r=   r>   r°   ³  s    zIMAP4._simple_commandc                 C   sT   |dkr||fS || j kr$|d gfS | j  |¡}| jdkrL|  d||f ¡ ||fS )Nr  r  zuntagged_responses[%s] => %s)rH   r.  rD   ro   )rT   r¡   r¢   r    r–   r=   r=   r>   r   ¸  s    


zIMAP4._untagged_responsec                 C   sN   |d krt   ¡ }t  dt  |¡¡}tj d||d d |f ¡ tj ¡  d S )Nz%M:%Sz  %s.%02d %s
éd   )ÚtimeÚstrftimeÚ	localtimer‚   ÚstderrÚwriteÚflush)rT   r5  ZsecsZtmr=   r=   r>   ro   Æ  s
    zIMAP4._mesgc                 C   s>   |  ¡ }|sd S d}tdd„ |ƒ}|  d|| |¡f ¡ d S )Nz
		c                 S   s*   d| d | d d r"d  | d ¡p$df S )Nz%s: "%s"r   rf   z" "rB   )r  )Úxr=   r=   r>   Ú<lambda>Ò  r  z IMAP4._dump_ur.<locals>.<lambda>zuntagged responses dump:%s%s)ÚitemsÚmapro   r  )rT   ÚdictÚlÚtr=   r=   r>   rè   Í  s     zIMAP4._dump_urc                 C   s8   |t   ¡ f| j| j< |  jd7  _| j| jkr4d| _d S )Nrf   r   )r9  rn   rm   rl   r’   r=   r=   r>   r  Õ  s    z
IMAP4._logc                 C   sl   |   dt| jƒ ¡ | j| j }}|rhz| j | j| Ž  W n   Y nX |d7 }|| jkr^d}|d8 }q"d S )Nzlast %d IMAP4 interactions:rf   r   )ro   r‘   rn   rm   rl   )rT   ÚiÚnr=   r=   r>   r/  Ü  s    
zIMAP4.print_log)rÔ   rÕ   )rÔ   rÕ   )r§   F)N)F)N)Tr:   r;   r<   Ú__doc__rP   r?   r@   rA   Ú
IMAP4_PORTrW   rM   rd   rO   r|   r~   r   r…   rN   r‹   r   r—   rQ   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ç   rž   rê   rë   rì   rï   ró   rô   rõ   rö   rø   rÿ   r  r  r  r  r	  r
  r  r  r  r  r"  rr   rq   r!  r%  r&  r  rÙ   r°   r   ro   rè   r  r/  r=   r=   r=   r>   r   †   sž   ,*		
	


 	

M	P
!
c                   @   s:   e Zd ZdZdedddfdd„Zdd„ Zdefdd	„ZdS )
Ú	IMAP4_SSLa3  IMAP4 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.
        rB   Nc                 C   s   |d k	r|d k	rt dƒ‚|d k	r0|d k	r0t dƒ‚|d k	s@|d k	rVdd l}| dtd¡ || _|| _|d krxtj||d}|| _t	 
| ||¡ d S )Nz8ssl_context and keyfile arguments are mutually exclusivez9ssl_context and certfile arguments are mutually exclusiver   zEkeyfile and certfile are deprecated, use a custom ssl_context insteadé   )ÚcertfileÚkeyfile)Ú
ValueErrorÚwarningsÚwarnÚDeprecationWarningrM  rL  rû   rü   rþ   r   rW   )rT   rU   rV   rM  rL  rþ   rO  r=   r=   r>   rW   ÿ  s$     ÿÿzIMAP4_SSL.__init__c                 C   s   t  | ¡}| jj|| jdS )Nrù   )r   r…   rþ   rý   rU   )rT   r‡   r=   r=   r>   r…     s    
ÿzIMAP4_SSL._create_socketc                 C   s   t  | ||¡ dS )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)r   rN   rS   r=   r=   r>   rN     s    zIMAP4_SSL.open)r:   r;   r<   rH  ÚIMAP4_SSL_PORTrW   r…   rN   r=   r=   r=   r>   rJ  ì  s    ÿ
rJ  c                   @   sB   e Zd ZdZdd„ Zddd„Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )r   zæ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.
    c                 C   s   || _ t | ¡ d S r}   )r  r   rW   )rT   r  r=   r=   r>   rW   /  s    zIMAP4_stream.__init__Nc                 C   sN   d| _ d| _d| _d| _tj| jttjtjddd| _	| j	j
| _| j	j| _dS )z…Setup a stream connection.
        This connection will be used by the routines:
            read, readline, send, shutdown.
        NT)ÚbufsizeÚstdinÚstdoutÚshellZ	close_fds)rU   rV   r‡   r‰   Ú
subprocessÚPopenr  r   ÚPIPEr¸   rT  Ú	writefilerU  ÚreadfilerS   r=   r=   r>   rN   4  s      ý
zIMAP4_stream.openc                 C   s   | j  |¡S rŠ   )r[  r‹   rŒ   r=   r=   r>   r‹   D  s    zIMAP4_stream.readc                 C   s
   | j  ¡ S )rŽ   )r[  r   rb   r=   r=   r>   r   I  s    zIMAP4_stream.readlinec                 C   s   | j  |¡ | j  ¡  dS )r”   N)rZ  r=  r>  r•   r=   r=   r>   r—   N  s    zIMAP4_stream.sendc                 C   s"   | j  ¡  | j ¡  | j ¡  dS )r˜   N)r[  r™   rZ  r¸   Úwaitrb   r=   r=   r>   rQ   T  s    

zIMAP4_stream.shutdown)NN)
r:   r;   r<   rH  rW   rN   r‹   r   r—   rQ   r=   r=   r=   r>   r   #  s   

c                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )r·   zcPrivate class to provide en/decoding
            for base64-based authentication conversation.
    c                 C   s
   || _ d S r}   )rº   )rT   Zmechinstr=   r=   r>   rW   b  s    z_Authenticator.__init__c                 C   s&   |   |  |¡¡}|d krdS |  |¡S )Nó   *)rº   r¹   rã   )rT   r–   Zretr=   r=   r>   r¸   e  s    z_Authenticator.processc                 C   sn   d}t |tƒr| d¡}|rjt|ƒdkrB|d d… }|dd … }n|}d}t |¡}|r||d d…  }q|S )Nr  rc   é0   rœ   )rá   râ   rã   r‘   ÚbinasciiZ
b2a_base64)rT   ÚinpZouprE  Úer=   r=   r>   rã   k  s    	


z_Authenticator.encodec                 C   s   |sdS t  |¡S )Nr  )r_  Z
a2b_base64)rT   r`  r=   r=   r>   r¹   ƒ  s    z_Authenticator.decodeN)r:   r;   r<   rH  rW   r¸   rã   r¹   r=   r=   r=   r>   r·   \  s
   r·   z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decrß   c                 C   s   i | ]\}}|  ¡ |d  “qS )rf   )rã   )Ú.0rG  r5  r=   r=   r>   Ú
<dictcomp>‰  s      rc  rf   c              	   C   sØ   t  | ¡}|sdS t| d¡ }| d¡}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d¡ƒ}t| d	¡ƒ}	t| d
¡ƒ}
|	d |
 d }|dkrª| }||||||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œ   )	ÚInternalDater3  ÚMon2numr(  r+  ÚcalendarZtimegmr9  r;  )r-  r'  rd  re  rf  rg  rh  ri  rj  rk  rl  ZzoneZttÚutcr=   r=   r>   r   ‹  s$    

c                 C   s@   d}d}t t| ƒƒ} | r<t| dƒ\} }|||d … | }q|S )z-Convert integer to A-P string representation.r  s   ABCDEFGHIJKLMNOPé   rf   )r+  ÚabsÚdivmod)Znumr  ZAPÚmodr=   r=   r>   r	   ®  s     c                 C   s$   t  | ¡}|sdS t| d¡ ¡ ƒS )z-Convert IMAP4 flags response to python tuple.r=   r²   )ÚFlagsr3  r#  r(  r$  )r-  r'  r=   r=   r>   r
   »  s    
c                 C   s  t | ttfƒr"t | tj¡ ¡ }nât | tƒr¸z
| j	}W nZ t
k
r   tjr„| d }|dkrpt t | ¡¡d }tjtjf|  }ntj }Y nX t|d}t| dd… dt|ƒiŽ}nLt | tƒrÚ| jdkrÔtdƒ‚| }n*t | tƒrü| d | d fd	krü| S td
ƒ‚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œ   )ZsecondsNé   Útzinfozdate_time must be awarer   )r7  r7  zdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")rá   r+  Úfloatr   Zfromtimestampr   rr  Z
astimezoner#  Ú	tm_gmtoffrz   r9  Údaylightr;  ÚmktimeÚaltzoner   rz  rN  râ   ÚformatÚMonthsZmonthr:  )r³   ZdtZgmtoffZdstZdeltaZfmtr=   r=   r>   r   Æ  s2    ÿ





Ú__main__zd:s:)r=   r=   z-dz-s)rB   zIMAP password for %s on %s: Z	localhostzJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)sÚ
)rÚ   ZlfrÜ   )rÄ   )ú
/tmp/xxx 1)rì   )r„  z/tmp/yyy)r   ©ú
/tmp/yyz 2rµ   r†  )rØ   )z/tmpzyy*)ró   r…  )rï   )NZSUBJECTZtest)rÊ   )Ú1z(FLAGS INTERNALDATE RFC822))r  )r‡  ÚFLAGSz
(\Deleted))rç   r=   )rÉ   r=   )r£   r=   )r™   r=   )ró   r=   )r¦   )ZUIDVALIDITY)r	  )r,   ZALL)r¦   )rñ   )r   r=   c                 C   sL   t  d| |f ¡ tt | ƒ|Ž \}}t  d| ||f ¡ |dkrH|d ‚|S )Nz%s %sz%s => %s %sr  r   )ÚMro   rx   )Úcmdr€   r¡   r¢   r=   r=   r>   Úrun'  s     r‹  r   zPROTOCOL_VERSION = %szCAPABILITIES = %rrØ   )z/tmp/zyy%z.*"([^"]+)"$rœ   rÅ   r	  r   z%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
)UrH  rp   r_  rš   ri   r[   r„   rW  r‚   r9  rq  r   r   r   Úior   rû   rú   ÚImportErrorÚ__all__r¯   rC   rI  rR  rt   r   rw   r\   r*  rw  ro  r^   r_   r­   r,  r)  ra   r]   r`   r   rJ  rµ   r   r·   r$  r  Ú	enumeraterp  r   r	   r
   r   r:   ZgetoptZgetpassÚargvZoptlistr€   r?   r  Zstream_commandZoptr+  rU   ZgetuserZUSERZPASSWDZ	test_mesgZ	test_seq1Z	test_seq2r‹  r‰  rE   ro   ru   rs   rŠ  Zmlr3  r'  r(  Úpathr¢   r	  Úprintr=   r=   r=   r>   Ú<module>   sZ  H
  ÿ	Ö/



	

 ÿ        l4
9,
#)



 
 
òù

 
 ÿ
ý