
    Rh                     d   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 	 ddlZdZg dZd	ZdZd
ZdZdZdZi 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i d$dd%dd&dd'dd(dd)dd*dd+dd,dd-dd.dd/dd0dd1dd2dd3dd4dddddddddd5Z ej6                  d6      Z ej6                  d7      Z ej6                  d8      Z ej6                  d9ej>                        Z  ej6                  d:      Z! ej6                  d;      Z" ej6                  d<      Z# ej6                  d=ej>                        Z$d9Z%d=Z& G d> d?      Z'er G d@ dAe'      Z(ejS                  dA        G dB dCe'      Z* G dD dE      Z+dFjY                  dG      Z- e.e-dHd       D  ci c]  \  } }|j_                         | dHz    c}} Z0dI Z1dJ Z2dK Z3dL Z4e5dMk(  rddl6Z6ddl7Z7	  e6jl                  ejp                  dHd dN      \  Z9Z:dZ=e9D ]!  \  Z>Z<e>dPk(  r	 e?e<      Ze>dQk(  se<Z=e:re=fZ:# e:sdRZ:e:d   Z@ e7j                         ZB e7jn                  dSeBdTe@xs dUdV      ZCdWeBdXdYz  ZDdZeBeCffd[d\d]d^d_ddeDffd`dadbdcdddedfdgdhfZEdidjdkdld^dddeDffdgdmfZFdn ZG	 e=r	 e*e=      ZHn e'e@      ZHeHj                  dok(  reEdHd ZEeHj                  dpeHj                  z         eHj                  dqeHj                         eED ]  \  ZMZ: eGeMe:         eGdrds      D ]F  ZN ej                  dteN      ZPePrePj                  dH      ZRneNjY                         du   ZR eGdveRf       H eFD ]>  \  ZMZ: eGeMe:      ZSeMe:fdkk7  reSdu   jY                         ZTeTs- eGdwddxeTdu   z  dyf       @  eUdz       yy# e$ r dZY w xY wc c}} w # e6jv                  $ rZ<dO\  Z9Z:Y dZ<[<dZ<[<ww xY w#   eUd{       es eUd|ejp                  d   z          xY w)}zIMAP4 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  )	IMAP4REV1r   i@B APPEND)AUTHSELECTEDAUTHENTICATE)NONAUTH
CAPABILITY)r   r   r   LOGOUTCHECK)r   CLOSECOPYCREATEDELETE	DELETEACLENABLE)r   EXAMINEEXPUNGEFETCHGETACLGETANNOTATIONGETQUOTAGETQUOTAROOTMYRIGHTSLISTLOGINr   LSUBMOVE	NAMESPACENOOPPARTIAL	PROXYAUTHRENAMESEARCHSELECTSETACLSETANNOTATIONSETQUOTASORT)STARTTLSSTATUSSTORE	SUBSCRIBETHREADUIDUNSUBSCRIBEUNSELECTs   \+( (?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                   8   e Zd ZdZ G d de      Z G d de      Z G d de      Zded	fd
Z	d Z
d Zd Zd Zd Zd Zd Zded	fdZd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd  Zd! Z d" Z!d# Z"d$ Z#d% Z$d& Z%d' Z&d( Z'd) Z(dVd*Z)d+ Z*d, Z+d- Z,d. Z-dVd/Z.d0 Z/d1 Z0d2 Z1d3 Z2d4 Z3d5 Z4d6 Z5dWd7Z6d8 Z7d9 Z8d: Z9d; Z:dXd<Z;d= Z<d> Z=d? Z>d@ Z?dA Z@dB ZAdC ZBdD ZCdE ZDdF ZEdG ZFdH ZGdI ZHdJ ZIdYdKZJdL ZKdM ZLdN ZMdO ZNdP ZOdQ ZP	 dXdRZQdS ZRdT ZSdU ZTy	)Zr   a  IMAP4 client class.

    Instantiate with: IMAP4([host[, port[, timeout=None]]])

            host - host's name (default: localhost);
            port - port number (default: standard IMAP4 port).
            timeout - socket timeout (default: None)
                      If timeout is not given or is None,
                      the global default socket timeout is used

    All IMAP4rev1 commands are supported by methods of the same
    name (in lowercase).

    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                       e Zd Zy)IMAP4.errorN__name__
__module____qualname__     /usr/lib/python3.12/imaplib.pyerrorr?          rE   rG   c                       e Zd Zy)IMAP4.abortNr@   rD   rE   rF   abortrJ      rH   rE   rK   c                       e Zd Zy)IMAP4.readonlyNr@   rD   rE   rF   readonlyrM      rH   rE   rN    Nc                 N   t         | _        d| _        d | _        i | _        i | _        d| _        d| _        d| _        d| _	        | j                          | j                  |||       	 | j                          y # t        $ r" 	 | j                           # t        $ r Y  w xY ww xY w)Nr   rO   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porttimeouts       rF   __init__zIMAP4.__init__   s    

!"$%'"  % 			$g&	MMO 	   	s0   (A9 9	B$BB$	B B$B  B$c                     d| _         d| _        t        j                  t        t        j
                        | _        t        j                  t        t        j
                        | _        y )NFascii)	utf8_enabled	_encodingrecompile_LiteralASCIILiteral_Untagged_statusUntagged_statusrb   s    rF   r[   zIMAP4._mode_ascii   s?    ! zz(BHH5!zz*:BHHErE   c                     d| _         d| _        t        j                  t              | _        t        j                  t              | _        y )NTutf-8)ri   rj   rk   rl   rm   ro   rp   rq   rr   s    rF   
