mirror of
https://github.com/python/cpython.git
synced 2025-07-29 14:15:07 +00:00
parent
dd7b0525e9
commit
5a096e1b10
6 changed files with 28 additions and 28 deletions
|
@ -778,7 +778,7 @@ class SMTPHandler(logging.Handler):
|
|||
try:
|
||||
import smtplib
|
||||
try:
|
||||
from email.Utils import formatdate
|
||||
from email.utils import formatdate
|
||||
except ImportError:
|
||||
formatdate = self.date_time
|
||||
port = self.mailport
|
||||
|
|
|
@ -16,8 +16,8 @@ import socket
|
|||
import errno
|
||||
import copy
|
||||
import email
|
||||
import email.Message
|
||||
import email.Generator
|
||||
import email.message
|
||||
import email.generator
|
||||
import rfc822
|
||||
import StringIO
|
||||
try:
|
||||
|
@ -196,9 +196,9 @@ class Mailbox:
|
|||
# To get native line endings on disk, the user-friendly \n line endings
|
||||
# used in strings and by email.Message are translated here.
|
||||
"""Dump message contents to target file."""
|
||||
if isinstance(message, email.Message.Message):
|
||||
if isinstance(message, email.message.Message):
|
||||
buffer = StringIO.StringIO()
|
||||
gen = email.Generator.Generator(buffer, mangle_from_, 0)
|
||||
gen = email.generator.Generator(buffer, mangle_from_, 0)
|
||||
gen.flatten(message)
|
||||
buffer.seek(0)
|
||||
target.write(buffer.read().replace('\n', os.linesep))
|
||||
|
@ -707,7 +707,7 @@ class _mboxMMDF(_singlefileMailbox):
|
|||
message = ''
|
||||
elif isinstance(message, _mboxMMDFMessage):
|
||||
from_line = 'From ' + message.get_from()
|
||||
elif isinstance(message, email.Message.Message):
|
||||
elif isinstance(message, email.message.Message):
|
||||
from_line = message.get_unixfrom() # May be None.
|
||||
if from_line is None:
|
||||
from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
|
||||
|
@ -1257,9 +1257,9 @@ class Babyl(_singlefileMailbox):
|
|||
self._file.write(os.linesep)
|
||||
else:
|
||||
self._file.write('1,,' + os.linesep)
|
||||
if isinstance(message, email.Message.Message):
|
||||
if isinstance(message, email.message.Message):
|
||||
orig_buffer = StringIO.StringIO()
|
||||
orig_generator = email.Generator.Generator(orig_buffer, False, 0)
|
||||
orig_generator = email.generator.Generator(orig_buffer, False, 0)
|
||||
orig_generator.flatten(message)
|
||||
orig_buffer.seek(0)
|
||||
while True:
|
||||
|
@ -1270,7 +1270,7 @@ class Babyl(_singlefileMailbox):
|
|||
self._file.write('*** EOOH ***' + os.linesep)
|
||||
if isinstance(message, BabylMessage):
|
||||
vis_buffer = StringIO.StringIO()
|
||||
vis_generator = email.Generator.Generator(vis_buffer, False, 0)
|
||||
vis_generator = email.generator.Generator(vis_buffer, False, 0)
|
||||
vis_generator.flatten(message.get_visible())
|
||||
while True:
|
||||
line = vis_buffer.readline()
|
||||
|
@ -1326,12 +1326,12 @@ class Babyl(_singlefileMailbox):
|
|||
return (start, stop)
|
||||
|
||||
|
||||
class Message(email.Message.Message):
|
||||
class Message(email.message.Message):
|
||||
"""Message with mailbox-format-specific properties."""
|
||||
|
||||
def __init__(self, message=None):
|
||||
"""Initialize a Message instance."""
|
||||
if isinstance(message, email.Message.Message):
|
||||
if isinstance(message, email.message.Message):
|
||||
self._become_message(copy.deepcopy(message))
|
||||
if isinstance(message, Message):
|
||||
message._explain_to(self)
|
||||
|
@ -1340,7 +1340,7 @@ class Message(email.Message.Message):
|
|||
elif hasattr(message, "read"):
|
||||
self._become_message(email.message_from_file(message))
|
||||
elif message is None:
|
||||
email.Message.Message.__init__(self)
|
||||
email.message.Message.__init__(self)
|
||||
else:
|
||||
raise TypeError('Invalid message type: %s' % type(message))
|
||||
|
||||
|
@ -1471,7 +1471,7 @@ class _mboxMMDFMessage(Message):
|
|||
def __init__(self, message=None):
|
||||
"""Initialize an mboxMMDFMessage instance."""
|
||||
self.set_from('MAILER-DAEMON', True)
|
||||
if isinstance(message, email.Message.Message):
|
||||
if isinstance(message, email.message.Message):
|
||||
unixfrom = message.get_unixfrom()
|
||||
if unixfrom is not None and unixfrom.startswith('From '):
|
||||
self.set_from(unixfrom[5:])
|
||||
|
|
|
@ -43,10 +43,10 @@ Example:
|
|||
|
||||
import socket
|
||||
import re
|
||||
import email.Utils
|
||||
import email.utils
|
||||
import base64
|
||||
import hmac
|
||||
from email.base64MIME import encode as encode_base64
|
||||
from email.base64mime import encode as encode_base64
|
||||
from sys import stderr
|
||||
|
||||
__all__ = ["SMTPException","SMTPServerDisconnected","SMTPResponseException",
|
||||
|
@ -172,7 +172,7 @@ def quoteaddr(addr):
|
|||
"""
|
||||
m = (None, None)
|
||||
try:
|
||||
m = email.Utils.parseaddr(addr)[1]
|
||||
m = email.utils.parseaddr(addr)[1]
|
||||
except AttributeError:
|
||||
pass
|
||||
if m == (None, None): # Indicates parse failure or AttributeError
|
||||
|
|
|
@ -4,7 +4,7 @@ import time
|
|||
import stat
|
||||
import socket
|
||||
import email
|
||||
import email.Message
|
||||
import email.message
|
||||
import rfc822
|
||||
import re
|
||||
import StringIO
|
||||
|
@ -22,7 +22,7 @@ class TestBase(unittest.TestCase):
|
|||
|
||||
def _check_sample(self, msg):
|
||||
# Inspect a mailbox.Message representation of the sample message
|
||||
self.assert_(isinstance(msg, email.Message.Message))
|
||||
self.assert_(isinstance(msg, email.message.Message))
|
||||
self.assert_(isinstance(msg, mailbox.Message))
|
||||
for key, value in _sample_headers.iteritems():
|
||||
self.assert_(value in msg.get_all(key))
|
||||
|
@ -30,7 +30,7 @@ class TestBase(unittest.TestCase):
|
|||
self.assert_(len(msg.get_payload()) == len(_sample_payloads))
|
||||
for i, payload in enumerate(_sample_payloads):
|
||||
part = msg.get_payload(i)
|
||||
self.assert_(isinstance(part, email.Message.Message))
|
||||
self.assert_(isinstance(part, email.message.Message))
|
||||
self.assert_(not isinstance(part, mailbox.Message))
|
||||
self.assert_(part.get_payload() == payload)
|
||||
|
||||
|
@ -946,7 +946,7 @@ class TestMessage(TestBase):
|
|||
self._delete_recursively(self._path)
|
||||
|
||||
def test_initialize_with_eMM(self):
|
||||
# Initialize based on email.Message.Message instance
|
||||
# Initialize based on email.message.Message instance
|
||||
eMM = email.message_from_string(_sample_message)
|
||||
msg = self._factory(eMM)
|
||||
self._post_initialize_hook(msg)
|
||||
|
@ -972,7 +972,7 @@ class TestMessage(TestBase):
|
|||
# Initialize without arguments
|
||||
msg = self._factory()
|
||||
self._post_initialize_hook(msg)
|
||||
self.assert_(isinstance(msg, email.Message.Message))
|
||||
self.assert_(isinstance(msg, email.message.Message))
|
||||
self.assert_(isinstance(msg, mailbox.Message))
|
||||
self.assert_(isinstance(msg, self._factory))
|
||||
self.assert_(msg.keys() == [])
|
||||
|
@ -999,7 +999,7 @@ class TestMessage(TestBase):
|
|||
mailbox.BabylMessage, mailbox.MMDFMessage):
|
||||
other_msg = class_()
|
||||
msg._explain_to(other_msg)
|
||||
other_msg = email.Message.Message()
|
||||
other_msg = email.message.Message()
|
||||
self.assertRaises(TypeError, lambda: msg._explain_to(other_msg))
|
||||
|
||||
def _post_initialize_hook(self, msg):
|
||||
|
@ -1739,11 +1739,11 @@ class MaildirTestCase(unittest.TestCase):
|
|||
|
||||
def test_unix_mbox(self):
|
||||
### should be better!
|
||||
import email.Parser
|
||||
import email.parser
|
||||
fname = self.createMessage("cur", True)
|
||||
n = 0
|
||||
for msg in mailbox.PortableUnixMailbox(open(fname),
|
||||
email.Parser.Parser().parse):
|
||||
email.parser.Parser().parse):
|
||||
n += 1
|
||||
self.assertEqual(msg["subject"], "Simple Test")
|
||||
self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
|
||||
|
|
|
@ -452,7 +452,7 @@ class URLopener:
|
|||
|
||||
def open_local_file(self, url):
|
||||
"""Use local file."""
|
||||
import mimetypes, mimetools, email.Utils
|
||||
import mimetypes, mimetools, email.utils
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
|
@ -464,7 +464,7 @@ class URLopener:
|
|||
except OSError, e:
|
||||
raise IOError(e.errno, e.strerror, e.filename)
|
||||
size = stats.st_size
|
||||
modified = email.Utils.formatdate(stats.st_mtime, usegmt=True)
|
||||
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
|
||||
mtype = mimetypes.guess_type(url)[0]
|
||||
headers = mimetools.Message(StringIO(
|
||||
'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
|
||||
|
|
|
@ -1209,14 +1209,14 @@ class FileHandler(BaseHandler):
|
|||
|
||||
# not entirely sure what the rules are here
|
||||
def open_local_file(self, req):
|
||||
import email.Utils
|
||||
import email.utils
|
||||
import mimetypes
|
||||
host = req.get_host()
|
||||
file = req.get_selector()
|
||||
localfile = url2pathname(file)
|
||||
stats = os.stat(localfile)
|
||||
size = stats.st_size
|
||||
modified = email.Utils.formatdate(stats.st_mtime, usegmt=True)
|
||||
modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
|
||||
mtype = mimetypes.guess_type(file)[0]
|
||||
headers = mimetools.Message(StringIO(
|
||||
'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue