jpayne@68: # Copyright (C) 2001-2006 Python Software Foundation jpayne@68: # Author: Barry Warsaw jpayne@68: # Contact: email-sig@python.org jpayne@68: jpayne@68: """Base class for MIME specializations.""" jpayne@68: jpayne@68: __all__ = ['MIMEBase'] jpayne@68: jpayne@68: import email.policy jpayne@68: jpayne@68: from email import message jpayne@68: jpayne@68: jpayne@68: jpayne@68: class MIMEBase(message.Message): jpayne@68: """Base class for MIME specializations.""" jpayne@68: jpayne@68: def __init__(self, _maintype, _subtype, *, policy=None, **_params): jpayne@68: """This constructor adds a Content-Type: and a MIME-Version: header. jpayne@68: jpayne@68: The Content-Type: header is taken from the _maintype and _subtype jpayne@68: arguments. Additional parameters for this header are taken from the jpayne@68: keyword arguments. jpayne@68: """ jpayne@68: if policy is None: jpayne@68: policy = email.policy.compat32 jpayne@68: message.Message.__init__(self, policy=policy) jpayne@68: ctype = '%s/%s' % (_maintype, _subtype) jpayne@68: self.add_header('Content-Type', ctype, **_params) jpayne@68: self['MIME-Version'] = '1.0'