ยปCore Development>Code coverage>Lib/email/mime/multipart.py

Python code coverage for Lib/email/mime/multipart.py

#countcontent
1n/a# Copyright (C) 2002-2006 Python Software Foundation
2n/a# Author: Barry Warsaw
3n/a# Contact: email-sig@python.org
4n/a
5n/a"""Base class for MIME multipart/* type messages."""
6n/a
7n/a__all__ = ['MIMEMultipart']
8n/a
9n/afrom email.mime.base import MIMEBase
10n/a
11n/a
12n/a
13n/aclass MIMEMultipart(MIMEBase):
14n/a """Base class for MIME multipart/* type messages."""
15n/a
16n/a def __init__(self, _subtype='mixed', boundary=None, _subparts=None,
17n/a *, policy=None,
18n/a **_params):
19n/a """Creates a multipart/* type message.
20n/a
21n/a By default, creates a multipart/mixed message, with proper
22n/a Content-Type and MIME-Version headers.
23n/a
24n/a _subtype is the subtype of the multipart content type, defaulting to
25n/a `mixed'.
26n/a
27n/a boundary is the multipart boundary string. By default it is
28n/a calculated as needed.
29n/a
30n/a _subparts is a sequence of initial subparts for the payload. It
31n/a must be an iterable object, such as a list. You can always
32n/a attach new subparts to the message by using the attach() method.
33n/a
34n/a Additional parameters for the Content-Type header are taken from the
35n/a keyword arguments (or passed into the _params argument).
36n/a """
37n/a MIMEBase.__init__(self, 'multipart', _subtype, policy=policy, **_params)
38n/a
39n/a # Initialise _payload to an empty list as the Message superclass's
40n/a # implementation of is_multipart assumes that _payload is a list for
41n/a # multipart messages.
42n/a self._payload = []
43n/a
44n/a if _subparts:
45n/a for p in _subparts:
46n/a self.attach(p)
47n/a if boundary:
48n/a self.set_boundary(boundary)