annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/email/mime/multipart.py @ 68:5028fdace37b

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