OLD | NEW |
(Empty) | |
| 1 # Copyright (C) 2001-2006 Python Software Foundation |
| 2 # Author: Keith Dart |
| 3 # Contact: email-sig@python.org |
| 4 |
| 5 """Class representing application/* type MIME documents.""" |
| 6 from __future__ import unicode_literals |
| 7 from __future__ import division |
| 8 from __future__ import absolute_import |
| 9 |
| 10 from future.backports.email import encoders |
| 11 from future.backports.email.mime.nonmultipart import MIMENonMultipart |
| 12 |
| 13 __all__ = ["MIMEApplication"] |
| 14 |
| 15 |
| 16 class MIMEApplication(MIMENonMultipart): |
| 17 """Class for generating application/* MIME documents.""" |
| 18 |
| 19 def __init__(self, _data, _subtype='octet-stream', |
| 20 _encoder=encoders.encode_base64, **_params): |
| 21 """Create an application/* type MIME document. |
| 22 |
| 23 _data is a string containing the raw application data. |
| 24 |
| 25 _subtype is the MIME content type subtype, defaulting to |
| 26 'octet-stream'. |
| 27 |
| 28 _encoder is a function which will perform the actual encoding for |
| 29 transport of the application data, defaulting to base64 encoding. |
| 30 |
| 31 Any additional keyword arguments are passed to the base class |
| 32 constructor, which turns them into parameters on the Content-Type |
| 33 header. |
| 34 """ |
| 35 if _subtype is None: |
| 36 raise TypeError('Invalid application MIME subtype') |
| 37 MIMENonMultipart.__init__(self, 'application', _subtype, **_params) |
| 38 self.set_payload(_data) |
| 39 _encoder(self) |
OLD | NEW |