_mode_utf8zIMAP4._mode_utf8   s3      zz(+!zz*:;rE   c                    t        t        j                  dd            | _        t	        j
                  d| j                  z   dz   t        j                        | _        	 d| _        d| _	        i | _
        | j                  dk\  r6| j                  dt        z         | j                  d	| j                  z         | j                         | _        d
| j                   v rd| _        n1d| j                   v rd| _        n| j%                  | j                        | j'                          	 | j                  dk\  r| j                  d| j(                         t*        D ]  }|| j(                  vr|| _         y  | j%                  d      )Ni   i  s   (?P<tag>s"   \d+) (?P<type>[A-Z]+) (?P<data>.*)
   r      zimaplib version %sznew IMAP4 connection, tag=%sPREAUTHr   OKr      zCAPABILITIES: zserver not IMAP4 compliant)r
   randomrandinttagprerk   rl   rn   tagre_cmd_log_len_cmd_log_idx_cmd_logrR   _mesg__version___get_responsewelcomerV   rS   rG   _get_capabilitiescapabilitiesAllowedVersionsPROTOCOL_VERSION)rb   versions     rF   r]   zIMAP4._connect   sR    V^^D%89ZZ++!&@!ABD((L
  "D !DDMzzQ

/+=>

9DKKGH))+///DJT,,,"DJ**T\\** zzQ

1B1BDE& 	Gd///$+D!		 jj566rE   c                 b    |t         v rt        | |j                               S t        d|z        )NzUnknown IMAP4 command: '%s')CommandsgetattrlowerAttributeError)rb   attrs     rF   __getattr__zIMAP4.__getattr__  s.    84..:TABBrE   c                     | S NrD   rr   s    rF   	__enter__zIMAP4.__enter__  s    rE   c                 d    | j                   dk(  ry 	 | j                          y # t        $ r Y y w xY w)Nr   )rS   logoutr`   )rb   argss     rF   __exit__zIMAP4.__exit__  s1    ::!	KKM 		s   # 	//c                 "   ||st        d      | j                  sd n| j                  }t        j                  d| | j                  | j                         || j                  f}|t        j                  ||      S t        j                  |      S )Nz0Non-blocking socket (timeout=0) is not supportedzimaplib.open)
ValueErrorrc   sysauditrd   socketcreate_connection)rb   re   rc   addresss       rF   _create_socketzIMAP4._create_socket#  s{     wOPP99t$))		.$		499=#++GW==''00rE   c                     || _         || _        | j                  |      | _        | j                  j	                  d      | _        y)zSetup 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)rc   rd   r   sockmakefilefilera   s       rF   r\   z
IMAP4.open0  s:     		''0	II&&t,	rE   c                 8    | j                   j                  |      S zRead 'size' bytes from remote.)r   readrb   sizes     rF   r   z
IMAP4.read<  s    yy~~d##rE   c                     | j                   j                  t        dz         }t        |      t        kD  r| j	                  dt        z        |S )Read line from remote.rx   zgot more than %d bytes)r   readline_MAXLINElenrG   rb   lines     rF   r   zIMAP4.readlineA  s@    yy!!(Q,/t9x**5@AArE   c                 h    t        j                  d| |       | j                  j                  |       y)Send data to remote.zimaplib.sendN)r   r   r   sendallrb   datas     rF   sendz
IMAP4.sendI  s$    		.$-		$rE   c                    | j                   j                          	 | j                  j                  t        j
                         | j                  j                          y# t        $ r8}|j                  t        j                  k7  rt        |dd      dk7  r Y d}~Wd}~ww xY w# | j                  j                          w xY w) Close I/O established in "open".winerrorr   i&'  N)
