Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(80737)

Delta Between Two Patch Sets: Lib/poplib.py

Issue 21804: Implement thr UTF8 command (RFC 6856) in poplib.
Left Patch Set: Created 5 years, 2 months ago
Right Patch Set: Created 5 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Doc/library/poplib.rst ('k') | Lib/test/test_poplib.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 """A POP3 client class. 1 """A POP3 client class.
2 2
3 Based on the J. Myers POP3 draft, Jan. 96 3 Based on the J. Myers POP3 draft, Jan. 96
4 """ 4 """
5 5
6 # Author: David Ascher <david_ascher@brown.edu> 6 # Author: David Ascher <david_ascher@brown.edu>
7 # [heavily stealing from nntplib.py] 7 # [heavily stealing from nntplib.py]
8 # Updated: Piers Lauder <piers@cs.su.oz.au> [Jul '97] 8 # Updated: Piers Lauder <piers@cs.su.oz.au> [Jul '97]
9 # String method conversion and test jig improvements by ESR, February 2001. 9 # String method conversion and test jig improvements by ESR, February 2001.
10 # Added the POP3_SSL class. Methods loosely based on IMAP_SSL. Hector Urtubia <u rtubia@mrbook.org> Aug 2003 10 # Added the POP3_SSL class. Methods loosely based on IMAP_SSL. Hector Urtubia <u rtubia@mrbook.org> Aug 2003
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 NOOP noop() 63 NOOP noop()
64 RSET rset() 64 RSET rset()
65 QUIT quit() 65 QUIT quit()
66 66
67 Optional Commands (some servers support these): 67 Optional Commands (some servers support these):
68 RPOP name rpop(name) 68 RPOP name rpop(name)
69 APOP name digest apop(name, digest) 69 APOP name digest apop(name, digest)
70 TOP msg n top(msg, n) 70 TOP msg n top(msg, n)
71 UIDL [msg] uidl(msg = None) 71 UIDL [msg] uidl(msg = None)
72 CAPA capa() 72 CAPA capa()
73 STLS stls() 73 STLS stls()
Jim.J.Jewett 2014/06/23 15:24:37 Should UTF8 be added to this list?
zvyn 2014/07/02 02:03:31 Yes, I missed that.
74 UTF8 utf8()
74 75
75 Raises one exception: 'error_proto'. 76 Raises one exception: 'error_proto'.
76 77
77 Instantiate with: 78 Instantiate with:
78 POP3(hostname, port=110) 79 POP3(hostname, port=110)
79 80
80 NB: the POP protocol locks the mailbox from user 81 NB: the POP protocol locks the mailbox from user
81 authorization until QUIT, so be sure to get in, suck 82 authorization until QUIT, so be sure to get in, suck
82 the messages, and quit, each time you access the 83 the messages, and quit, each time you access the
83 mailbox. 84 mailbox.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 If 'which', result contains unique id for that message 338 If 'which', result contains unique id for that message
338 in the form 'response mesgnum uid', otherwise result is 339 in the form 'response mesgnum uid', otherwise result is
339 the list ['response', ['mesgnum uid', ...], octets] 340 the list ['response', ['mesgnum uid', ...], octets]
340 """ 341 """
341 if which is not None: 342 if which is not None:
342 return self._shortcmd('UIDL %s' % which) 343 return self._shortcmd('UIDL %s' % which)
343 return self._longcmd('UIDL') 344 return self._longcmd('UIDL')
344 345
345 346
346 def utf8(self): 347 def utf8(self):
347 """Enter UTF-8 mode if supported by the server. Return server 348 """Try to enter UTF-8 mode (see RFC 6856). Returns server response.
348 response. Specified in RFC 6856.
349 """ 349 """
350 return self._shortcmd('UTF8') 350 return self._shortcmd('UTF8')
Jim.J.Jewett 2014/06/23 15:24:37 What happens if the server does not support UTF-8
zvyn 2014/07/02 02:03:31 The server responds with an error. (I'll try to ma
351 351
352 352
353 def capa(self): 353 def capa(self):
354 """Return server capabilities (RFC 2449) as a dictionary 354 """Return server capabilities (RFC 2449) as a dictionary
355 >>> c=poplib.POP3('localhost') 355 >>> c=poplib.POP3('localhost')
356 >>> c.capa() 356 >>> c.capa()
357 {'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'], 357 {'IMPLEMENTATION': ['Cyrus', 'POP3', 'server', 'v2.2.12'],
358 'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RESP-CODE': [], 358 'TOP': [], 'LOGIN-DELAY': ['0'], 'AUTH-RESP-CODE': [],
359 'EXPIRE': ['NEVER'], 'USER': [], 'STLS': [], 'PIPELINING': [], 359 'EXPIRE': ['NEVER'], 'USER': [], 'STLS': [], 'PIPELINING': [],
360 'UIDL': [], 'RESP-CODES': []} 360 'UIDL': [], 'RESP-CODES': []}
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 a.pass_(sys.argv[3]) 459 a.pass_(sys.argv[3])
460 a.list() 460 a.list()
461 (numMsgs, totalSize) = a.stat() 461 (numMsgs, totalSize) = a.stat()
462 for i in range(1, numMsgs + 1): 462 for i in range(1, numMsgs + 1):
463 (header, msg, octets) = a.retr(i) 463 (header, msg, octets) = a.retr(i)
464 print("Message %d:" % i) 464 print("Message %d:" % i)
465 for line in msg: 465 for line in msg:
466 print(' ' + line) 466 print(' ' + line)
467 print('-----------------------') 467 print('-----------------------')
468 a.quit() 468 a.quit()
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+