183760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh# Copyright (C) 2002-2006 Python Software Foundation 283760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh# Author: Barry Warsaw 383760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh# Contact: email-sig@python.org 483760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 583760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh"""Base class for MIME type messages that are not multipart.""" 683760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 783760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh__all__ = ['MIMENonMultipart'] 883760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 983760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsiehfrom email import errors 1083760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsiehfrom email.mime.base import MIMEBase 1183760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 1283760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 1383760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 1483760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsiehclass MIMENonMultipart(MIMEBase): 1583760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh """Base class for MIME multipart/* type messages.""" 1683760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 1783760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh def attach(self, payload): 1883760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh # The public API prohibits attaching multiple subparts to MIMEBase 1983760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh # derived subtypes since none of them are, by definition, of content 2083760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh # type multipart/* 2183760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh raise errors.MultipartConversionError( 2283760d213fb3bec7b4117d266fcfbf6fe2ba14abAndrew Hsieh 'Cannot attach additional subparts to non-multipart/*') 23