r   closer   r_   r   	SHUT_RDWRr`   errnoENOTCONNr   )rb   excs     rF   r_   zIMAP4.shutdownO  s    		
	IIv//0 IIOO  	 		U^^+3
A.%7	 IIOOs)   )A   	B!).BB$ B!!B$ $C c                     | j                   S )zfReturn socket instance used to connect to IMAP4 server.

        socket = <instance>.socket()
        )r   rr   s    rF   r   zIMAP4.socket_  s    
 yyrE   c                     d}| j                  ddg|      \  }}|d   r||fS | j                         \  }}| j                  |||      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.
        RECENTrz   N)_untagged_responsenooprb   nametypdats       rF   recentzIMAP4.recentk  sW     **4$>Sr78O99;S&&sC66rE   c                 F    | j                  |dg|j                               S )zReturn data for response 'code' if received, or None.

        Old value for response 'code' is cleared.

        (code, [data]) = <instance>.response(code)
        N)r   upper)rb   codes     rF   responsezIMAP4.response|  s!     &&tdVTZZ\BBrE   c                     d}|sd}|r|d   |d   fdk7  rd|z  }nd}|rt        |      }nd}t        j                  t        |      }| j                  rd|z   d	z   }|| _        | j                  ||||      S )
zAppend 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CRLFri   rT   _simple_command)rb   mailboxflags	date_timemessager   rT   s          rF   appendzIMAP4.append  s     Gar#y0E))4II++dG,')D0G##D'5)DDrE   c                     |j                         }t        |      j                  | _        | j	                  d|      \  }}|dk7  r$| j                  |d   j                  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   rz   r   rt   replacer   )r   _AuthenticatorprocessrT   r   rG   decoderS   )rb   	mechanism
authobjectmechr   r   s         rF   authenticatezIMAP4.authenticate  so       
 &j199''=S$;**SW^^GY?@@
CxrE   c                 T    d}| j                  |      \  }}| j                  |||      S )zT(typ, [data]) = <instance>.capability()
        Fetch capabilities list from server.r   r   r   r   s       rF   
capabilityzIMAP4.capability  s2     ''-S&&sC66rE   c                 $    | j                  d      S )zRCheckpoint mailbox on server.

        (typ, [data]) = <instance>.check()
        r   r   rr   s    rF   checkzIMAP4.check  s    
 ##G,,rE   c                 Z    	 | j                  d      \  }}d| _        ||fS # d| _        w xY w)zClose currently selected mailbox.

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

        (typ, [data]) = <instance>.close()
        r   r   r   rS   rb   r   r   s      rF   r   zIMAP4.close  s6    	 ++G4HCDJCx  DJ   ! 	*c                 (    | j                  d||      S )zCopy 'message_set' messages onto end of 'new_mailbox'.

        (typ, [data]) = <instance>.copy(message_set, new_mailbox)
        r   r   )rb   message_setnew_mailboxs      rF   copyz
IMAP4.copy  s    
 ##FKEErE   c                 &    | j                  d|      S )zPCreate new mailbox.

        (typ, [data]) = <instance>.create(mailbox)
        r   r   rb   r   s     rF   createzIMAP4.create      
 ##Hg66rE   c                 &    | j                  d|      S )zPDelete old mailbox.

        (typ, [data]) = <instance>.delete(mailbox)
        r   r   r   s     rF   deletezIMAP4.delete  r   rE   c                 (    | j                  d||      S )zDelete the ACLs (remove any rights) set for who on mailbox.

        (typ, [data]) = <instance>.deleteacl(mailbox, who)
        r   r   )rb   r   whos      rF   	deleteaclzIMAP4.deleteacl  s    
 ##K#>>rE   c                     d| j                   vrt        j                  d      | j                  d|      \  }}|dk(  r"d|j	                         v r| j                          ||fS )zlSend an RFC5161 enable string to the server.

        (typ, [data]) = <instance>.enable(capability)
        r   zServer does not support ENABLErz   zUTF8=ACCEPT)r   r   rG   r   r   ru   )rb   r   r   r   s       rF   enablezIMAP4.enable  sc    
 4,,,++>??((:>	T$;=J,<,<,>>OODyrE   c                 T    d}| j                  |      \  }}| j                  |||      S )zPermanently 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   s       rF   expungezIMAP4.expunge  s2     ''-S&&sC66rE   c                 X    d}| j                  |||      \  }}| j                  |||      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   )rb   r   message_partsr   r   r   s         rF   fetchzIMAP4.fetch  s6     ''k=IS&&sC66rE   c                 R    | j                  d|      \  }}| j                  ||d      S )zXGet the ACLs for a mailbox.

        (typ, [data]) = <instance>.getacl(mailbox)
        r!   ACLr   rb   r   r   r   s       rF   getaclzIMAP4.getacl(  s/    
 ''':S&&sC77rE   c                 V    | j                  d|||      \  }}| j                  ||d      S )za(typ, [data]) = <instance>.getannotation(mailbox, entry, attribute)
        Retrieve ANNOTATIONs.r"   
ANNOTATIONr   )rb   r   entry	attributer   r   s         rF   getannotationzIMAP4.getannotation1  s3     ''%SS&&sC>>rE   c                 R    | j                  d|      \  }}| j                  ||d      S )zGet the quota root's resource usage and limits.

        Part of the IMAP4 QUOTA extension defined in rfc2087.

        (typ, [data]) = <instance>.getquota(root)
        r#   QUOTAr   )rb   rootr   r   s       rF   getquotazIMAP4.getquota9  s/     ''
D9S&&sC99rE   c                     | j                  d|      \  }}| j                  ||d      \  }}| j                  ||d      \  }}|||gfS )zGet the list of quota roots for the named mailbox.

        (typ, [[QUOTAROOT responses...], [QUOTA responses]]) = <instance>.getquotaroot(mailbox)
        r$   r  	QUOTAROOTr   )rb   r   r   r   quota	quotaroots         rF   getquotarootzIMAP4.getquotarootD  sZ    
 ''@S,,S#w?
U00c;GYY&&&rE   c                 X    d}| j                  |||      \  }}| j                  |||      S )zList mailbox names in directory matching pattern.

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

        'data' is list of LIST responses.
        r&   r   rb   	directorypatternr   r   r   s         rF   listz
IMAP4.listO  6     ''iAS&&sC66rE   c                     | j                  d|| j                  |            \  }}|dk7  r| j                  |d         d| _        ||fS )zIdentify client using plaintext password.

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

        NB: 'password' will be quoted.
        r'   rz   r   r   )r   _quoterG   rS   )rb   userpasswordr   r   s        rF   loginzIMAP4.login[  sO     ''t{{87LMS$;**SW%%
CxrE   c                 X    ||c| _         | _        | j                  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)rb   r!  r"  s      rF   login_cram_md5zIMAP4.login_cram_md5i  s-    
 $( 	4=  T-@-@AArE   c                     ddl }t        | j                  t              r| j                  j	                  d      n| j                  }| j
                  dz   |j                  ||d      j                         z   S )z1 Authobject to use with CRAM-MD5 authentication. r   Nrt    md5)hmac
isinstancer"  strencoder!  HMAC	hexdigest)rb   	challenger*  pwds       rF   r%  zIMAP4._CRAM_MD5_AUTHr  sY    0:4==#0Nt}}##G,26-- 	yy33	5!A!K!K!MMMrE   c                 `    d| _         | j                  d      \  }}| j                          ||fS )z|Shutdown connection to server.

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

        Returns server 'BYE' response.
        r   )rS   r   r_   r   s      rF   r   zIMAP4.logoutz  s1     
