annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/email/mime/message.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) 2001-2006 Python Software Foundation
jpayne@68 2 # Author: Barry Warsaw
jpayne@68 3 # Contact: email-sig@python.org
jpayne@68 4
jpayne@68 5 """Class representing message/* MIME documents."""
jpayne@68 6
jpayne@68 7 __all__ = ['MIMEMessage']
jpayne@68 8
jpayne@68 9 from email import message
jpayne@68 10 from email.mime.nonmultipart import MIMENonMultipart
jpayne@68 11
jpayne@68 12
jpayne@68 13
jpayne@68 14 class MIMEMessage(MIMENonMultipart):
jpayne@68 15 """Class representing message/* MIME documents."""
jpayne@68 16
jpayne@68 17 def __init__(self, _msg, _subtype='rfc822', *, policy=None):
jpayne@68 18 """Create a message/* type MIME document.
jpayne@68 19
jpayne@68 20 _msg is a message object and must be an instance of Message, or a
jpayne@68 21 derived class of Message, otherwise a TypeError is raised.
jpayne@68 22
jpayne@68 23 Optional _subtype defines the subtype of the contained message. The
jpayne@68 24 default is "rfc822" (this is defined by the MIME standard, even though
jpayne@68 25 the term "rfc822" is technically outdated by RFC 2822).
jpayne@68 26 """
jpayne@68 27 MIMENonMultipart.__init__(self, 'message', _subtype, policy=policy)
jpayne@68 28 if not isinstance(_msg, message.Message):
jpayne@68 29 raise TypeError('Argument is not an instance of Message')
jpayne@68 30 # It's convenient to use this base class method. We need to do it
jpayne@68 31 # this way or we'll get an exception
jpayne@68 32 message.Message.attach(self, _msg)
jpayne@68 33 # And be sure our default type is set correctly
jpayne@68 34 self.set_default_type('message/rfc822')