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