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

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

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