''1SCxrE   c                 X    d}| j                  |||      \  }}| j                  |||      S )zList '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  s         rF   lsubz
IMAP4.lsub  r  rE   c                 R    | j                  d|      \  }}| j                  ||d      S )zShow my ACLs for a mailbox (i.e. the rights that I have on mailbox).

        (typ, [data]) = <instance>.myrights(mailbox)
        r%   r   r	  s       rF   myrightszIMAP4.myrights  s/    
 &&z7;C&&sC<<rE   c                 T    d}| j                  |      \  }}| j                  |||      S )zb Returns IMAP namespaces ala rfc2342

        (typ, [data, ...]) = <instance>.namespace()
        r*   r   r   s       rF   	namespacezIMAP4.namespace  s2    
 ''-S&&sC66rE   c                 z    	 | j                   dk\  r| j                  | j                         | j                  d      S )zFSend NOOP command.

        (typ, [data]) = <instance>.noop()
        r{   r+   )rR   _dump_urrV   r   rr   s    rF   r   z
IMAP4.noop  s5    
 zzQd556##F++rE   c                 \    d}| j                  |||||      \  }}| j                  ||d      S )zFetch 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   )rb   message_nummessage_partstartlengthr   r   r   s           rF   partialzIMAP4.partial  s;     ''k<PVWS&&sC99rE   c                 *    d}| j                  d|      S )zAssume authentication as "user".

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

        (typ, [data]) = <instance>.proxyauth(user)
        r-   r   )rb   r!  r   s      rF   	proxyauthzIMAP4.proxyauth  s     ##K66rE   c                 (    | j                  d||      S )zkRename old mailbox name to new.

        (typ, [data]) = <instance>.rename(oldmailbox, newmailbox)
        r.   r   )rb   
oldmailbox
newmailboxs      rF   renamezIMAP4.rename  s    
 ##Hj*EErE   c                     d}|r:| j                   rt        j                  d       | j                  |d|g| \  }}n | j                  |g| \  }}| j	                  |||      S )zSearch 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)ri   r   rG   r   r   )rb   charsetcriteriar   r   r   s         rF   searchzIMAP4.search  st       kk"KLL+t++D)WPxPHC+t++D<8<HC&&sC66rE   c                 `   i | _         || _        |rd}nd}| j                  ||      \  }}|dk7  rd| _        ||fS d| _        d| j                   v rA|s?	 | j                  dk\  r| j                  | j                          | j                  d|z        || j                   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   r0   rz   r   r   	READ-ONLYrx   z%s is not writableEXISTSN)rV   rX   r   rS   rR   r:  rN   get)rb   r   rN   r   r   r   s         rF   selectzIMAP4.select  s     #%#DD''g6S$;DJ8O
$111 ::?MM$"9"9:-- 4w >??D++//4&AAArE   c                 *    | j                  d|||      S )zZSet a mailbox acl.

        (typ, [data]) = <instance>.setacl(mailbox, who, what)
        r1   r   )rb   r   r   whats       rF   setaclzIMAP4.setacl  s    
 ##HgsDAArE   c                 T     | j                   dg| \  }}| j                  ||d      S )z_(typ, [data]) = <instance>.setannotation(mailbox[, entry, attribute]+)
        Set ANNOTATIONs.r2   r  r   )rb   r   r   r   s       rF   setannotationzIMAP4.setannotation
  s4     (4''?$?S&&sC>>rE   c                 T    | j                  d||      \  }}| j                  ||d      S )ziSet the quota root's resource limits.

        (typ, [data]) = <instance>.setquota(root, limits)
        r3   r  r   )rb   r  limitsr   r   s        rF   setquotazIMAP4.setquota  s1    
 ''
D&AS&&sC99rE   c                     d}|d   |d   fdk7  rd|z  } | j                   |||g| \  }}| j                  |||      S )zIMAP4rev1 extension SORT command.

        (typ, [data]) = <instance>.sort(sort_criteria, charset, search_criteria, ...)
        r4   r   r   r   r   r   )rb   sort_criteriarI  search_criteriar   r   r   s          rF   sortz
