equal
deleted
inserted
replaced
|
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 |
|
7 __all__ = ["MIMEApplication"] |
|
8 |
|
9 from email import encoders |
|
10 from email.mime.nonmultipart import MIMENonMultipart |
|
11 |
|
12 |
|
13 class MIMEApplication(MIMENonMultipart): |
|
14 """Class for generating application/* MIME documents.""" |
|
15 |
|
16 def __init__(self, _data, _subtype='octet-stream', |
|
17 _encoder=encoders.encode_base64, **_params): |
|
18 """Create an application/* type MIME document. |
|
19 |
|
20 _data is a string containing the raw applicatoin data. |
|
21 |
|
22 _subtype is the MIME content type subtype, defaulting to |
|
23 'octet-stream'. |
|
24 |
|
25 _encoder is a function which will perform the actual encoding for |
|
26 transport of the application data, defaulting to base64 encoding. |
|
27 |
|
28 Any additional keyword arguments are passed to the base class |
|
29 constructor, which turns them into parameters on the Content-Type |
|
30 header. |
|
31 """ |
|
32 if _subtype is None: |
|
33 raise TypeError('Invalid application MIME subtype') |
|
34 MIMENonMultipart.__init__(self, 'application', _subtype, **_params) |
|
35 self.set_payload(_data) |
|
36 _encoder(self) |