blob: ac919258b15ba8e678fde8a979ba2f93828930db [file] [log] [blame]
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00001# Copyright (C) 2001-2006 Python Software Foundation
Barry Warsawbb113862004-10-03 03:16:19 +00002# Author: Barry Warsaw
3# Contact: email-sig@python.org
Barry Warsawba925802001-09-23 03:17:28 +00004
Barry Warsawbb113862004-10-03 03:16:19 +00005"""Base class for MIME specializations."""
Barry Warsawba925802001-09-23 03:17:28 +00006
Thomas Wouters49fd7fa2006-04-21 10:40:58 +00007__all__ = ['MIMEBase']
8
9from email import message
Barry Warsawba925802001-09-23 03:17:28 +000010
11
Barry Warsawe968ead2001-10-04 17:05:11 +000012
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000013class MIMEBase(message.Message):
Barry Warsawba925802001-09-23 03:17:28 +000014 """Base class for MIME specializations."""
15
Barry Warsaw76fac8e2001-09-26 05:36:36 +000016 def __init__(self, _maintype, _subtype, **_params):
Barry Warsawba925802001-09-23 03:17:28 +000017 """This constructor adds a Content-Type: and a MIME-Version: header.
18
Barry Warsaw76fac8e2001-09-26 05:36:36 +000019 The Content-Type: header is taken from the _maintype and _subtype
Barry Warsawba925802001-09-23 03:17:28 +000020 arguments. Additional parameters for this header are taken from the
21 keyword arguments.
22 """
Thomas Wouters49fd7fa2006-04-21 10:40:58 +000023 message.Message.__init__(self)
Barry Warsaw76fac8e2001-09-26 05:36:36 +000024 ctype = '%s/%s' % (_maintype, _subtype)
Barry Warsawba925802001-09-23 03:17:28 +000025 self.add_header('Content-Type', ctype, **_params)
26 self['MIME-Version'] = '1.0'