1 | n/a | # Copyright (C) 2001-2006 Python Software Foundation |
---|
2 | n/a | # Author: Barry Warsaw |
---|
3 | n/a | # Contact: email-sig@python.org |
---|
4 | n/a | |
---|
5 | n/a | """Base class for MIME specializations.""" |
---|
6 | n/a | |
---|
7 | n/a | __all__ = ['MIMEBase'] |
---|
8 | n/a | |
---|
9 | n/a | import email.policy |
---|
10 | n/a | |
---|
11 | n/a | from email import message |
---|
12 | n/a | |
---|
13 | n/a | |
---|
14 | n/a | |
---|
15 | n/a | class MIMEBase(message.Message): |
---|
16 | n/a | """Base class for MIME specializations.""" |
---|
17 | n/a | |
---|
18 | n/a | def __init__(self, _maintype, _subtype, *, policy=None, **_params): |
---|
19 | n/a | """This constructor adds a Content-Type: and a MIME-Version: header. |
---|
20 | n/a | |
---|
21 | n/a | The Content-Type: header is taken from the _maintype and _subtype |
---|
22 | n/a | arguments. Additional parameters for this header are taken from the |
---|
23 | n/a | keyword arguments. |
---|
24 | n/a | """ |
---|
25 | n/a | if policy is None: |
---|
26 | n/a | policy = email.policy.compat32 |
---|
27 | n/a | message.Message.__init__(self, policy=policy) |
---|
28 | n/a | ctype = '%s/%s' % (_maintype, _subtype) |
---|
29 | n/a | self.add_header('Content-Type', ctype, **_params) |
---|
30 | n/a | self['MIME-Version'] = '1.0' |
---|