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

Delta Between Two Patch Sets: Doc/library/email.util.rst

Issue 18761: Fix internal doc references for the email package (Closed)
Left Patch Set: Created 6 years, 9 months ago
Right Patch Set: Created 6 years, 9 months 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/email.rst ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 :mod:`email.utils`: Miscellaneous utilities 1 :mod:`email.utils`: Miscellaneous utilities
2 ------------------------------------------- 2 -------------------------------------------
3 3
4 .. module:: email.utils 4 .. module:: email.utils
5 :synopsis: Miscellaneous email package utilities. 5 :synopsis: Miscellaneous email package utilities.
6 6
7 7
8 There are several useful utilities provided in the :mod:`email.utils` module: 8 There are several useful utilities provided in the :mod:`email.utils` module:
9 9
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 :class:`~email.charset.Charset`. Defaults to ``utf-8``. 42 :class:`~email.charset.Charset`. Defaults to ``utf-8``.
43 43
44 .. versionchanged:: 3.3 44 .. versionchanged:: 3.3
45 Added the *charset* option. 45 Added the *charset* option.
46 46
47 47
48 .. function:: getaddresses(fieldvalues) 48 .. function:: getaddresses(fieldvalues)
49 49
50 This method returns a list of 2-tuples of the form returned by ``parseaddr()` `. 50 This method returns a list of 2-tuples of the form returned by ``parseaddr()` `.
51 *fieldvalues* is a sequence of header field values as might be returned by 51 *fieldvalues* is a sequence of header field values as might be returned by
52 :meth:`Message.get_all <email.message.Message.get_all>`. Here's a simple exa mple that gets all the recipients 52 :meth:`Message.get_all <email.message.Message.get_all>`. Here's a simple
53 of a message:: 53 example that gets all the recipients of a message::
54 54
55 from email.utils import getaddresses 55 from email.utils import getaddresses
56 56
57 tos = msg.get_all('to', []) 57 tos = msg.get_all('to', [])
58 ccs = msg.get_all('cc', []) 58 ccs = msg.get_all('cc', [])
59 resent_tos = msg.get_all('resent-to', []) 59 resent_tos = msg.get_all('resent-to', [])
60 resent_ccs = msg.get_all('resent-cc', []) 60 resent_ccs = msg.get_all('resent-cc', [])
61 all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs) 61 all_recipients = getaddresses(tos + ccs + resent_tos + resent_ccs)
62 62
63 63
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 180
181 Encode the string *s* according to :rfc:`2231`. Optional *charset* and 181 Encode the string *s* according to :rfc:`2231`. Optional *charset* and
182 *language*, if given is the character set name and language name to use. If 182 *language*, if given is the character set name and language name to use. If
183 neither is given, *s* is returned as-is. If *charset* is given but *language * 183 neither is given, *s* is returned as-is. If *charset* is given but *language *
184 is not, the string is encoded using the empty string for *language*. 184 is not, the string is encoded using the empty string for *language*.
185 185
186 186
187 .. function:: collapse_rfc2231_value(value, errors='replace', fallback_charset=' us-ascii') 187 .. function:: collapse_rfc2231_value(value, errors='replace', fallback_charset=' us-ascii')
188 188
189 When a header parameter is encoded in :rfc:`2231` format, 189 When a header parameter is encoded in :rfc:`2231` format,
190 :meth:`Message.get_param <email.message.Message.get_param>` may return a 3-tu ple containing the character set, 190 :meth:`Message.get_param <email.message.Message.get_param>` may return a
191 3-tuple containing the character set,
191 language, and value. :func:`collapse_rfc2231_value` turns this into a unicod e 192 language, and value. :func:`collapse_rfc2231_value` turns this into a unicod e
192 string. Optional *errors* is passed to the *errors* argument of :class:`str` 's 193 string. Optional *errors* is passed to the *errors* argument of :class:`str` 's
193 :func:`~str.encode` method; it defaults to ``'replace'``. Optional 194 :func:`~str.encode` method; it defaults to ``'replace'``. Optional
194 *fallback_charset* specifies the character set to use if the one in the 195 *fallback_charset* specifies the character set to use if the one in the
195 :rfc:`2231` header is not known by Python; it defaults to ``'us-ascii'``. 196 :rfc:`2231` header is not known by Python; it defaults to ``'us-ascii'``.
196 197
197 For convenience, if the *value* passed to :func:`collapse_rfc2231_value` is n ot 198 For convenience, if the *value* passed to :func:`collapse_rfc2231_value` is n ot
198 a tuple, it should be a string and it is returned unquoted. 199 a tuple, it should be a string and it is returned unquoted.
199 200
200 201
201 .. function:: decode_params(params) 202 .. function:: decode_params(params)
202 203
203 Decode parameters list according to :rfc:`2231`. *params* is a sequence of 204 Decode parameters list according to :rfc:`2231`. *params* is a sequence of
204 2-tuples containing elements of the form ``(content-type, string-value)``. 205 2-tuples containing elements of the form ``(content-type, string-value)``.
205 206
206 207
207 .. rubric:: Footnotes 208 .. rubric:: Footnotes
208 209
209 .. [#] Note that the sign of the timezone offset is the opposite of the sign of the 210 .. [#] Note that the sign of the timezone offset is the opposite of the sign of the
210 ``time.timezone`` variable for the same timezone; the latter variable follows 211 ``time.timezone`` variable for the same timezone; the latter variable follows
211 the POSIX standard while this module follows :rfc:`2822`. 212 the POSIX standard while this module follows :rfc:`2822`.
212 213
LEFTRIGHT

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