xref: /aosp_15_r20/prebuilts/build-tools/common/py3-stdlib/email/mime/nonmultipart.py (revision cda5da8d549138a6648c5ee6d7a49cf8f4a657be)
1*cda5da8dSAndroid Build Coastguard Worker# Copyright (C) 2002-2006 Python Software Foundation
2*cda5da8dSAndroid Build Coastguard Worker# Author: Barry Warsaw
3*cda5da8dSAndroid Build Coastguard Worker# Contact: [email protected]
4*cda5da8dSAndroid Build Coastguard Worker
5*cda5da8dSAndroid Build Coastguard Worker"""Base class for MIME type messages that are not multipart."""
6*cda5da8dSAndroid Build Coastguard Worker
7*cda5da8dSAndroid Build Coastguard Worker__all__ = ['MIMENonMultipart']
8*cda5da8dSAndroid Build Coastguard Worker
9*cda5da8dSAndroid Build Coastguard Workerfrom email import errors
10*cda5da8dSAndroid Build Coastguard Workerfrom email.mime.base import MIMEBase
11*cda5da8dSAndroid Build Coastguard Worker
12*cda5da8dSAndroid Build Coastguard Worker
13*cda5da8dSAndroid Build Coastguard Worker
14*cda5da8dSAndroid Build Coastguard Workerclass MIMENonMultipart(MIMEBase):
15*cda5da8dSAndroid Build Coastguard Worker    """Base class for MIME non-multipart type messages."""
16*cda5da8dSAndroid Build Coastguard Worker
17*cda5da8dSAndroid Build Coastguard Worker    def attach(self, payload):
18*cda5da8dSAndroid Build Coastguard Worker        # The public API prohibits attaching multiple subparts to MIMEBase
19*cda5da8dSAndroid Build Coastguard Worker        # derived subtypes since none of them are, by definition, of content
20*cda5da8dSAndroid Build Coastguard Worker        # type multipart/*
21*cda5da8dSAndroid Build Coastguard Worker        raise errors.MultipartConversionError(
22*cda5da8dSAndroid Build Coastguard Worker            'Cannot attach additional subparts to non-multipart/*')
23