-
H ?c       sV  d  Z  d k Z d k Z d d g Z d e f d     YZ d Z d Z d Z e e Z	 d f  d     YZ
 e d	 j o d k Z e
 e i d
  Z e i   GHe i e i d  e i e i d  e i   e i   \ Z Z x` e d
 e d
  D]K Z e i e  \ Z Z Z d Ge Gd GHx e D] Z d e GHq(Wd GHq We i   n d S(   s@   A POP3 client class.

Based on the J. Myers POP3 draft, Jan. 96
Ns   POP3s   error_protoc      s   RS(   N(    (    (    (    s#   /mit/python/lib/python2.2/poplib.pys   error_proto s    in   s   s   
c      s   d  Z  e 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 e d  Z d   Z d   Z d   Z d   Z d   Z d   Z e i d  Z d   Z d   Z e d  Z RS(   s  This class supports both the minimal and optional command sets.
    Arguments can be strings or integers (where appropriate)
    (e.g.: retr(1) and retr('1') both work equally well.

    Minimal Command Set:
            USER name               user(name)
            PASS string             pass_(string)
            STAT                    stat()
            LIST [msg]              list(msg = None)
            RETR msg                retr(msg)
            DELE msg                dele(msg)
            NOOP                    noop()
            RSET                    rset()
            QUIT                    quit()

    Optional Commands (some servers support these):
            RPOP name               rpop(name)
            APOP name digest        apop(name, digest)
            TOP msg n               top(msg, n)
            UIDL [msg]              uidl(msg = None)

    Raises one exception: 'error_proto'.

    Instantiate with:
            POP3(hostname, port=110)

    NB:     the POP protocol locks the mailbox from user
            authorization until QUIT, so be sure to get in, suck
            the messages, and quit, each time you access the
            mailbox.

            POP is a line-based protocol, which means large mail
            messages consume lots of python cycles reading them
            line-by-line.

            If it's available on your mail server, use IMAP4
            instead, it doesn't suffer from the two problems
            above.
    c 
   s  | |  _  | |  _ d } t |  _ x t i |  i  |  i d t i  D] } | \ } } } } }	 y, t i | | |  |  _ |  i i |	  Wn? t i j
 o0 } |  i o |  i i   n t |  _ qC n XPqC W|  i o t i |  n |  i i d  |  _ d |  _ |  i   |  _ d  S(   Ns!   getaddrinfo returns an empty listi    s   rb(   s   hosts   selfs   ports   msgs   Nones   socks   sockets   getaddrinfos   SOCK_STREAMs   ress   afs   socktypes   protos	   canonnames   sas   connects   errors   closes   makefiles   files
   _debuggings   _getresps   welcome(
   s   selfs   hosts   ports   afs	   canonnames   protos   msgs   ress   socktypes   sa(    (    s#   /mit/python/lib/python2.2/poplib.pys   __init__K s*    			" 
		c    s<   |  i d j o d G| GHn |  i i d | t f  d  S(   Ni   s   *put*s   %s%s(   s   selfs
   _debuggings   lines   socks   sends   CRLF(   s   selfs   line(    (    s#   /mit/python/lib/python2.2/poplib.pys   _putlineb s     c    s)   |  i o d G| GHn |  i |  d  S(   Ns   *cmd*(   s   selfs
   _debuggings   lines   _putline(   s   selfs   line(    (    s#   /mit/python/lib/python2.2/poplib.pys   _putcmdi s    
 c    s   |  i i   } |  i d j o d G| GHn | o t d   n t |  } | d t j o | d  | f Sn | d t	 j o | d d !| f Sn | d  | f Sd  S(   Ni   s   *get*s   -ERR EOFii    i(
   s   selfs   files   readlines   lines
   _debuggings   error_protos   lens   octetss   CRLFs   CR(   s   selfs   octetss   line(    (    s#   /mit/python/lib/python2.2/poplib.pys   _getliner s      c    s_   |  i   \ } } |  i d j o d G| GHn | d  } | d j o t |   n | Sd  S(   Ni   s   *resp*s   +(   s   selfs   _getlines   resps   os
   _debuggings   cs   error_proto(   s   selfs   cs   resps   o(    (    s#   /mit/python/lib/python2.2/poplib.pys   _getresp s     
c    s   |  i   } g  } d } |  i   \ } } xd | d j oV | d  d j o | d } | d } n | | } | i |  |  i   \ } } q- W| | | f Sd  S(   Ni    s   .i   s   ..i   (	   s   selfs   _getresps   resps   lists   octetss   _getlines   lines   os   append(   s   selfs   resps   octetss   lines   lists   o(    (    s#   /mit/python/lib/python2.2/poplib.pys   _getlongresp s     

c    s   |  i |  |  i   Sd  S(   N(   s   selfs   _putcmds   lines   _getresp(   s   selfs   line(    (    s#   /mit/python/lib/python2.2/poplib.pys	   _shortcmd s    c    s   |  i |  |  i   Sd  S(   N(   s   selfs   _putcmds   lines   _getlongresp(   s   selfs   line(    (    s#   /mit/python/lib/python2.2/poplib.pys   _longcmd s    c    s   |  i Sd  S(   N(   s   selfs   welcome(   s   self(    (    s#   /mit/python/lib/python2.2/poplib.pys
   getwelcome s    c    s   | |  _ d  S(   N(   s   levels   selfs
   _debugging(   s   selfs   level(    (    s#   /mit/python/lib/python2.2/poplib.pys   set_debuglevel s    c    s   |  i d |  Sd S(   sV   Send user name, return response

        (should indicate password required).
        s   USER %sN(   s   selfs	   _shortcmds   user(   s   selfs   user(    (    s#   /mit/python/lib/python2.2/poplib.pys   user s     c    s   |  i d |  Sd S(   s   Send password, return response

        (response includes message count, mailbox size).

        NB: mailbox is locked by server from here to 'quit()'
        s   PASS %sN(   s   selfs	   _shortcmds   pswd(   s   selfs   pswd(    (    s#   /mit/python/lib/python2.2/poplib.pys   pass_ s     c    sa   |  i d  } | i   } |  i o d G| GHn t | d  } t | d  } | | f Sd S(   s]   Get mailbox status.

        Result is tuple of 2 ints (message count, mailbox size)
        s   STATs   *stat*i   i   N(	   s   selfs	   _shortcmds   retvals   splits   retss
   _debuggings   ints   numMessagess   sizeMessages(   s   selfs   retss   sizeMessagess   retvals   numMessages(    (    s#   /mit/python/lib/python2.2/poplib.pys   stat s     
 c    s-   | o |  i d |  Sn |  i d  Sd S(   s  Request listing, return result.

        Result without a message number argument is in form
        ['response', ['mesg_num octets', ...]].

        Result when a message number argument is given is a
        single response: the "scan listing" for that message.
        s   LIST %ss   LISTN(   s   whichs   selfs	   _shortcmds   _longcmd(   s   selfs   which(    (    s#   /mit/python/lib/python2.2/poplib.pys   list s     c    s   |  i d |  Sd S(   so   Retrieve whole message number 'which'.

        Result is in form ['response', ['line', ...], octets].
        s   RETR %sN(   s   selfs   _longcmds   which(   s   selfs   which(    (    s#   /mit/python/lib/python2.2/poplib.pys   retr s     c    s   |  i d |  Sd S(   sF   Delete message number 'which'.

        Result is 'response'.
        s   DELE %sN(   s   selfs	   _shortcmds   which(   s   selfs   which(    (    s#   /mit/python/lib/python2.2/poplib.pys   dele s     c    s   |  i d  Sd S(   sX   Does nothing.

        One supposes the response indicates the server is alive.
        s   NOOPN(   s   selfs	   _shortcmd(   s   self(    (    s#   /mit/python/lib/python2.2/poplib.pys   noop s     c    s   |  i d  Sd S(   s   Not sure what this does.s   RSETN(   s   selfs	   _shortcmd(   s   self(    (    s#   /mit/python/lib/python2.2/poplib.pys   rset s     c    s_   y |  i d  } Wn t j
 o } | } n X|  i i   |  i i   |  ` |  ` | Sd S(   sD   Signoff: commit changes on server, unlock mailbox, close connection.s   QUITN(   s   selfs	   _shortcmds   resps   error_protos   vals   files   closes   sock(   s   selfs   resps   val(    (    s#   /mit/python/lib/python2.2/poplib.pys   quits     c    s   |  i d |  Sd S(   s   Not sure what this does.s   RPOP %sN(   s   selfs	   _shortcmds   user(   s   selfs   user(    (    s#   /mit/python/lib/python2.2/poplib.pys   rpops     s   \+OK.*(<[^>]+>)c    s   |  i i |  i  } | o t d   n d k } | i | i d  |  i
   } d i t d   |   } |  i d | | f  Sd S(   s   Authorisation

        - only possible if server has supplied a timestamp in initial greeting.

        Args:
                user    - mailbox user;
                secret  - secret shared between client and server.

        NB: mailbox is locked by server from here to 'quit()'
        s!   -ERR APOP not supported by serverNi   s    c    s   d t  |   S(   Ns   %02x(   s   ords   x(   s   x(    (    s#   /mit/python/lib/python2.2/poplib.pys   <lambda>(s    s
   APOP %s %s(   s   selfs	   timestamps   matchs   welcomes   ms   error_protos   md5s   news   groups   secrets   digests   joins   maps	   _shortcmds   user(   s   selfs   users   secrets   ms   digests   md5(    (    s#   /mit/python/lib/python2.2/poplib.pys   apops    
 	"c    s   |  i d | | f  Sd S(   s   Retrieve message header of message number 'which'
        and first 'howmuch' lines of message body.

        Result is in form ['response', ['line', ...], octets].
        s	   TOP %s %sN(   s   selfs   _longcmds   whichs   howmuch(   s   selfs   whichs   howmuch(    (    s#   /mit/python/lib/python2.2/poplib.pys   top,s     c    s-   | o |  i d |  Sn |  i d  Sd S(   s   Return message digest (unique id) list.

        If 'which', result contains unique id for that message
        in the form 'response mesgnum uid', otherwise result is
        the list ['response', ['mesgnum uid', ...], octets]
        s   UIDL %ss   UIDLN(   s   whichs   selfs	   _shortcmds   _longcmd(   s   selfs   which(    (    s#   /mit/python/lib/python2.2/poplib.pys   uidl5s     (   s   __doc__s	   POP3_PORTs   __init__s   _putlines   _putcmds   _getlines   _getresps   _getlongresps	   _shortcmds   _longcmds
   getwelcomes   set_debuglevels   users   pass_s   stats   Nones   lists   retrs   deles   noops   rsets   quits   rpops   res   compiles	   timestamps   apops   tops   uidl(    (    (    s#   /mit/python/lib/python2.2/poplib.pys   POP3  s2   ( 												
										s   __main__i   i   i   s   Message s   :s      s   -----------------------(   s   __doc__s   res   sockets   __all__s	   Exceptions   error_protos	   POP3_PORTs   CRs   LFs   CRLFs   POP3s   __name__s   syss   argvs   as
   getwelcomes   users   pass_s   lists   stats   numMsgss	   totalSizes   ranges   is   retrs   headers   msgs   octetss   lines   quit(   s   LFs   syss   sockets   error_protos	   POP3_PORTs	   totalSizes   is   headers   octetss   POP3s   res   CRLFs   as   msgs   CRs   lines   numMsgss   __all__(    (    s#   /mit/python/lib/python2.2/poplib.pys   ? s4   
 "	
  	