IMAP4.sort  s`    
  !]2./9<"]2M'4''mWWWS&&sC66rE   c                    d}t         s| j                  d      | j                  r| j                  d      || j                  vr| j                  d      |t        j                         }| j                  |      \  }}|dk(  rd|j                  | j                  | j                        | _	        | j                  j                  d      | _        d| _        | j                          n| j                  d	      | j                  |||      S )
Nr5   zSSL support missingzTLS session already establishedzTLS not supported by serverrz   server_hostnamer   TzCouldn't establish TLS session)HAVE_SSLrG   rZ   rK   r   ssl_create_stdlib_contextr   wrap_socketr   rc   r   r   r   r   )rb   ssl_contextr   r   r   s        rF   starttlszIMAP4.starttls)  s    **233  **>??t(((**:;;446K''-S$;#//		@D		 0 KDI		**40DI$(D!""$**=>>&&sC66rE   c                 X    d}| j                  |||      \  }}| j                  |||      S )zpRequest named status conditions for mailbox.

        (typ, [data]) = <instance>.status(mailbox, names)
        r6   r   )rb   r   namesr   r   r   s         rF   statuszIMAP4.status@  s8    
  ''gu=S&&sC66rE   c                 z    |d   |d   fdk7  rd|z  }| j                  d|||      \  }}| j                  ||d      S )zAlters flag dispositions for messages in mailbox.

        (typ, [data]) = <instance>.store(message_set, command, flags)
        r   r   r   r   r7   r    r   )rb   r   commandr   r   r   s         rF   storezIMAP4.storeL  sQ    
 !HU2Y9,UNE''guMS&&sC99rE   c                 &    | j                  d|      S )zYSubscribe to new mailbox.

        (typ, [data]) = <instance>.subscribe(mailbox)
        r8   r   r   s     rF   	subscribezIMAP4.subscribeW  s    
 ##K99rE   c                 \    d} | j                   |||g| \  }}| j                  |||      S )zIMAPrev1 extension THREAD command.

        (type, [data]) = <instance>.thread(threading_algorithm, charset, search_criteria, ...)
        r9   r   )rb   threading_algorithmrI  r[  r   r   r   s          rF   threadzIMAP4.thread_  s>    
 '4''.A7]_]S&&sC66rE   c                 b   |j                         }|t        vr| j                  d|z        | j                  t        |   vr:| j                  d|d| j                  ddj	                  t        |               d} | j
                  ||g| \  }}|dv r|}nd}| j                  |||      S )	zExecute "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command  illegal in state , only allowed in states , r:   )r/   r4   r9   r    )r   r   rG   rS   joinr   r   )rb   rj  r   r   r   r   s         rF   uidz	IMAP4.uidi  s     --/("**<wFGG::Xg..**%tzz"ii(9:< = = '4''g==S22DD&&sC66rE   c                 &    | j                  d|      S )z_Unsubscribe from old mailbox.

        (typ, [data]) = <instance>.unsubscribe(mailbox)
        r;   r   r   s     rF   unsubscribezIMAP4.unsubscribe  s    
 ##M7;;rE   c                 Z    	 | j                  d      \  }}d| _        ||fS # d| _        w xY w)aM  Free server's resources associated with the selected mailbox
        and returns the server to the authenticated state.
        This command performs the same actions as CLOSE, except
        that no messages are permanently removed from the currently
        selected mailbox.

        (typ, [data]) = <instance>.unselect()
        r<   r   r   )rb   r   r   s      rF   unselectzIMAP4.unselect  s7    	 ,,Z8ICDJDy  DJr   c                     |j                         }|t        vr| j                  ft        |<    | j                  |g| 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   r   rS   r   rb   r   r   s      rF   xatomzIMAP4.xatom  s@     zz| x"jj]HTN#t##D0400rE   c                     |d}| j                   }	 | j                  dk\  r4| j                  d|dt        |j	                  |d            d|d       ||v r||   j                  |       y |g||<   y )NrE      untagged_responses[z] rO   z += ["z"])rV   rR   r   r   rO  r   )rb   r   r   urs       rF   _append_untaggedzIMAP4._append_untagged  sn    ;C$$zzQ

c"&&R.138 9"9sGNN3eBsGrE   c                     | j                   j                  d      }|r.| j                  |d   j                  | j                  d            y )NBYEr   r   )rV   rO  rK   r   rj   )rb   byes     rF   
_check_byezIMAP4._check_bye  sB    %%))%0**SW^^DNNIFGG rE   c                 V   | j                   t        |   vrAd | _        | j                  d|d| j                   ddj	                  t        |               dD ]  }|| j
                  v s| j
                  |=   d| j
                  v r| j                  s| j                  d      | j                         }t        || j                        }|dz   |z   }|D ]3  }|t        |t              rt        || j                        }|dz   |z   }5 | j                  }|Qd | _        t        |      t        | j                        u r|}n'd }|t        d	t        |      z  | j                        z   }	 | j                   d
k\  r| j#                  d|z         n| j%                  d|z         	 | j'                  |t(        z          ||S 	 | j/                         r"| j0                  |   r|S | j/                         r"r || j2                        }	 | j                   d
k\  r| j#                  dt        |      z         	 | j'                  |       | j'                  t(               |s	 |S # t*        $ r}	| j-                  d|	z        d }	~	ww xY w# t*        $ r}	| j-                  d|	z        d }	~	ww xY w)Nrr  rs  rt  ru  rz   NOBADrM  z#mailbox status changed to READ-ONLY    z {%s}   z> %rzsocket error: %szwrite literal size %s)rS   r   rT   rG   rv  rV   rX   rN   _new_tagbytesrj   r+  r,  type_commandr   rR   r   _logr   r   r`   rK   r   rU   rW   )
rb   r   r   r   tagr   argrT   	literatorvals
             rF   r  zIMAP4._command  s   ::Xd^+DL**"DJJ"ii79 : :
 ' 	1Cd---++C0	1 $111  -- EFFmmoT4>>*TzD  	%C{H#s#C0$;$D		% ,,DLG}T]] 33#	 	eGc'l$:DNNKKzzQ

