mirror of
https://github.com/python/cpython.git
synced 2024-11-28 12:31:14 +08:00
Use absolute import paths for intrapackage imports.
Use MIMENonMultipart as the base class so that you can't attach() to these non-multipart message types.
This commit is contained in:
parent
7dc865ad72
commit
524af6f382
@ -6,9 +6,9 @@
|
||||
import sndhdr
|
||||
from cStringIO import StringIO
|
||||
|
||||
import MIMEBase
|
||||
import Errors
|
||||
import Encoders
|
||||
from email import Errors
|
||||
from email import Encoders
|
||||
from email.MIMENonMultipart import MIMENonMultipart
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ def _whatsnd(data):
|
||||
|
||||
|
||||
|
||||
class MIMEAudio(MIMEBase.MIMEBase):
|
||||
class MIMEAudio(MIMENonMultipart):
|
||||
"""Class for generating audio/* MIME documents."""
|
||||
|
||||
def __init__(self, _audiodata, _subtype=None,
|
||||
@ -66,6 +66,6 @@ class MIMEAudio(MIMEBase.MIMEBase):
|
||||
_subtype = _whatsnd(_audiodata)
|
||||
if _subtype is None:
|
||||
raise TypeError, 'Could not find audio MIME subtype'
|
||||
MIMEBase.MIMEBase.__init__(self, 'audio', _subtype, **_params)
|
||||
MIMENonMultipart.__init__(self, 'audio', _subtype, **_params)
|
||||
self.set_payload(_audiodata)
|
||||
_encoder(self)
|
||||
|
@ -4,7 +4,7 @@
|
||||
"""Base class for MIME specializations.
|
||||
"""
|
||||
|
||||
import Message
|
||||
from email import Message
|
||||
|
||||
|
||||
|
||||
|
@ -6,14 +6,13 @@
|
||||
|
||||
import imghdr
|
||||
|
||||
# Intrapackage imports
|
||||
import MIMEBase
|
||||
import Errors
|
||||
import Encoders
|
||||
from email import Errors
|
||||
from email import Encoders
|
||||
from email.MIMENonMultipart import MIMENonMultipart
|
||||
|
||||
|
||||
|
||||
class MIMEImage(MIMEBase.MIMEBase):
|
||||
class MIMEImage(MIMENonMultipart):
|
||||
"""Class for generating image/* type MIME documents."""
|
||||
|
||||
def __init__(self, _imagedata, _subtype=None,
|
||||
@ -41,6 +40,6 @@ class MIMEImage(MIMEBase.MIMEBase):
|
||||
_subtype = imghdr.what(None, _imagedata)
|
||||
if _subtype is None:
|
||||
raise TypeError, 'Could not guess image MIME subtype'
|
||||
MIMEBase.MIMEBase.__init__(self, 'image', _subtype, **_params)
|
||||
MIMENonMultipart.__init__(self, 'image', _subtype, **_params)
|
||||
self.set_payload(_imagedata)
|
||||
_encoder(self)
|
||||
|
@ -4,12 +4,12 @@
|
||||
"""Class representing message/* MIME documents.
|
||||
"""
|
||||
|
||||
import Message
|
||||
import MIMEBase
|
||||
from email import Message
|
||||
from email.MIMENonMultipart import MIMENonMultipart
|
||||
|
||||
|
||||
|
||||
class MIMEMessage(MIMEBase.MIMEBase):
|
||||
class MIMEMessage(MIMENonMultipart):
|
||||
"""Class representing message/* MIME documents."""
|
||||
|
||||
def __init__(self, _msg, _subtype='rfc822'):
|
||||
@ -22,7 +22,9 @@ class MIMEMessage(MIMEBase.MIMEBase):
|
||||
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)
|
||||
MIMENonMultipart.__init__(self, 'message', _subtype)
|
||||
if not isinstance(_msg, Message.Message):
|
||||
raise TypeError, 'Argument is not an instance of Message'
|
||||
self.set_payload(_msg)
|
||||
# It's convenient to use this base class method. We need to do it
|
||||
# this way or we'll get an exception
|
||||
Message.Message.attach(self, _msg)
|
||||
|
@ -5,12 +5,12 @@
|
||||
"""
|
||||
|
||||
import warnings
|
||||
import MIMEBase
|
||||
from Encoders import encode_7or8bit
|
||||
from email.MIMENonMultipart import MIMENonMultipart
|
||||
from email.Encoders import encode_7or8bit
|
||||
|
||||
|
||||
|
||||
class MIMEText(MIMEBase.MIMEBase):
|
||||
class MIMEText(MIMENonMultipart):
|
||||
"""Class for generating text/* type MIME documents."""
|
||||
|
||||
def __init__(self, _text, _subtype='plain', _charset='us-ascii',
|
||||
@ -33,8 +33,8 @@ class MIMEText(MIMEBase.MIMEBase):
|
||||
override any header settings indicated by _charset. This is probably
|
||||
not what you want.
|
||||
"""
|
||||
MIMEBase.MIMEBase.__init__(self, 'text', _subtype,
|
||||
**{'charset': _charset})
|
||||
MIMENonMultipart.__init__(self, 'text', _subtype,
|
||||
**{'charset': _charset})
|
||||
if _text and _text[-1] <> '\n':
|
||||
_text += '\n'
|
||||
self.set_payload(_text, _charset)
|
||||
|
Loading…
Reference in New Issue
Block a user