blob: 88691f802e316b1670abb89a7a4d843652259dfc [file] [log] [blame]
Barry Warsawbb113862004-10-03 03:16:19 +00001# Copyright (C) 2001-2004 Python Software Foundation
2# 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
Barry Warsaw524af6f2002-06-02 19:05:08 +00007from email import Message
Barry Warsawba925802001-09-23 03:17:28 +00008
9
Barry Warsawe968ead2001-10-04 17:05:11 +000010
Barry Warsawba925802001-09-23 03:17:28 +000011class MIMEBase(Message.Message):
12 """Base class for MIME specializations."""
13
Barry Warsaw76fac8e2001-09-26 05:36:36 +000014 def __init__(self, _maintype, _subtype, **_params):
Barry Warsawba925802001-09-23 03:17:28 +000015 """This constructor adds a Content-Type: and a MIME-Version: header.
16
Barry Warsaw76fac8e2001-09-26 05:36:36 +000017 The Content-Type: header is taken from the _maintype and _subtype
Barry Warsawba925802001-09-23 03:17:28 +000018 arguments. Additional parameters for this header are taken from the
19 keyword arguments.
20 """
21 Message.Message.__init__(self)
Barry Warsaw76fac8e2001-09-26 05:36:36 +000022 ctype = '%s/%s' % (_maintype, _subtype)
Barry Warsawba925802001-09-23 03:17:28 +000023 self.add_header('Content-Type', ctype, **_params)
24 self['MIME-Version'] = '1.0'