diff options
author | Barry Warsaw <barry@python.org> | 2001-09-26 05:34:30 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2001-09-26 05:34:30 (GMT) |
commit | 3dd978dfff316a521a899c9e17daa0795ec17edb (patch) | |
tree | 7b46bb159d83cdae94bd0ad4b687ce52b89550c9 /Lib/email | |
parent | b384e01796fad1293256262e7ab022f176afce9a (diff) | |
download | cpython-3dd978dfff316a521a899c9e17daa0795ec17edb.zip cpython-3dd978dfff316a521a899c9e17daa0795ec17edb.tar.gz cpython-3dd978dfff316a521a899c9e17daa0795ec17edb.tar.bz2 |
Image.py and class Image => MIMEImage.py and MIMEImage
Text.py and class Text => MIMEText.py and MIMEText
MessageRFC822.py and class MessageRFC822 => MIMEMessage.py and MIMEMessage
These are renamed so as to be more consistent; these are MIME specific
derived classes for when creating the object model out of whole cloth.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/MIMEImage.py (renamed from Lib/email/Image.py) | 16 | ||||
-rw-r--r-- | Lib/email/MIMEMessage.py | 28 | ||||
-rw-r--r-- | Lib/email/MIMEText.py (renamed from Lib/email/Text.py) | 8 | ||||
-rw-r--r-- | Lib/email/MessageRFC822.py | 24 |
4 files changed, 40 insertions, 36 deletions
diff --git a/Lib/email/Image.py b/Lib/email/MIMEImage.py index d350785..963da23 100644 --- a/Lib/email/Image.py +++ b/Lib/email/MIMEImage.py @@ -13,17 +13,17 @@ import Encoders -class Image(MIMEBase.MIMEBase): +class MIMEImage(MIMEBase.MIMEBase): """Class for generating image/* type MIME documents.""" - def __init__(self, _imagedata, _minor=None, + def __init__(self, _imagedata, _subtype=None, _encoder=Encoders.encode_base64, **_params): """Create an image/* type MIME document. _imagedata is a string containing the raw image data. If this data can be decoded by the standard Python `imghdr' module, then the subtype will be automatically included in the Content-Type: header. - Otherwise, you can specify the specific image subtype via the _minor + Otherwise, you can specify the specific image subtype via the _subtype parameter. _encoder is a function which will perform the actual encoding for @@ -37,10 +37,10 @@ class Image(MIMEBase.MIMEBase): constructor, which turns them into parameters on the Content-Type: header. """ - if _minor is None: - _minor = imghdr.what(None, _imagedata) - if _minor is None: - raise TypeError, 'Could not guess image _minor type' - MIMEBase.MIMEBase.__init__(self, 'image', _minor, **_params) + if _subtype is None: + _subtype = imghdr.what(None, _imagedata) + if _subtype is None: + raise TypeError, 'Could not guess image MIME subtype' + MIMEBase.MIMEBase.__init__(self, 'image', _subtype, **_params) self.set_payload(_imagedata) _encoder(self) diff --git a/Lib/email/MIMEMessage.py b/Lib/email/MIMEMessage.py new file mode 100644 index 0000000..fc4b2c6 --- /dev/null +++ b/Lib/email/MIMEMessage.py @@ -0,0 +1,28 @@ +# Copyright (C) 2001 Python Software Foundation +# Author: barry@zope.com (Barry Warsaw) + +"""Class representing message/* MIME documents. +""" + +import Message +import MIMEBase + + + +class MIMEMessage(MIMEBase.MIMEBase): + """Class representing message/* MIME documents.""" + + def __init__(self, _msg, _subtype='rfc822'): + """Create a message/* type MIME document. + + _msg is a message object and must be an instance of Message, or a + derived class of Message, otherwise a TypeError is raised. + + Optional _subtype defines the subtype of the contained message. The + default is "rfc822" (this is defined by the MIME standard, even though + the term "rfc822" is technically outdated by RFC 2822). + """ + MIMEBase.MIMEBase.__init__(self, 'message', _subtype) + if not isinstance(_msg, Message.Message): + raise TypeError, 'Argument is not an instance of Message' + self.set_payload(_msg) diff --git a/Lib/email/Text.py b/Lib/email/MIMEText.py index 5abfd0b..ccce9fb 100644 --- a/Lib/email/Text.py +++ b/Lib/email/MIMEText.py @@ -9,17 +9,17 @@ from Encoders import encode_7or8bit -class Text(MIMEBase.MIMEBase): +class MIMEText(MIMEBase.MIMEBase): """Class for generating text/* type MIME documents.""" - def __init__(self, _text, _minor='plain', _charset='us-ascii', + def __init__(self, _text, _subtype='plain', _charset='us-ascii', _encoder=encode_7or8bit): """Create a text/* type MIME document. _text is the string for this message object. If the text does not end in a newline, one is added. - _minor is the minor content type, defaulting to "plain". + _subtype is the MIME sub content type, defaulting to "plain". _charset is the character set parameter added to the Content-Type: header. This defaults to "us-ascii". @@ -33,7 +33,7 @@ class Text(MIMEBase.MIMEBase): but it does set Content-Transfer-Encoding: to either `7bit' or `8bit' as appropriate. """ - MIMEBase.MIMEBase.__init__(self, 'text', _minor, + MIMEBase.MIMEBase.__init__(self, 'text', _subtype, **{'charset': _charset}) if _text and _text[-1] <> '\n': _text += '\n' diff --git a/Lib/email/MessageRFC822.py b/Lib/email/MessageRFC822.py deleted file mode 100644 index 81cc4dc..0000000 --- a/Lib/email/MessageRFC822.py +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2001 Python Software Foundation -# Author: barry@zope.com (Barry Warsaw) - -"""Class for generating message/rfc822 MIME documents. -""" - -import Message -import MIMEBase - - - -class MessageRFC822(MIMEBase.MIMEBase): - """Class for generating message/rfc822 MIME documents.""" - - def __init__(self, _msg): - """Create a message/rfc822 type MIME document. - - _msg is a message object and must be an instance of Message, or a - derived class of Message, otherwise a TypeError is raised. - """ - MIMEBase.MIMEBase.__init__(self, 'message', 'rfc822') - if not isinstance(_msg, Message.Message): - raise TypeError, 'Argument is not an instance of Message' - self.set_payload(_msg) |