launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #18127
[Merge] lp:~cjwatson/launchpad/modern-email-naming into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/modern-email-naming into lp:launchpad.
Commit message:
Use the modern names for email subpackages, introduced in Python 2.5.
Requested reviews:
Colin Watson (cjwatson)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/modern-email-naming/+merge/252941
Use the modern names for email subpackages, introduced in Python 2.5.
We can also drop the exception for email.Utils.mktime_tz from importfascist, since this was fixed properly upstream in Python 2.6.
--
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/answers/model/question.py'
--- lib/lp/answers/model/question.py 2015-01-28 16:18:11 +0000
+++ lib/lp/answers/model/question.py 2015-03-13 19:16:21 +0000
@@ -14,7 +14,7 @@
]
from datetime import datetime
-from email.Utils import make_msgid
+from email.utils import make_msgid
import operator
from lazr.enum import (
=== modified file 'lib/lp/answers/tests/emailinterface.txt'
--- lib/lp/answers/tests/emailinterface.txt 2012-01-24 12:36:15 +0000
+++ lib/lp/answers/tests/emailinterface.txt 2015-03-13 19:16:21 +0000
@@ -30,7 +30,7 @@
# Define a helper function to send email to the Answer Tracker handler.
>>> from lp.answers.mail.handler import AnswerTrackerHandler
- >>> from email.Utils import formatdate, make_msgid, mktime_tz
+ >>> from email.utils import formatdate, make_msgid, mktime_tz
>>> from lp.services.mail.signedmessage import signed_message_from_string
>>> handler = AnswerTrackerHandler()
>>> def send_question_email(question_id, from_addr, subject, body):
=== modified file 'lib/lp/app/browser/tales.py'
--- lib/lp/app/browser/tales.py 2014-11-27 05:01:51 +0000
+++ lib/lp/app/browser/tales.py 2015-03-13 19:16:21 +0000
@@ -10,7 +10,7 @@
datetime,
timedelta,
)
-from email.Utils import formatdate
+from email.utils import formatdate
import math
import os.path
import rfc822
=== modified file 'lib/lp/archiveuploader/utils.py'
--- lib/lp/archiveuploader/utils.py 2013-06-26 06:57:30 +0000
+++ lib/lp/archiveuploader/utils.py 2015-03-13 19:16:21 +0000
@@ -31,7 +31,7 @@
from collections import defaultdict
-import email.Header
+import email.header
import os
import re
import signal
@@ -189,10 +189,10 @@
try:
s.decode('utf8')
#encodings.utf_8.Codec().decode(s)
- h = email.Header.Header(s, 'utf-8', 998)
+ h = email.header.Header(s, 'utf-8', 998)
return str(h)
except UnicodeError:
- h = email.Header.Header(s, 'iso-8859-1', 998)
+ h = email.header.Header(s, 'iso-8859-1', 998)
return str(h)
=== modified file 'lib/lp/blueprints/model/specificationmessage.py'
--- lib/lp/blueprints/model/specificationmessage.py 2011-12-30 06:14:56 +0000
+++ lib/lp/blueprints/model/specificationmessage.py 2015-03-13 19:16:21 +0000
@@ -7,7 +7,7 @@
'SpecificationMessageSet'
]
-from email.Utils import make_msgid
+from email.utils import make_msgid
from sqlobject import (
BoolCol,
=== modified file 'lib/lp/bugs/browser/bug.py'
--- lib/lp/bugs/browser/bug.py 2014-12-06 00:16:55 +0000
+++ lib/lp/bugs/browser/bug.py 2015-03-13 19:16:21 +0000
@@ -25,8 +25,8 @@
'MaloneView',
]
-from email.MIMEMultipart import MIMEMultipart
-from email.MIMEText import MIMEText
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
import re
from lazr.enum import (
=== modified file 'lib/lp/bugs/doc/bugnotification-email.txt'
--- lib/lp/bugs/doc/bugnotification-email.txt 2015-01-27 23:42:39 +0000
+++ lib/lp/bugs/doc/bugnotification-email.txt 2015-03-13 19:16:21 +0000
@@ -533,8 +533,8 @@
X-Launchpad-Bug-Reporter: Sample Person (name12)
X-Launchpad-Bug-Modifier: Ford Prefect (person-name...)
-The build() method of a builder accepts a number of parameters and
-returns an instance of email.MIMEText. The most basic invocation of this
+The build() method of a builder accepts a number of parameters and returns
+an instance of email.mime.text.MIMEText. The most basic invocation of this
method requires a from address, a to address, a body, a subject and a
sending date for the mail.
=== modified file 'lib/lp/bugs/doc/externalbugtracker-debbugs.txt'
--- lib/lp/bugs/doc/externalbugtracker-debbugs.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/bugs/doc/externalbugtracker-debbugs.txt 2015-03-13 19:16:21 +0000
@@ -526,11 +526,11 @@
(at 220301) by example.com; 30 May 2008 21:18:12 +0000
DebBugs has a method, _getDateForComment(), which returns the correct
-date for a given email.Message.Message instance. This can be
+date for a given email.message.Message instance. This can be
demonstrated by instantiating Message with some test data and passing
the instance to _getDateForComment()
- >>> test_message = email.Message.Message()
+ >>> test_message = email.message.Message()
If the message has no Date or useful Received headers,
_getDateForComment() will return None.
=== modified file 'lib/lp/bugs/doc/externalbugtracker-emailaddress.txt'
--- lib/lp/bugs/doc/externalbugtracker-emailaddress.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/bugs/doc/externalbugtracker-emailaddress.txt 2015-03-13 19:16:21 +0000
@@ -88,7 +88,7 @@
By contrast, if the message ID is known it is recorded in the remotebug
field.
- >>> from email.Utils import make_msgid
+ >>> from email.utils import make_msgid
>>> message_id = make_msgid('launchpad')
>>> bug_watch = example_bug.addWatch(bugtracker=email_tracker,
... remotebug=message_id,
=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py 2012-11-19 04:53:35 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2015-03-13 19:16:21 +0000
@@ -11,7 +11,7 @@
'needs_authentication',
]
-from email.Utils import parseaddr
+from email.utils import parseaddr
from httplib import BadStatusLine
import re
import string
=== modified file 'lib/lp/bugs/externalbugtracker/debbugs.py'
--- lib/lp/bugs/externalbugtracker/debbugs.py 2012-03-27 13:41:38 +0000
+++ lib/lp/bugs/externalbugtracker/debbugs.py 2015-03-13 19:16:21 +0000
@@ -11,7 +11,7 @@
from datetime import datetime
import email
-from email.Utils import (
+from email.utils import (
mktime_tz,
parseaddr,
parsedate_tz,
@@ -279,7 +279,7 @@
def _getDateForComment(self, parsed_comment):
"""Return the correct date for a comment.
- :param parsed_comment: An `email.Message.Message` instance
+ :param parsed_comment: An `email.message.Message` instance
containing a parsed DebBugs comment.
:return: The correct date to use for the comment contained in
`parsed_comment`. If a date is specified in a Received
=== modified file 'lib/lp/bugs/externalbugtracker/trac.py'
--- lib/lp/bugs/externalbugtracker/trac.py 2013-02-11 03:32:00 +0000
+++ lib/lp/bugs/externalbugtracker/trac.py 2015-03-13 19:16:21 +0000
@@ -10,7 +10,7 @@
from cookielib import CookieJar
import csv
from datetime import datetime
-from email.Utils import parseaddr
+from email.utils import parseaddr
import time
import urllib2
import xmlrpclib
=== modified file 'lib/lp/bugs/mail/bugnotificationbuilder.py'
--- lib/lp/bugs/mail/bugnotificationbuilder.py 2015-01-27 23:42:39 +0000
+++ lib/lp/bugs/mail/bugnotificationbuilder.py 2015-03-13 19:16:21 +0000
@@ -11,8 +11,8 @@
'get_bugmail_from_address',
]
-from email.MIMEText import MIMEText
-from email.Utils import formatdate
+from email.mime.text import MIMEText
+from email.utils import formatdate
import rfc822
from zope.component import getUtility
@@ -172,7 +172,7 @@
:param references: A value for the References header.
:param message_id: A value for the Message-ID header.
- :return: An `email.MIMEText.MIMEText` object.
+ :return: An `email.mime.text.MIMEText` object.
"""
message = MIMEText(body.encode('utf8'), 'plain', 'utf8')
message['Date'] = format_rfc2822_date(email_date)
=== modified file 'lib/lp/bugs/model/bug.py'
--- lib/lp/bugs/model/bug.py 2015-02-16 13:01:34 +0000
+++ lib/lp/bugs/model/bug.py 2015-03-13 19:16:21 +0000
@@ -20,7 +20,7 @@
from cStringIO import StringIO
-from email.Utils import make_msgid
+from email.utils import make_msgid
from functools import wraps
from itertools import chain
import operator
=== modified file 'lib/lp/bugs/model/bugmessage.py'
--- lib/lp/bugs/model/bugmessage.py 2013-01-07 02:40:55 +0000
+++ lib/lp/bugs/model/bugmessage.py 2015-03-13 19:16:21 +0000
@@ -4,7 +4,7 @@
__metaclass__ = type
__all__ = ['BugMessage', 'BugMessageSet']
-from email.Utils import make_msgid
+from email.utils import make_msgid
from sqlobject import (
ForeignKey,
=== modified file 'lib/lp/bugs/tests/bugs-emailinterface.txt'
--- lib/lp/bugs/tests/bugs-emailinterface.txt 2012-12-10 13:43:47 +0000
+++ lib/lp/bugs/tests/bugs-emailinterface.txt 2015-03-13 19:16:21 +0000
@@ -52,10 +52,10 @@
>>> from lp.testing import sampledata
- >>> import email.Message
- >>> class MockSignedMessage(email.Message.Message):
+ >>> import email.message
+ >>> class MockSignedMessage(email.message.Message):
... def __init__(self, *args, **kws):
- ... email.Message.Message.__init__(self, *args, **kws)
+ ... email.message.Message.__init__(self, *args, **kws)
... self.signature = 'fake'
... @property
... def signedMessage(self):
@@ -449,7 +449,7 @@
The same will happen if we send the same email without signing it:
- >>> class MockUnsignedMessage(email.Message.Message):
+ >>> class MockUnsignedMessage(email.message.Message):
... signedMessage = None
... signature = None
>>> msg = email.message_from_string(
@@ -1803,8 +1803,8 @@
>>> from lp.services.mail.signedmessage import signed_message_from_string
>>> msg = signed_message_from_string(submit_mail)
- >>> import email.Utils
- >>> msg['Message-Id'] = email.Utils.make_msgid()
+ >>> import email.utils
+ >>> msg['Message-Id'] = email.utils.make_msgid()
>>> handler.process(
... msg, msg['To'],
... )
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2015-02-25 11:21:43 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2015-03-13 19:16:21 +0000
@@ -10,7 +10,7 @@
'is_valid_transition',
]
-from email.Utils import make_msgid
+from email.utils import make_msgid
from sqlobject import (
ForeignKey,
=== modified file 'lib/lp/code/model/revision.py'
--- lib/lp/code/model/revision.py 2015-01-29 16:28:30 +0000
+++ lib/lp/code/model/revision.py 2015-03-13 19:16:21 +0000
@@ -196,7 +196,7 @@
"""
if '@' not in self.name:
return self.name
- return email.Utils.parseaddr(self.name)[0]
+ return email.utils.parseaddr(self.name)[0]
email = StringCol(notNull=False, default=None)
person = ForeignKey(dbName='person', foreignKey='Person', notNull=False,
@@ -254,7 +254,7 @@
def _createRevisionAuthor(self, revision_author):
"""Extract out the email and check to see if it matches a Person."""
- email_address = email.Utils.parseaddr(revision_author)[1]
+ email_address = email.utils.parseaddr(revision_author)[1]
# If there is no @, then it isn't a real email address.
if '@' not in email_address:
email_address = None
=== modified file 'lib/lp/registry/doc/standing.txt'
--- lib/lp/registry/doc/standing.txt 2012-06-29 14:33:47 +0000
+++ lib/lp/registry/doc/standing.txt 2015-03-13 19:16:21 +0000
@@ -30,7 +30,7 @@
# A helper for posting messages to a list.
>>> from lp.services.messages.interfaces.message import IMessageSet
- >>> from email.Utils import formatdate
+ >>> from email.utils import formatdate
>>> from lp.registry.interfaces.mailinglist import IMailingListSet
>>> def post_message(from_address, to_team_name):
... message = getUtility(IMessageSet).fromEmail("""\
=== modified file 'lib/lp/registry/mail/notification.py'
--- lib/lp/registry/mail/notification.py 2015-02-26 02:36:22 +0000
+++ lib/lp/registry/mail/notification.py 2015-03-13 19:16:21 +0000
@@ -5,9 +5,9 @@
__metaclass__ = type
-from email.Header import Header
-from email.MIMEText import MIMEText
-from email.Utils import (
+from email.header import Header
+from email.mime.text import MIMEText
+from email.utils import (
formataddr,
make_msgid,
)
@@ -320,7 +320,7 @@
:param value: The raw email header value.
:type value: unicode
:return: The encoded header.
- :rtype: `email.Header.Header`
+ :rtype: `email.header.Header`
"""
try:
value.encode('us-ascii')
@@ -343,7 +343,7 @@
:param body: The message body.
:type body: unicode
:return: The sent message.
- :rtype: `email.Message.Message`
+ :rtype: `email.message.Message`
"""
# Craft the email message. Start by checking whether the subject and
# message bodies are ASCII or not.
=== modified file 'lib/lp/registry/model/distroseriesdifferencecomment.py'
--- lib/lp/registry/model/distroseriesdifferencecomment.py 2013-06-20 05:50:00 +0000
+++ lib/lp/registry/model/distroseriesdifferencecomment.py 2015-03-13 19:16:21 +0000
@@ -9,7 +9,7 @@
'DistroSeriesDifferenceComment',
]
-from email.Utils import make_msgid
+from email.utils import make_msgid
from storm.locals import (
Desc,
=== modified file 'lib/lp/registry/scripts/mlistimport.py'
--- lib/lp/registry/scripts/mlistimport.py 2012-06-29 08:40:05 +0000
+++ lib/lp/registry/scripts/mlistimport.py 2015-03-13 19:16:21 +0000
@@ -9,7 +9,7 @@
]
-from email.Utils import parseaddr
+from email.utils import parseaddr
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
@@ -97,7 +97,7 @@
The named file has email address to import, one per line. The lines
may be formatted using any format recognized by
- `email.Utils.parseaddr()`.
+ `email.utils.parseaddr()`.
:param filename: The name of the file containing email address.
:type filename: string
=== modified file 'lib/lp/scripts/utilities/importfascist.py'
--- lib/lp/scripts/utilities/importfascist.py 2013-11-15 06:36:55 +0000
+++ lib/lp/scripts/utilities/importfascist.py 2015-03-13 19:16:21 +0000
@@ -27,7 +27,6 @@
valid_imports_not_in_all = {
'bzrlib.lsprof': set(['BzrProfiler']),
'cookielib': set(['domain_match']),
- 'email.Utils': set(['mktime_tz']),
'openid.fetchers': set(['Urllib2Fetcher']),
'storm.database': set(['STATE_DISCONNECTED']),
'textwrap': set(['dedent']),
=== modified file 'lib/lp/services/mail/doc/emailauthentication.txt'
--- lib/lp/services/mail/doc/emailauthentication.txt 2012-01-20 16:11:11 +0000
+++ lib/lp/services/mail/doc/emailauthentication.txt 2015-03-13 19:16:21 +0000
@@ -43,7 +43,7 @@
>>> from lp.services.webapp.interfaces import ILaunchBag
>>> from lp.registry.interfaces.person import IPersonSet
>>> launchbag = getUtility(ILaunchBag)
- >>> name, addr = email.Utils.parseaddr(msg['From'])
+ >>> name, addr = email.utils.parseaddr(msg['From'])
>>> from_user = getUtility(IPersonSet).getByEmail(addr)
>>> launchbag.user == from_user
True
@@ -57,7 +57,7 @@
>>> principal = authenticateEmail(msg, accept_any_timestamp)
>>> principal is not None
True
- >>> name, addr = email.Utils.parseaddr(msg['From'])
+ >>> name, addr = email.utils.parseaddr(msg['From'])
>>> from_user = getUtility(IPersonSet).getByEmail(addr)
>>> launchbag.user == from_user
True
@@ -70,7 +70,7 @@
>>> principal = authenticateEmail(msg, accept_any_timestamp)
>>> principal is not None
True
- >>> name, addr = email.Utils.parseaddr(msg['From'])
+ >>> name, addr = email.utils.parseaddr(msg['From'])
>>> from_user = getUtility(IPersonSet).getByEmail(addr)
>>> launchbag.user == from_user
True
@@ -85,7 +85,7 @@
>>> principal = authenticateEmail(msg, accept_any_timestamp)
>>> principal is not None
True
- >>> name, addr = email.Utils.parseaddr(msg['From'])
+ >>> name, addr = email.utils.parseaddr(msg['From'])
>>> from_user = getUtility(IPersonSet).getByEmail(addr)
>>> launchbag.user == from_user
True
@@ -96,7 +96,7 @@
InvalidSignature will be raised:
>>> msg = read_test_message('signed_detached_invalid_signature.txt')
- >>> name, addr = email.Utils.parseaddr(msg['From'])
+ >>> name, addr = email.utils.parseaddr(msg['From'])
>>> from_user = getUtility(IPersonSet).getByEmail(addr)
>>> principal = authenticateEmail(msg, accept_any_timestamp)
Traceback (most recent call last):
=== modified file 'lib/lp/services/mail/doc/sending-mail.txt'
--- lib/lp/services/mail/doc/sending-mail.txt 2012-04-16 15:26:38 +0000
+++ lib/lp/services/mail/doc/sending-mail.txt 2015-03-13 19:16:21 +0000
@@ -129,7 +129,7 @@
>>> from_addr, to_addr, raw_message = stub.test_emails.pop()
>>> msg = email.message_from_string(raw_message)
- >>> from email.Header import decode_header
+ >>> from email.header import decode_header
>>> subject_str, charset = decode_header(msg['Subject'])[0]
>>> subject_str.decode(charset)
u'\xc4mnesrad'
@@ -153,7 +153,7 @@
>>> from_addr, to_addr, raw_message = stub.test_emails.pop()
>>> msg = email.message_from_string(raw_message)
- >>> from email.Utils import parseaddr
+ >>> from email.utils import parseaddr
>>> from_name_encoded, from_addr = parseaddr(msg['From'])
>>> from_name_str, charset = decode_header(from_name_encoded)[0]
>>> from_addr
@@ -265,7 +265,7 @@
Let's send a mail using that function. We only create a simple message
to test with, though.
- >>> msg = email.MIMEText.MIMEText("Some content")
+ >>> msg = email.mime.text.MIMEText("Some content")
>>> msg['From'] = 'foo.bar@xxxxxxxxxxxxx'
>>> msg['To'] = 'test@xxxxxxxxxxxxx'
>>> msg['Subject'] = "test"
@@ -304,7 +304,7 @@
the mail should be sent to. When we do this, the 'To' and 'CC' headers
are ignored.
- >>> msg = email.MIMEText.MIMEText("Some content")
+ >>> msg = email.mime.text.MIMEText("Some content")
>>> msg['From'] = 'foo.bar@xxxxxxxxxxxxx'
>>> msg['To'] = 'test@xxxxxxxxxxxxx'
>>> msg['CC'] = 'foo.bar@xxxxxxxxxxxxx'
=== modified file 'lib/lp/services/mail/doc/signedmessage.txt'
--- lib/lp/services/mail/doc/signedmessage.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/services/mail/doc/signedmessage.txt 2015-03-13 19:16:21 +0000
@@ -1,4 +1,4 @@
-SignedMessage extends email.Message.Message in order to provide easy
+SignedMessage extends email.message.Message in order to provide easy
access to signed content and the signature of messages.
You can create it from a string using signed_message_from_string. It
@@ -37,7 +37,7 @@
<BLANKLINE>
With multiple paragraphs.
-And to make it easier to work with, it's available as an email.Message
+And to make it easier to work with, it's available as an email.message
object as well:
>>> signed_msg = msg.signedMessage
=== modified file 'lib/lp/services/mail/incoming.py'
--- lib/lp/services/mail/incoming.py 2013-12-05 03:08:44 +0000
+++ lib/lp/services/mail/incoming.py 2015-03-13 19:16:21 +0000
@@ -412,11 +412,11 @@
continue
try:
mail = signed_message_from_string(raw_mail)
- except email.Errors.MessageError:
+ except email.errors.MessageError:
# If we can't parse the message, we can't send a reply back to
# the user, but logging an exception will let us investigate.
log.exception(
- "Couldn't convert email to email.Message: %s" % (
+ "Couldn't convert email to email.message: %s" % (
file_alias_url, ))
mailbox.delete(mail_id)
continue
=== modified file 'lib/lp/services/mail/interfaces.py'
--- lib/lp/services/mail/interfaces.py 2013-01-07 02:40:55 +0000
+++ lib/lp/services/mail/interfaces.py 2015-03-13 19:16:21 +0000
@@ -49,7 +49,7 @@
"""Returns the message header with the given name."""
signedMessage = Attribute("The part that was signed, represented "
- "as an email.Message.")
+ "as an email.message.Message.")
signedContent = ASCII(title=_("Signed Content"),
description=_("The text that was signed."))
=== modified file 'lib/lp/services/mail/mbox.py'
--- lib/lp/services/mail/mbox.py 2013-04-09 08:22:58 +0000
+++ lib/lp/services/mail/mbox.py 2015-03-13 19:16:21 +0000
@@ -8,7 +8,7 @@
import email
-from email.Utils import make_msgid
+from email.utils import make_msgid
from logging import getLogger
from zope.component import getUtility
=== modified file 'lib/lp/services/mail/notification.py'
--- lib/lp/services/mail/notification.py 2012-01-01 02:58:52 +0000
+++ lib/lp/services/mail/notification.py 2015-03-13 19:16:21 +0000
@@ -11,9 +11,9 @@
from difflib import unified_diff
from email import message_from_string
-from email.MIMEMessage import MIMEMessage
-from email.MIMEMultipart import MIMEMultipart
-from email.MIMEText import MIMEText
+from email.mime.message import MIMEMessage
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
import re
from lp.bugs.mail.bugnotificationbuilder import get_bugmail_error_address
=== modified file 'lib/lp/services/mail/sendmail.py'
--- lib/lp/services/mail/sendmail.py 2013-04-09 08:22:58 +0000
+++ lib/lp/services/mail/sendmail.py 2015-03-13 19:16:21 +0000
@@ -29,13 +29,13 @@
from binascii import b2a_qp
-from email import Charset
-from email.Encoders import encode_base64
-from email.Header import Header
-from email.Message import Message
-from email.MIMEMultipart import MIMEMultipart
-from email.MIMEText import MIMEText
-from email.Utils import (
+from email import charset
+from email.encoders import encode_base64
+from email.header import Header
+from email.message import Message
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+from email.utils import (
formataddr,
formatdate,
getaddresses,
@@ -62,9 +62,9 @@
# email package by default ends up encoding UTF-8 messages using base64,
# which sucks as they look like spam to stupid spam filters. We define
# our own custom charset definition to force quoted printable.
-del Charset.CHARSETS['utf-8']
-Charset.add_charset('utf-8', Charset.SHORTEST, Charset.QP, 'utf-8')
-Charset.add_alias('utf8', 'utf-8')
+del charset.CHARSETS['utf-8']
+charset.add_charset('utf-8', charset.SHORTEST, charset.QP, 'utf-8')
+charset.add_alias('utf8', 'utf-8')
def do_paranoid_email_content_validation(from_addr, to_addrs, subject, body):
@@ -356,7 +356,7 @@
def validate_message(message):
"""Validate that the supplied message is suitable for sending."""
- assert isinstance(message, Message), "Not an email.Message.Message"
+ assert isinstance(message, Message), "Not an email.message.Message"
assert 'to' in message and bool(message['to']), "No To: header"
assert 'from' in message and bool(message['from']), "No From: header"
assert 'subject' in message and bool(message['subject']), (
@@ -364,7 +364,7 @@
def sendmail(message, to_addrs=None, bulk=True):
- """Send an email.Message.Message
+ """Send an email.message.Message
If you just need to send dumb ASCII or Unicode, simple_sendmail
will be easier for you. Sending attachments or multipart messages
=== modified file 'lib/lp/services/mail/signedmessage.py'
--- lib/lp/services/mail/signedmessage.py 2012-04-13 07:07:43 +0000
+++ lib/lp/services/mail/signedmessage.py 2015-03-13 19:16:21 +0000
@@ -46,7 +46,7 @@
return msg
-class SignedMessage(email.Message.Message):
+class SignedMessage(email.message.Message):
"""Provides easy access to signed content and the signature"""
implements(ISignedMessage)
=== modified file 'lib/lp/services/mail/tests/test_sendmail.py'
--- lib/lp/services/mail/tests/test_sendmail.py 2014-08-29 02:03:52 +0000
+++ lib/lp/services/mail/tests/test_sendmail.py 2015-03-13 19:16:21 +0000
@@ -5,7 +5,7 @@
from doctest import DocTestSuite
import email.header
-from email.Message import Message
+from email.message import Message
import unittest
from zope.interface import implements
@@ -275,7 +275,7 @@
self.checkTimelineHasOneMailAction(ctl.timeline, subject=subject)
def test_sendmail_with_email_header(self):
- """Check the timeline is ok even if there is an email.Header.
+ """Check the timeline is ok even if there is an email.header.Header.
See https://bugs.launchpad.net/launchpad/+bug/885972
"""
=== modified file 'lib/lp/services/mail/tests/test_signedmessage.py'
--- lib/lp/services/mail/tests/test_signedmessage.py 2012-01-01 02:58:52 +0000
+++ lib/lp/services/mail/tests/test_signedmessage.py 2015-03-13 19:16:21 +0000
@@ -5,10 +5,10 @@
__metaclass__ = type
-from email.Message import Message
-from email.MIMEMultipart import MIMEMultipart
-from email.MIMEText import MIMEText
-from email.Utils import (
+from email.message import Message
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+from email.utils import (
formatdate,
make_msgid,
)
=== modified file 'lib/lp/services/mail/tests/test_stub.py'
--- lib/lp/services/mail/tests/test_stub.py 2012-07-02 20:07:44 +0000
+++ lib/lp/services/mail/tests/test_stub.py 2015-03-13 19:16:21 +0000
@@ -16,7 +16,7 @@
Send an email (faked by TestMailer - no actual email is sent)
>>> import email
- >>> from email.MIMEText import MIMEText
+ >>> from email.mime.text import MIMEText
>>> import transaction
>>> from lp.services.mail import stub
>>> from lp.services.mail.sendmail import simple_sendmail
=== modified file 'lib/lp/services/mailman/monkeypatches/lpmoderate.py'
--- lib/lp/services/mailman/monkeypatches/lpmoderate.py 2011-12-19 23:38:16 +0000
+++ lib/lp/services/mailman/monkeypatches/lpmoderate.py 2015-03-13 19:16:21 +0000
@@ -5,7 +5,7 @@
"""
from email.iterators import typed_subpart_iterator
-from email.Utils import (
+from email.utils import (
formatdate,
make_msgid,
)
=== modified file 'lib/lp/services/messages/interfaces/message.py'
--- lib/lp/services/messages/interfaces/message.py 2015-01-30 18:24:07 +0000
+++ lib/lp/services/messages/interfaces/message.py 2015-03-13 19:16:21 +0000
@@ -145,7 +145,7 @@
a UnknownSender error if they cannot be found.
:param filealias: The `LibraryFileAlias` of the raw email if it has
already been uploaded to the Librarian.
- :param parsed_message: An email.Message.Message instance. If given,
+ :param parsed_message: An email.message.Message instance. If given,
it is used internally instead of building one from the raw
email_message. This is purely an optimization step, significant
in many places because the emails we are handling may contain huge
@@ -283,7 +283,7 @@
"""Record that the message was sent.
:param message: The email message that was sent.
- :type message: `email.Message.Message`
+ :type message: `email.message.Message`
"""
=== modified file 'lib/lp/services/messages/model/message.py'
--- lib/lp/services/messages/model/message.py 2013-08-12 03:12:44 +0000
+++ lib/lp/services/messages/model/message.py 2015-03-13 19:16:21 +0000
@@ -13,11 +13,11 @@
from cStringIO import StringIO as cStringIO
from datetime import datetime
import email
-from email.Header import (
+from email.header import (
decode_header,
make_header,
)
-from email.Utils import (
+from email.utils import (
make_msgid,
mktime_tz,
parseaddr,
@@ -250,7 +250,7 @@
# Unfold the header before decoding it.
header = ''.join(header.splitlines())
- bits = email.Header.decode_header(header)
+ bits = email.header.decode_header(header)
# Re-encode the header parts using utf-8, replacing undecodable
# characters with question marks.
re_encoded_bits = []
@@ -260,7 +260,7 @@
# 2008-09-26 gary:
# The RFC 2047 encoding names and the Python encoding names are
# not always the same. A safer and more correct approach would use
- # bytes.decode(email.Charset.Charset(charset).input_codec,
+ # bytes.decode(email.charset.Charset(charset).input_codec,
# 'replace')
# or similar, rather than
# bytes.decode(charset, 'replace')
@@ -270,7 +270,7 @@
re_encoded_bits.append(
(self.decode(bytes, charset).encode('utf-8'), 'utf-8'))
- return unicode(email.Header.make_header(re_encoded_bits))
+ return unicode(email.header.make_header(re_encoded_bits))
def fromEmail(self, email_message, owner=None, filealias=None,
parsed_message=None, create_missing_persons=False,
@@ -284,7 +284,7 @@
'email_message must be a normal string. Got: %r'
% email_message)
- # Parse the raw message into an email.Message.Message instance,
+ # Parse the raw message into an email.message.Message instance,
# if we haven't been given one already.
if parsed_message is None:
parsed_message = email.message_from_string(email_message)
=== modified file 'lib/lp/soyuz/adapters/notification.py'
--- lib/lp/soyuz/adapters/notification.py 2014-11-08 23:53:17 +0000
+++ lib/lp/soyuz/adapters/notification.py 2015-03-13 19:16:21 +0000
@@ -587,7 +587,7 @@
def person_to_email(person):
"""Return a string of full name <e-mail address> given an IPerson."""
if person and person.preferredemail:
- # This will use email.Header to encode any non-ASCII characters.
+ # This will use email.header to encode any non-ASCII characters.
return format_address_for_person(person)
=== modified file 'lib/lp/testing/mail.py'
--- lib/lp/testing/mail.py 2011-08-12 14:36:25 +0000
+++ lib/lp/testing/mail.py 2015-03-13 19:16:21 +0000
@@ -5,7 +5,7 @@
__metaclass__ = type
-from email.Utils import formatdate
+from email.utils import formatdate
import os
from zope.component import getUtility
=== modified file 'lib/lp/translations/utilities/gettext_po_parser.py'
--- lib/lp/translations/utilities/gettext_po_parser.py 2014-06-10 11:25:51 +0000
+++ lib/lp/translations/utilities/gettext_po_parser.py 2015-03-13 19:16:21 +0000
@@ -15,7 +15,7 @@
import codecs
import datetime
-from email.Utils import parseaddr
+from email.utils import parseaddr
import logging
import re
=== modified file 'lib/lp/translations/utilities/xpi_header.py'
--- lib/lp/translations/utilities/xpi_header.py 2012-06-29 08:40:05 +0000
+++ lib/lp/translations/utilities/xpi_header.py 2015-03-13 19:16:21 +0000
@@ -11,7 +11,7 @@
import xml.etree.cElementTree as cElementTree
except ImportError:
import cElementTree
-from email.Utils import parseaddr
+from email.utils import parseaddr
from StringIO import StringIO
from zope.interface import implements
=== modified file 'scripts/script-monitor.py'
--- scripts/script-monitor.py 2011-12-30 06:47:17 +0000
+++ scripts/script-monitor.py 2015-03-13 19:16:21 +0000
@@ -14,7 +14,7 @@
datetime,
timedelta,
)
-from email.MIMEText import MIMEText
+from email.mime.text import MIMEText
from optparse import OptionParser
import smtplib
import sys
References