6D=)		&4-(	7IIdTk" ?J $$&'',J $$& #D$>$>?::?JJ6WEF;		'"		$ 
3   	7**/#566	72  ;jj!3c!9::;s0   $I! 5&J !	J*I>>J	J(J##J(c                 t   |dk(  }|s| j                          	 | j                  ||      \  }}|s| j                          |dk(  r| j                  |d|d|      ||fS # | j                  $ r}| j                  d|d|      d }~w| j                  $ r}| j                  d|d|      d }~ww xY w)Nr   )
expect_byez	command:  => r  z command error: r(  )r  _get_tagged_responserK   rG   )rb   r   r  r   r   r   r  s          rF   _command_completezIMAP4._command_complete  s    ("OO	@11#&1IIC
 OO%<**$TJKKDy zz 	@**D#>??zz 	@**D#>??	@s#   A# #B72B		B7B22B7c                     | j                         \  }}|d gk(  r| j                  d      t        |d   | j                        }|j	                         }t        |j                               | _        y )Nz"no CAPABILITY response from serverr   )r   rG   r,  rj   r   tuplesplitr   r   s      rF   r   zIMAP4._get_capabilities#  s]    ??$S4&=**ABB#b'4>>*iik!#))+.rE   c                 h   | j                         }| j                  | j                  |      r| j                  j	                  d      }|| j
                  vr| j                  d|z        | j                  j	                  d      }t        || j                        }| j                  j	                  d      }||gf| j
                  |<   nd }| j                  t        |      s7| j                  | j                  |      r| j                  j	                  d      }| j                  K| j                  t        |      r!| j                  j	                  d      | _        y | j                  d|z        | j                  j	                  d      }t        || j                        }| j                  j	                  d      }|d}|r|dz   |z   }| j                  | j                  |      rt        | j                  j	                  d	            }	 | j                  d
k\  r| j!                  d|z         | j#                  |      }| j%                  |||f       | j                         }| j                  | j                  |      r| j%                  ||       |dv rr| j                  t&        |      r\| j                  j	                  d      }t        || j                        }| j%                  || j                  j	                  d             	 | j                  dk\  r|dv r| j!                  |d|       |S )Nr  zunexpected tagged response: %rr  r   data2zunexpected response: %rrE   r  r   r  zread literal size %sr  rx   )r  r  r  z response: )	_get_line_matchr   mogrouprU   rK   r,  rj   Untagged_responserq   ContinuationrW   ro   intrR   r   r   r  Response_code)rb   respr  r   r   dat2r   r   s           rF   r   zIMAP4._get_response,  s    ~~ ;;tzz4(''--&C$...jj!AD!HII''--'Cc4>>*C''--'C),seD  %D ;;0$7;;t33T:77==1Dww ;;|T215v1FD.jj!:T!ABB''--'Cc4>>*C''--'C{#C3:,S ++dllC0 477==01zzQ

#9D#@Ayy %%cC;7 nn&! ++dllC0$ !!#s+ %%$++mS*I''--'Cc4>>*C!!#tww}}V'<=zzQ3*>#>

S9:rE   c                 D   	 | j                   |   }|| j                   |= |S |r$d}| j                  j                  |d       }|||fS | j                          	 | j	                          h# | j
                  $ r&}	 | j                  dk\  r| j                           d }~ww xY w)Nrx   r  )rU   rV   popr  r   rK   rR   	print_log)rb   r  r  resultr   r  r  s          rF   r  zIMAP4._get_tagged_response|  s    ))#.F!((---11#t<?:% OO""$/ 0 :: zzQ(	s   A* *B9!BBc                    | j                         }|s| j                  d      |j                  d      s| j                  d|z        |d d }	 | j                  dk\  r| j	                  d|z         |S | j                  d|z         |S )Nzsocket error: EOFr   z#socket error: unterminated line: %rr  z< %r)r   rK   endswithrR   r   r  r   s     rF   r  zIMAP4._get_line  s    }}**011 }}W%**BTIJJCRyzzQ

6D=)  		&4-(rE   c                     |j                  |      | _        	 | j                  H| j                  dk\  r9| j                  d|j                  d| j                  j                                | j                  d uS )Nr  z		matched r  )matchr  rR   r   r  groups)rb   cress      rF   r  zIMAP4._match  sY    
 ))A,ww"tzzQ

3;;@PQRwwd""rE   c                     | j                   t        t        | j                        | j                        z   }| j                  dz   | _        d | j
                  |<   |S )Nrx   )r~   r  r,  rY   rj   rU   )rb   r  s     rF   r  zIMAP4._new_tag  sH    kkE#dkk"2DNNCCkkAo$(S!
rE   c                 Z    |j                  dd      }|j                  dd      }d|z   dz   S )N\z\\"z\")r   )rb   r  s     rF   r   zIMAP4._quote  s0    kk$'kk#u%Sy3rE   c                 H    | j                  | | j                  |g|       S r   )r  r  r}  s      rF   r   zIMAP4._simple_command  s%    %%dMDMM$,F,FGGrE   c                     |dk(  r||fS || j                   vr|d gfS | j                   j                  |      }	 | j                  dk\  r| j                  d|d|       ||fS )Nr  r  r  z] => )rV   r  rR   r   )rb   r   r   r   r   s        rF   r   zIMAP4._untagged_response  sk    $;8Ot...;&&**40zzQ

T4HIDyrE   c                    |t        j                          }t        j                  dt        j                  |            }t        j                  j                  d||dz  dz  |fz         t        j                  j                          y )Nz%M:%Sz  %s.%02d %s
d   )timestrftime	localtimer   stderrwriteflush)rb   r  secstms       rF   r   zIMAP4._mesg  sb    |yy{wt(<=BJJ-d3h^Q0GGHJJrE   c                 ~    |sy d |j                         D        }| j                  ddj                  |      z          y )Nc              3   0   K   | ]  \  }}| d |  yw): NrD   ).0keyvalues      rF   	<genexpr>z!IMAP4._dump_ur.<locals>.<genexpr>  s)      B"U uBui( Bs   zuntagged responses dump:z
		)itemsr   rv  )rb   untagged_resp_dictr  s      rF   r:  zIMAP4._dump_ur  s=    %B&8&>&>&@BEJJ1HMM%4HHIrE   c                     |t        j                          f| j                  | j                  <   | xj                  dz  c_        | j                  | j                  k\  rd| _        y y )Nrx   r   )r  r   r   r   r   s     rF   r  z
