Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/library/email.message.rst

    r2 r391  
    1 :mod:`email`: Representing an email message
    2 -------------------------------------------
     1:mod:`email.message`: Representing an email message
     2---------------------------------------------------
    33
    44.. module:: email.message
     
    4949      format the message the way you want.  For example, by default it mangles
    5050      lines that begin with ``From``.  For more flexibility, instantiate a
    51       :class:`~email.generator.Generator` instance and use its :meth:`flatten`
    52       method directly.  For example::
     51      :class:`~email.generator.Generator` instance and use its
     52      :meth:`~email.generator.Generator.flatten` method directly.  For example::
    5353
    5454         from cStringIO import StringIO
     
    134134      be converted to a :class:`~email.charset.Charset` instance.  If *charset*
    135135      is ``None``, the ``charset`` parameter will be removed from the
    136       :mailheader:`Content-Type` header. Anything else will generate a
    137       :exc:`TypeError`.
    138 
    139       The message will be assumed to be of type :mimetype:`text/\*` encoded with
    140       *charset.input_charset*.  It will be converted to *charset.output_charset*
    141       and encoded properly, if needed, when generating the plain text
     136      :mailheader:`Content-Type` header (the message will not be otherwise
     137      modified).  Anything else will generate a :exc:`TypeError`.
     138
     139      If there is no existing :mailheader:`MIME-Version` header one will be
     140      added.  If there is no existing :mailheader:`Content-Type` header, one
     141      will be added with a value of :mimetype:`text/plain`.  Whether the
     142      :mailheader:`Content-Type` header already exists or not, its ``charset``
     143      parameter will be set to *charset.output_charset*.   If
     144      *charset.input_charset* and *charset.output_charset* differ, the payload
     145      will be re-encoded to the *output_charset*.  If there is no existing
     146      :mailheader:`Content-Transfer-Encoding` header, then the payload will be
     147      transfer-encoded, if needed, using the specified
     148      :class:`~email.charset.Charset`, and a header with the appropriate value
     149      will be added.  If a :mailheader:`Content-Transfer-Encoding` header
     150      already exists, the payload is assumed to already be correctly encoded
     151      using that :mailheader:`Content-Transfer-Encoding` and is not modified.
     152
     153      The message will be assumed to be of type :mimetype:`text/\*`, with the
     154      payload either in unicode or encoded with *charset.input_charset*.
     155      It will be encoded or converted to *charset.output_charset*
     156      and transfer encoded properly, if needed, when generating the plain text
    142157      representation of the message.  MIME headers (:mailheader:`MIME-Version`,
    143158      :mailheader:`Content-Type`, :mailheader:`Content-Transfer-Encoding`) will
     
    266281      dashes are illegal in Python identifiers).  Normally, the parameter will
    267282      be added as ``key="value"`` unless the value is ``None``, in which case
    268       only the key will be added.
     283      only the key will be added.  If the value contains non-ASCII characters,
     284      it must be specified as a three tuple in the format
     285      ``(CHARSET, LANGUAGE, VALUE)``, where ``CHARSET`` is a string naming the
     286      charset to be used to encode the value, ``LANGUAGE`` can usually be set
     287      to ``None`` or the empty string (see :RFC:`2231` for other possibilities),
     288      and ``VALUE`` is the string value containing non-ASCII code points.
    269289
    270290      Here's an example::
     
    275295
    276296         Content-Disposition: attachment; filename="bud.gif"
     297
     298      An example with non-ASCII characters::
     299
     300         msg.add_header('Content-Disposition', 'attachment',
     301                        filename=('iso-8859-1', '', 'Fußballer.ppt'))
     302
     303      Which produces ::
     304
     305         Content-Disposition: attachment; filename*="iso-8859-1''Fu%DFballer.ppt"
    277306
    278307
     
    380409      :func:`email.utils.collapse_rfc2231_value`, passing in the return value
    381410      from :meth:`get_param`.  This will return a suitably decoded Unicode
    382       string whn the value is a tuple, or the original string unquoted if it
     411      string when the value is a tuple, or the original string unquoted if it
    383412      isn't.  For example::
    384413
     
    448477      :mailheader:`Content-Disposition` header of the message.  If the header
    449478      does not have a ``filename`` parameter, this method falls back to looking
    450       for the ``name`` parameter.  If neither is found, or the header is
    451       missing, then *failobj* is returned.  The returned string will always be
    452       unquoted as per :func:`email.utils.unquote`.
     479      for the ``name`` parameter on the :mailheader:`Content-Type` header.  If
     480      neither is found, or the header is missing, then *failobj* is returned.
     481      The returned string will always be unquoted as per
     482      :func:`email.utils.unquote`.
    453483
    454484
     
    465495      Set the ``boundary`` parameter of the :mailheader:`Content-Type` header to
    466496      *boundary*.  :meth:`set_boundary` will always quote *boundary* if
    467       necessary.  A :exc:`HeaderParseError` is raised if the message object has
    468       no :mailheader:`Content-Type` header.
     497      necessary.  A :exc:`~email.errors.HeaderParseError` is raised if the
     498      message object has no :mailheader:`Content-Type` header.
    469499
    470500      Note that using this method is subtly different than deleting the old
     
    560590      .. versionchanged:: 2.5
    561591         You do not need to set the epilogue to the empty string in order for the
    562          :class:`Generator` to print a newline at the end of the file.
     592         :class:`~email.generator.Generator` to print a newline at the end of the
     593         file.
    563594
    564595
Note: See TracChangeset for help on using the changeset viewer.