™N
ª´ 7c       s–    d  Z    d Z  d Z  d Z  k Z k Z k Z  d e f d „  ƒ  YZ  d Z	  d Z
  d Z  e
 e Z ! d	 f  d
 „  ƒ  YZ -e d j oï .e e ƒ Z /e i ƒ  GH0e i e ƒ 1e i e ƒ 2e i ƒ  3e i ƒ  \ Z Z 4xy e d e d ƒ d 4r_ Z 5e i e ƒ \ Z Z Z 6d Ge Gd GH7x e d 7r Z 8d e GHq\W9d GHqW:e i ƒ  n d S(   sÎ   A POP3 client class.

Based on the J. Myers POP3 draft, Jan. 96

Author: David Ascher <david_ascher@brown.edu>
        [heavily stealing from nntplib.py]
Updated: Piers Lauder <piers@cs.su.oz.au> [Jul '97]
s	   localhosts   tests   _passwd_s   error_protoc      s     RS(   N(    (    s"   /mit/gnome/lib/python1.5/poplib.pys   error_proto s    in   s   s   
s   POP3c      s=  ! d  Z  I L e d „ Z V d „  Z ] d „  Z f d „  Z x 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
		authorisation 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�   L M | |  _  N | |  _ O t i t i t i ƒ |  _ P |  i i |  i  |  i ƒ Q |  i i d ƒ |  _	 R d |  _
 S |  i ƒ  |  _ d  S(   Ns   rbi    (   s   hosts   selfs   ports   sockets   AF_INETs   SOCK_STREAMs   socks   connects   makefiles   files
   _debuggings   _getresps   welcome(   s   selfs   hosts   ports"   /mit/gnome/lib/python1.5/poplib.pys   __init__L s   c    s$   V X |  i i d | t f ƒ d  S(   Ns   %s%s(   s   selfs   socks   sends   lines   CRLF(   s   selfs   lines"   /mit/gnome/lib/python1.5/poplib.pys   _putlineV s   c    s   ] _ |  i | ƒ d  S(   N(   s   selfs   _putlines   line(   s   selfs   lines"   /mit/gnome/lib/python1.5/poplib.pys   _putcmd] s   c    s°   f g |  i i ƒ  } i | o i t d ƒ ‚ n j t | ƒ } n | d t j o o | d  | f Sn p | d t j o q | d d !| f Sn r | d  | f Sd  S(   Ns   -ERR EOFi   i    i   (	   s   selfs   files   readlines   lines   error_protos   lens   octetss   CRLFs   CR(   s   selfs   lines   octetss"   /mit/gnome/lib/python1.5/poplib.pys   _getlinef s    c    sS   x y |  i ƒ  \ } } { | d  } | | d j o } t | ƒ ‚ n ~ | Sd  S(   Ni   s   +(   s   selfs   _getlines   resps   os   cs   error_proto(   s   selfs   resps   os   cs"   /mit/gnome/lib/python1.5/poplib.pys   _getrespx s
   c    s—   ƒ „ |  i ƒ  } … g  } d } † |  i ƒ  \ } } ‡ xG ‡ | d j o6 ˆ | | } ‰ | i | ƒ Š |  i ƒ  \ } } q< W‹ | | | f Sd  S(   Ni    s   .(	   s   selfs   _getresps   resps   lists   octetss   _getlines   lines   os   append(   s   selfs   resps   lists   octetss   lines   os"   /mit/gnome/lib/python1.5/poplib.pys   _getlongrespƒ s    c    s$   � ‘ |  i | ƒ ’ |  i ƒ  Sd  S(   N(   s   selfs   _putcmds   lines   _getresp(   s   selfs   lines"   /mit/gnome/lib/python1.5/poplib.pys	   _shortcmd� s   c    s$   — ˜ |  i | ƒ ™ |  i ƒ  Sd  S(   N(   s   selfs   _putcmds   lines   _getlongresp(   s   selfs   lines"   /mit/gnome/lib/python1.5/poplib.pys   _longcmd— s   c    s   ž Ÿ |  i Sd  S(   N(   s   selfs   welcome(   s   selfs"   /mit/gnome/lib/python1.5/poplib.pys
   getwelcomež s   c    s   ¢ £ | |  _ d  S(   N(   s   levels   selfs
   _debugging(   s   selfs   levels"   /mit/gnome/lib/python1.5/poplib.pys   set_debuglevel¢ s   c    s   ¨ ¬ ­ |  i d | ƒ Sd S(   sL   Send user name, return response
		
		(should indicate password required).
		s   USER %sN(   s   selfs	   _shortcmds   user(   s   selfs   users"   /mit/gnome/lib/python1.5/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   pswds"   /mit/gnome/lib/python1.5/poplib.pys   pass_° s   c    sg   º ¾ ¿ |  i d ƒ } À t i | ƒ } Â t i | d ƒ } Ã t i | d ƒ } Ä | | f Sd S(   sS   Get mailbox status.
		
		Result is tuple of 2 ints (message count, mailbox size)
		s   STATi   i   N(	   s   selfs	   _shortcmds   retvals   strings   splits   retss   atois   numMessagess   sizeMessages(   s   selfs   retvals   retss   numMessagess   sizeMessagess"   /mit/gnome/lib/python1.5/poplib.pys   statº s   c    s<   Ç Ì Í | o Î |  i d | ƒ Sn Ï |  i d ƒ Sd S(   sŠ   Request listing, return result.
		Result is in form ['response', ['mesg_num octets', ...]].

		Unsure what the optional 'msg' arg does.
		s   LIST %ss   LISTN(   s   whichs   selfs   _longcmd(   s   selfs   whichs"   /mit/gnome/lib/python1.5/poplib.pys   listÇ s   
c    s   Ò Ö × |  i d | ƒ Sd S(   sc   Retrieve whole message number 'which'.

		Result is in form ['response', ['line', ...], octets].
		s   RETR %sN(   s   selfs   _longcmds   which(   s   selfs   whichs"   /mit/gnome/lib/python1.5/poplib.pys   retrÒ s   c    s   Ú Þ ß |  i d | ƒ Sd S(   s:   Delete message number 'which'.

		Result is 'response'.
		s   DELE %sN(   s   selfs	   _shortcmds   which(   s   selfs   whichs"   /mit/gnome/lib/python1.5/poplib.pys   deleÚ s   c    s   â æ ç |  i d ƒ Sd S(   sN   Does nothing.
		
		One supposes the response indicates the server is alive.
		s   NOOPN(   s   selfs	   _shortcmd(   s   selfs"   /mit/gnome/lib/python1.5/poplib.pys   noopâ s   c    s   ê ë ì |  i d ƒ Sd S(   s   Not sure what this does.s   RSETN(   s   selfs	   _shortcmd(   s   selfs"   /mit/gnome/lib/python1.5/poplib.pys   rsetê s   c    s�   ï ð ñ y ò |  i d ƒ } Wn% ó t t ƒ j
 o ô t } 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"   /mit/gnome/lib/python1.5/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   users"   /mit/gnome/lib/python1.5/poplib.pys   rpopÿ s   s   \+OK.*\(<[^>]+>\)c    s¨   |  i i |  i ƒ d j o t d ƒ ‚ n k } | i |  i i d ƒ | ƒ i	 ƒ  } t
 i t d „  | ƒ 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()'
		i    s!   -ERR APOP not supported by serveri   c    s   d t  |  ƒ S(   Ns   %02x(   s   ords   x(   s   xs"   /mit/gnome/lib/python1.5/poplib.pys   <lambda>s    s    s
   APOP %s %sN(   s   selfs	   timestamps   matchs   welcomes   error_protos   md5s   news   groups   secrets   digests   strings   joins   maps	   _shortcmds   user(   s   selfs   users   secrets   md5s   digests"   /mit/gnome/lib/python1.5/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   howmuchs"   /mit/gnome/lib/python1.5/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,
		otherwise result is list ['response', ['mesgnum uid', ...], octets]
		s   UIDL %ss   UIDLN(   s   whichs   selfs	   _shortcmds   _longcmd(   s   selfs   whichs"   /mit/gnome/lib/python1.5/poplib.pys   uidl"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   regexs   compiles	   timestamps   apops   tops   uidl(    s"   /mit/gnome/lib/python1.5/poplib.pys   POP3! s2   	(
	
	s   __main__i   i    s   Message s   :s      s   -----------------------N(   s   __doc__s
   TESTSERVERs   TESTACCOUNTs   TESTPASSWORDs   regexs   sockets   strings	   Exceptions   error_protos	   POP3_PORTs   CRs   LFs   CRLFs   POP3s   __name__s   as
   getwelcomes   users   pass_s   lists   stats   numMsgss	   totalSizes   ranges   is   retrs   headers   msgs   octetss   lines   quit(    s"   /mit/gnome/lib/python1.5/poplib.pys   ? s6   						ÿ  	 	