Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/future/backports/email/mime/multipart.py: 80%
15 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:53 +0000
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-25 06:53 +0000
1# Copyright (C) 2002-2006 Python Software Foundation
2# Author: Barry Warsaw
3# Contact: email-sig@python.org
5"""Base class for MIME multipart/* type messages."""
6from __future__ import unicode_literals
7from __future__ import division
8from __future__ import absolute_import
10__all__ = ['MIMEMultipart']
12from future.backports.email.mime.base import MIMEBase
15class MIMEMultipart(MIMEBase):
16 """Base class for MIME multipart/* type messages."""
18 def __init__(self, _subtype='mixed', boundary=None, _subparts=None,
19 **_params):
20 """Creates a multipart/* type message.
22 By default, creates a multipart/mixed message, with proper
23 Content-Type and MIME-Version headers.
25 _subtype is the subtype of the multipart content type, defaulting to
26 `mixed'.
28 boundary is the multipart boundary string. By default it is
29 calculated as needed.
31 _subparts is a sequence of initial subparts for the payload. It
32 must be an iterable object, such as a list. You can always
33 attach new subparts to the message by using the attach() method.
35 Additional parameters for the Content-Type header are taken from the
36 keyword arguments (or passed into the _params argument).
37 """
38 MIMEBase.__init__(self, 'multipart', _subtype, **_params)
40 # Initialise _payload to an empty list as the Message superclass's
41 # implementation of is_multipart assumes that _payload is a list for
42 # multipart messages.
43 self._payload = []
45 if _subparts:
46 for p in _subparts:
47 self.attach(p)
48 if boundary:
49 self.set_boundary(boundary)