10a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# Copyright (C) 2002-2006 Python Software Foundation 20a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# Author: Barry Warsaw 30a8c90248264a8b26970b4473770bcc3df8515fJosh Gao# Contact: email-sig@python.org 40a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 50a8c90248264a8b26970b4473770bcc3df8515fJosh Gao"""Base class for MIME type messages that are not multipart.""" 60a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 70a8c90248264a8b26970b4473770bcc3df8515fJosh Gao__all__ = ['MIMENonMultipart'] 80a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 90a8c90248264a8b26970b4473770bcc3df8515fJosh Gaofrom email import errors 100a8c90248264a8b26970b4473770bcc3df8515fJosh Gaofrom email.mime.base import MIMEBase 110a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 120a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 130a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 140a8c90248264a8b26970b4473770bcc3df8515fJosh Gaoclass MIMENonMultipart(MIMEBase): 150a8c90248264a8b26970b4473770bcc3df8515fJosh Gao """Base class for MIME multipart/* type messages.""" 160a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 170a8c90248264a8b26970b4473770bcc3df8515fJosh Gao def attach(self, payload): 180a8c90248264a8b26970b4473770bcc3df8515fJosh Gao # The public API prohibits attaching multiple subparts to MIMEBase 190a8c90248264a8b26970b4473770bcc3df8515fJosh Gao # derived subtypes since none of them are, by definition, of content 200a8c90248264a8b26970b4473770bcc3df8515fJosh Gao # type multipart/* 210a8c90248264a8b26970b4473770bcc3df8515fJosh Gao raise errors.MultipartConversionError( 220a8c90248264a8b26970b4473770bcc3df8515fJosh Gao 'Cannot attach additional subparts to non-multipart/*') 23