Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 1 | # Copyright (C) 2001-2006 Python Software Foundation |
Barry Warsaw | bb11386 | 2004-10-03 03:16:19 +0000 | [diff] [blame] | 2 | # Author: Barry Warsaw |
| 3 | # Contact: email-sig@python.org |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 4 | |
Barry Warsaw | bb11386 | 2004-10-03 03:16:19 +0000 | [diff] [blame] | 5 | """Base class for MIME specializations.""" |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 6 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 7 | __all__ = ['MIMEBase'] |
| 8 | |
| 9 | from email import message |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 10 | |
| 11 | |
Barry Warsaw | e968ead | 2001-10-04 17:05:11 +0000 | [diff] [blame] | 12 | |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 13 | class MIMEBase(message.Message): |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 14 | """Base class for MIME specializations.""" |
| 15 | |
Barry Warsaw | 76fac8e | 2001-09-26 05:36:36 +0000 | [diff] [blame] | 16 | def __init__(self, _maintype, _subtype, **_params): |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 17 | """This constructor adds a Content-Type: and a MIME-Version: header. |
| 18 | |
Barry Warsaw | 76fac8e | 2001-09-26 05:36:36 +0000 | [diff] [blame] | 19 | The Content-Type: header is taken from the _maintype and _subtype |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 20 | arguments. Additional parameters for this header are taken from the |
| 21 | keyword arguments. |
| 22 | """ |
Thomas Wouters | 49fd7fa | 2006-04-21 10:40:58 +0000 | [diff] [blame] | 23 | message.Message.__init__(self) |
Barry Warsaw | 76fac8e | 2001-09-26 05:36:36 +0000 | [diff] [blame] | 24 | ctype = '%s/%s' % (_maintype, _subtype) |
Barry Warsaw | ba92580 | 2001-09-23 03:17:28 +0000 | [diff] [blame] | 25 | self.add_header('Content-Type', ctype, **_params) |
| 26 | self['MIME-Version'] = '1.0' |