IMAP4._log  sS    04diik/BDMM$++,"  D$5$55$%! 6rE   c                    | j                  dt        | j                        z         | j                  | j                  }}|r<	  | j                   | j                  |     |dz  }|| j                  k\  rd}|dz  }|r;y y #  Y $xY w)Nzlast %d IMAP4 interactions:rx   r   )r   r   r   r   r   )rb   ins      rF   r  zIMAP4.print_log  s    JJ4s4==7IIJ$$d&7&7qADJJa 01 Q)))AQ s   A? ?B)z""*)r   Fr   )F)UrA   rB   rC   __doc__r^   rG   rK   rN   
IMAP4_PORTrf   r[   ru   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   r4  r6  r8  r   r@  rB  rF  rK  rP  rS  rU  rX  r\  re  rh  rk  rm  rp  rw  ry  r{  r~  r  r  r  r  r   r   r  r  r  r  r   r   r   r   r:  r  r  rD   rE   rF   r   r      s   -^ !	 5Z 2F<'7TC1 T 	-$
  7"CE4:7-F77?
778?:'	7BN
	7=7,	:
7F7$B@B?:77.	7::772< 1,HJZ$/M`B&	#H
	 		J	&	rE   r   c                   8    e Zd ZdZdefddddZd ZdedfdZy)	IMAP4_SSLa  IMAP4 client class over SSL connection

        Instantiate with: IMAP4_SSL([host[, port[, ssl_context[, timeout=None]]]])

                host - host's name (default: localhost);
                port - port number (default: standard IMAP4 SSL port);
                ssl_context - a SSLContext object that contains your certificate chain
                              and private key (default: None)
                timeout - socket timeout (default: None) If timeout is not given or is None,
                          the global default socket timeout is used

        for more documentation see the docstring of the parent class IMAP4.
        rO   N)rd  re   c                n    |t        j                         }|| _        t        j	                  | |||       y r   )ra  rb  rd  r   rf   )rb   rc   rd   rd  re   s        rF   rf   zIMAP4_SSL.__init__  s0    "!88:*DNN4tW5rE   c                 |    t         j                  | |      }| j                  j                  || j                        S )Nr^  )r   r   rd  rc  rc   )rb   re   r   s      rF   r   zIMAP4_SSL._create_socket  s=    ''g6D##//@D		 0 K KrE   c                 4    t         j                  | |||       y)zSetup 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   r\   ra   s       rF   r\   zIMAP4_SSL.open!  s     JJtT41rE   )rA   rB   rC   r  IMAP4_SSL_PORTrf   r   r\   rD   rE   rF   r  r    s1    	 !# 	6$($	6	K
 ^T 	2rE   r  c                   6    e Zd ZdZd Zd	dZd Zd Zd Zd Z	y)
r   zIMAP4 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                 <    || _         t        j                  |        y r   )rj  r   rf   )rb   rj  s     rF   rf   zIMAP4_stream.__init__8  s    trE   Nc                 <   d| _         d| _        d| _        d| _        t	        j
                  | j                  t        t        j                  t        j                  dd      | _	        | j                  j                  | _        | j                  j                  | _        y)zSetup a stream connection.
        This connection will be used by the routines:
            read, readline, send, shutdown.
        NT)bufsizestdinstdoutshell	close_fds)rc   rd   r   r   
subprocessPopenrj  r   PIPEr   r  	writefiler  readfilera   s       rF   r\   zIMAP4_stream.open=  sq    
 				!'''//*//$( ++++rE   c                 8    | j                   j                  |      S r   )r  r   r   s     rF   r   zIMAP4_stream.readM  s    }}!!$''rE   c                 6    | j                   j                         S )r   )r  r   rr   s    rF   r   zIMAP4_stream.readlineR  s    }}%%''rE   c                 n    | j                   j                  |       | j                   j                          y)r   N)r  r  r  r   s     rF   r   zIMAP4_stream.sendW  s$    T"rE   c                     | j                   j                          | j                  j                          | j                  j	                          y)r   N)r  r   r  r   waitrr   s    rF   r_   zIMAP4_stream.shutdown]  s2    rE   )NNN)
rA   rB   rC   r  rf   r\   r   r   r   r_   rD   rE   rF   r   r   ,  s%    
, (
(
rE   r   c                   (    e Zd ZdZd Zd Zd Zd Zy)r   zcPrivate class to provide en/decoding
            for base64-based authentication conversation.
    c                     || _         y r   )r   )rb   mechinsts     rF   rf   z_Authenticator.__init__k  s	    	rE   c                 j    | j                  | j                  |            }|y| j                  |      S )N   *)r   r   r-  )rb   r   rets      rF   r   z_Authenticator.processn  s0    iiD)*;{{3rE   c                     d}t        |t              r|j                  d      }|r?t        |      dkD  r|d d }|dd  }n|}d}t	        j
                  |      }|r||d d z   }|r?|S )NrE   rt   0   r   )r+  r,  r-  r   binascii
b2a_base64)rb   inpouptes        rF   r-  z_Authenticator.encodet  s}     c3**W%C3x"}H"#h##A&AAcrFl  
rE   c                 2    |syt        j                  |      S )NrE   )r  
a2b_base64)rb   r  s     rF   r   z_Authenticator.decode  s    ""3''rE   N)rA   rB   rC   r  rf   r   r-  r   rD   rE   rF   r   r   e  s     0(rE   r   z0 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Decr(  rx   c           	         t         j                  |       }|syt        |j                  d         }|j                  d      }t	        |j                  d            }t	        |j                  d            }t	        |j                  d            }t	        |j                  d            }t	        |j                  d            }t	        |j                  d	            }	t	        |j                  d
            }
|	dz  |
z   dz  }|dk(  r| }||||||dddf	}t        j                  |      |z
  }t        j                  |      S )zParse 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  Mon2numr  r  calendartimegmr  r  )r  r  r   r  r  r  r  r  r  r  r  zonettutcs                 rF   r	   r	     s    
		D	!B
"((5/
"CHHWE
bhhuo
Crxx Drxx D
bhhuo
C
bhhuo
C!"E!"E "Hub D}u
S$S"b"	5B
//"

$C>>#rE   c                 t    d}d}t        t        |             } | rt        | d      \  } }|||dz    |z   }| r|S )z-Convert integer to A-P string representation.rE   s   ABCDEFGHIJKLMNOP   rx   )r  absdivmod)numr  APmods       rF   r
   r
     sM     C'r
c#h-C
#r?SSUmc!  JrE   c                     t         j                  |       }|syt        |j                  d      j	                               S )z-Convert IMAP4 flags response to python tuple.rD   r   )Flagsr  r  r  r  )r  r  s     rF   r   r     s5     
T	B'"((*++rE   c                 :   t        | t        t        f      r3t        j                  | t
        j                        j                         }nt        | t              r1	 | j                  }t!        |      }t        | dd dt        |      i}nTt        | t              r| j"                  t%        d      | }n*t        | t&              r| d   | d   fd	k(  r| S t%        d
      dj)                  t*        |j,                           }|j/                  |      S # t        $ r t        j                  rZ| d   }|dk(  r+t        j                  t        j                  |             d   }t        j
                  t        j                  f|    }nt        j
                   }Y 2w xY w)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   )secondsN   tzinfozdate_time must be awarer   )r  r  zdate_time not of a known typez"%d-{}-%Y %H:%M:%S %z")r+  r  floatr   fromtimestampr   r  
astimezoner  	tm_gmtoffr   r  daylightr  mktimealtzoner   r  r   r,  formatMonthsmonthr  )r   dtgmtoffdstdeltafmts         rF   r   r     s]    )c5\*##I$,LL22<*, 		Iu	%		(((F &)y!}=Xe_=	Ix	(#677	Is	#1im(D	(Q899
"
)
)&*:
;C;;s'  	(}}l"9..Y)?@CC==$,,7<<--	(s   D BFF__main__zd:s:)rD   rD   z-dz-s)rO   zIMAP password for z on 	localhostr  zJFrom: %(user)s@localhost%(lf)sSubject: IMAP4 test%(lf)s%(lf)sdata...%(lf)s
)r!  lfr#  )r   )
/tmp/xxx 1)rF  )r3  z/tmp/yyy)r   
/tmp/yyz 2r   r5  )r  )z/tmpzyy*)rP  r4  )rK  )NSUBJECTtest)r  )1z(FLAGS INTERNALDATE RFC822))rk  )r8  FLAGSz
(\Deleted))r8  rD   )r  rD   )r   rD   )r   rD   )rP  rD   )r   )UIDVALIDITY)rw  )r/   ALL)r   )rN  )r   rD   c                     t         j                  | d|        t        t         |       | \  }}t         j                  | d|d|       |dk(  r|d   |S )Nr(  r  r  r   )Mr   r   )cmdr   r   r   s       rF   runr?  0  sP    	3%&"71c?D)S	c3/0$;c!f
rE   r   zPROTOCOL_VERSION = %szCAPABILITIES = r  )z/tmp/zyy%z.*"([^"]+)"$r   r   rw  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
)Vr  r   r  r   r|   rk   r   r  r   r  r  r   r   r   ior   ra  r`  ImportError__all__r   rQ   r  r  r   r   r   rl   r  r  r  rn   ro   r   r  r  rq   rm   rp   r   r  r   r   r   r  r(  	enumerater-  r  r	   r
   r   r   rA   getoptgetpassargvoptlistr   rG   r  stream_commandoptr  rc   getuserUSERPASSWD	test_mesg	test_seq1	test_seq2r?  r=  rS   r   r   r   r>  mlr  r  r  pathr   rw  print)r  r  s   00rF   <module>rS     sv  
,  K K K K K 2 2 "H8
 	
( 
,
,,
 	,
 	A	,

 	,
 	,
 	,
 	,,
 	,,
 	,,
 	
,
 	,,
 	,
 	,
 	,,
  	,!,
" 	,#,
$ 	,%,
& 	,',
( 	,),
* 	+,
, 	A-,
. 	,/,
0 	1,
2 	,3,
4 	A5,
6 	7,
8 		9,
: 	,;,
< 	=,
> 	,?,
@ 	,A,
B 	,C,
D 	,E,
F 	G,
H %,%,%%,%W,
` rzz01

45rzz   "**+RXX
6
"**^
$ 

DEBJJGH "**;RXXG "J x xv# #2E #2J NN;55 5r*( *(X 
<	A	A#	F&/qr
&;
<da188:ac>
<F	,%R z %chhqrlF; N 2C$;HED[ N 12 7D7??DW__tTEX[EXYZF\gkrv_wwItVn*dD)45)3,I$ !dD),-I)^,AdA77f!!"I	'!*<*<<=	q~~78! 	HCTN	 f./ 	#B/2.B"((1+4B$4'"		# " 		SHCc4.CDz77b'--/CBPR S		S 	 { q.  Hd+ =` << j	   
hhqk 
 	s<   O O"#O( ?DP
 OO(P7PP
%P/