From 44e43727be13e3554342c2b5b75b7dc42abdb18c Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sun, 30 Nov 2014 21:51:03 -0500 Subject: Checkpointing. By using `six` I think I have most of the imports squared away. There's probably still uses of `unicode` built-ins that need fixing. The idea is to first get the test suite running (which it doesn't yet), and then to fix tests. There's a bug in lazr.config which requires us to patch it for now. --- src/mailman/handlers/cook_headers.py | 4 ++-- src/mailman/handlers/decorate.py | 7 +++---- src/mailman/handlers/docs/subject-munging.rst | 16 ++++++---------- src/mailman/handlers/tests/test_recipients.py | 5 +++-- 4 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/handlers/cook_headers.py b/src/mailman/handlers/cook_headers.py index d5d096448..5fdfc238b 100644 --- a/src/mailman/handlers/cook_headers.py +++ b/src/mailman/handlers/cook_headers.py @@ -201,7 +201,7 @@ def prefix_subject(mlist, msg, msgdata): # range. It is safe to use unicode string when manupilating header # contents with re module. It would be best to return unicode in # ch_oneline() but here is temporary solution. - subject = unicode(subject, cset) + subject = subject.decode(cset) # If the subject_prefix contains '%d', it is replaced with the # mailing list sequential number. Sequential number format allows # '%d' or '%05d' like pattern. @@ -270,7 +270,7 @@ def ch_oneline(headerstr): else: cset = 'utf-8' h = make_header(d) - ustr = unicode(h) + ustr = h.decode('utf-8') oneline = ''.join(ustr.splitlines()) return oneline.encode(cset, 'replace'), cset except (LookupError, UnicodeError, ValueError, HeaderParseError): diff --git a/src/mailman/handlers/decorate.py b/src/mailman/handlers/decorate.py index bf8454232..03f0c009f 100644 --- a/src/mailman/handlers/decorate.py +++ b/src/mailman/handlers/decorate.py @@ -31,15 +31,14 @@ import re import logging from email.mime.text import MIMEText -from urllib2 import URLError -from zope.component import getUtility -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.email.message import Message from mailman.interfaces.handler import IHandler from mailman.interfaces.templates import ITemplateLoader from mailman.utilities.string import expand +from six.moves.urllib_error import URLError +from zope.component import getUtility +from zope.interface import implementer log = logging.getLogger('mailman.error') diff --git a/src/mailman/handlers/docs/subject-munging.rst b/src/mailman/handlers/docs/subject-munging.rst index 538ad99c7..072e80d17 100644 --- a/src/mailman/handlers/docs/subject-munging.rst +++ b/src/mailman/handlers/docs/subject-munging.rst @@ -124,7 +124,7 @@ set than the encoded header. >>> process(mlist, msg, {}) >>> print(msg['subject']) [XTest] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= - >>> unicode(msg['subject']) + >>> msg['subject'].decode('utf-8') u'[XTest] \u30e1\u30fc\u30eb\u30de\u30f3' @@ -180,7 +180,7 @@ in the subject prefix, and the subject is encoded non-ASCII. >>> process(mlist, msg, {}) >>> print(msg['subject']) [XTest 456] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= - >>> unicode(msg['subject']) + >>> msg['subject'].decode('utf-8') u'[XTest 456] \u30e1\u30fc\u30eb\u30de\u30f3' Even more fun is when the internationalized ``Subject`` header already has a @@ -194,10 +194,8 @@ prefix, possibly with a different posting number. >>> print(msg['subject']) [XTest 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= -.. - # XXX This requires Python email patch #1681333 to succeed. - # >>> unicode(msg['subject']) - # u'[XTest 456] Re: \u30e1\u30fc\u30eb\u30de\u30f3' + >>> msg['subject'].decode('utf-8') + u'[XTest 456] Re: \u30e1\u30fc\u30eb\u30de\u30f3' As before, old style subject prefixes are re-ordered. @@ -210,10 +208,8 @@ As before, old style subject prefixes are re-ordered. [XTest 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= -.. - # XXX This requires Python email patch #1681333 to succeed. - # >>> unicode(msg['subject']) - # u'[XTest 456] Re: \u30e1\u30fc\u30eb\u30de\u30f3' + >>> msg['subject'].decode('utf-8') + u'[XTest 456] Re: \u30e1\u30fc\u30eb\u30de\u30f3' In this test case, we get an extra space between the prefix and the original diff --git a/src/mailman/handlers/tests/test_recipients.py b/src/mailman/handlers/tests/test_recipients.py index afe533a7e..8f2a9d47d 100644 --- a/src/mailman/handlers/tests/test_recipients.py +++ b/src/mailman/handlers/tests/test_recipients.py @@ -26,15 +26,16 @@ __all__ = [ ] +import six import unittest -from zope.component import getUtility from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.member import DeliveryMode, DeliveryStatus, MemberRole from mailman.interfaces.usermanager import IUserManager from mailman.testing.helpers import specialized_message_from_string as mfs from mailman.testing.layers import ConfigLayer +from zope.component import getUtility @@ -218,4 +219,4 @@ site_owner: siteadmin@example.com finally: config.pop('test_site_admin_unicode') self.assertEqual(len(msgdata['recipients']), 1) - self.assertIsInstance(list(msgdata['recipients'])[0], unicode) + self.assertIsInstance(list(msgdata['recipients'])[0], six.text_type) -- cgit v1.2.3-70-g09d2 From d0c53890bf0c8aa531d45958f0e25fdaccbdb133 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 15 Dec 2014 11:12:13 -0500 Subject: * Read the .cfg files not as bytes any more, but as UTF-8 encoding files. * Revert LP: #1170347 to not .as_string() the message being added the mailbox, because Python 3.4 handles this properly by default. Fix up some lmtp code, though I don't thinkk it's quite right yet. Fix handler tests. --- src/mailman/config/config.py | 9 +++++---- src/mailman/core/switchboard.py | 2 +- src/mailman/handlers/tests/test_recipients.py | 27 +++++++++------------------ src/mailman/handlers/to_digest.py | 2 +- src/mailman/runners/lmtp.py | 10 +++++++--- src/mailman/runners/tests/test_owner.py | 2 +- 6 files changed, 24 insertions(+), 28 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py index c92485176..c6fe2041a 100644 --- a/src/mailman/config/config.py +++ b/src/mailman/config/config.py @@ -32,7 +32,7 @@ import sys from flufl.lock import Lock from lazr.config import ConfigSchema, as_boolean -from pkg_resources import resource_filename, resource_string +from pkg_resources import resource_filename, resource_string as resource_bytes from six.moves.configparser import ConfigParser, RawConfigParser from string import Template from unittest.mock import patch @@ -114,7 +114,7 @@ class Configuration: self._config = schema.load(config_file) if filename is not None: self.filename = filename - with open(filename) as user_config: + with open(filename, 'r', encoding='utf-8') as user_config: self.push(filename, user_config.read()) def push(self, config_name, config_string): @@ -286,9 +286,10 @@ def load_external(path, encoding=None): if path.startswith('python:'): resource_path = path[7:] package, dot, resource = resource_path.rpartition('.') - config_string = resource_string(package, resource + '.cfg') + raw = resource_bytes(package, resource + '.cfg') + config_string = raw.decode('utf-8') else: - with open(path, 'rb') as fp: + with open(path, 'r', encoding='utf-8') as fp: config_string = fp.read() if encoding is None: return config_string diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py index d635a12e9..3375aa1dd 100644 --- a/src/mailman/core/switchboard.py +++ b/src/mailman/core/switchboard.py @@ -134,7 +134,7 @@ class Switchboard: data['version'] = config.QFILE_SCHEMA_VERSION # Filter out volatile entries. Use .keys() so that we can mutate the # dictionary during the iteration. - for k in data.keys(): + for k in list(data): if k.startswith('_'): del data[k] # We have to tell the dequeue() method whether to parse the message diff --git a/src/mailman/handlers/tests/test_recipients.py b/src/mailman/handlers/tests/test_recipients.py index 8f2a9d47d..ef2021d2c 100644 --- a/src/mailman/handlers/tests/test_recipients.py +++ b/src/mailman/handlers/tests/test_recipients.py @@ -26,14 +26,14 @@ __all__ = [ ] -import six import unittest from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.member import DeliveryMode, DeliveryStatus, MemberRole from mailman.interfaces.usermanager import IUserManager -from mailman.testing.helpers import specialized_message_from_string as mfs +from mailman.testing.helpers import ( + configuration, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer from zope.component import getUtility @@ -200,23 +200,14 @@ To: test-owner@example.com self._process(self._mlist, self._msg, msgdata) self.assertEqual(msgdata['recipients'], set(('noreply@example.com',))) - def test_site_admin_unicode(self): - # Since the config file is read as bytes, the site_owner is also a - # bytes and must be converted to unicode when used as a fallback. + @configuration('mailman', site_owner='siteadmin@example.com') + def test_no_owners_site_owner_fallback(self): + # The list has no owners or moderators, but there is a non-default + # site owner defined. That owner gets the message. self._cris.unsubscribe() self._dave.unsubscribe() self.assertEqual(self._mlist.administrators.member_count, 0) msgdata = {} - # In order to properly mimic the testing environment, use - # config.push()/config.pop() directly instead of using the - # configuration() context manager. - config.push('test_site_admin_unicode', b"""\ -[mailman] -site_owner: siteadmin@example.com -""") - try: - self._process(self._mlist, self._msg, msgdata) - finally: - config.pop('test_site_admin_unicode') - self.assertEqual(len(msgdata['recipients']), 1) - self.assertIsInstance(list(msgdata['recipients'])[0], six.text_type) + self._process(self._mlist, self._msg, msgdata) + self.assertEqual(msgdata['recipients'], + set(('siteadmin@example.com',))) diff --git a/src/mailman/handlers/to_digest.py b/src/mailman/handlers/to_digest.py index e915bbfa3..9eb5818bb 100644 --- a/src/mailman/handlers/to_digest.py +++ b/src/mailman/handlers/to_digest.py @@ -55,7 +55,7 @@ class ToDigest: mailbox_path = os.path.join(mlist.data_path, 'digest.mmdf') # Lock the mailbox and append the message. with Mailbox(mailbox_path, create=True) as mbox: - mbox.add(msg.as_string()) + mbox.add(msg) # Calculate the current size of the mailbox file. This will not tell # us exactly how big the resulting MIME and rfc1153 digest will # actually be, but it's the most easily available metric to decide diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py index 7560fd962..cb5b4a017 100644 --- a/src/mailman/runners/lmtp.py +++ b/src/mailman/runners/lmtp.py @@ -91,7 +91,7 @@ SUBADDRESS_QUEUES = dict( ) DASH = '-' -CRLF = b'\r\n' +CRLF = '\r\n' ERR_451 = b'451 Requested action aborted: error in processing' ERR_501 = b'501 Message has defects' ERR_502 = b'502 Error: command HELO not implemented' @@ -99,7 +99,7 @@ ERR_550 = b'550 Requested action not taken: mailbox unavailable' ERR_550_MID = b'550 No Message-ID header provided' # XXX Blech -smtpd.__version__ = b'Python LMTP runner 1.0' +smtpd.__version__ = 'Python LMTP runner 1.0' @@ -147,6 +147,10 @@ class Channel(smtpd.SMTPChannel): """HELO is not a valid LMTP command.""" self.push(ERR_502) + ## def push(self, arg): + ## import pdb; pdb.set_trace() + ## return super().push(arg) + class LMTPRunner(Runner, smtpd.SMTPServer): @@ -243,7 +247,7 @@ class LMTPRunner(Runner, smtpd.SMTPServer): config.switchboards[queue].enqueue(msg, msgdata) slog.debug('%s subaddress: %s, queue: %s', message_id, canonical_subaddress, queue) - status.append(b'250 Ok') + status.append('250 Ok') except Exception: slog.exception('Queue detection: %s', msg['message-id']) config.db.abort() diff --git a/src/mailman/runners/tests/test_owner.py b/src/mailman/runners/tests/test_owner.py index 6c68e91cc..503f1e18d 100644 --- a/src/mailman/runners/tests/test_owner.py +++ b/src/mailman/runners/tests/test_owner.py @@ -89,7 +89,7 @@ class TestEmailToOwner(unittest.TestCase): # get a copy of the message. lmtp = get_lmtp_client(quiet=True) lmtp.lhlo('remote.example.org') - lmtp.sendmail('zuzu@example.org', ['test-owner@example.com'], """\ + lmtp.sendmail('zuzu@example.org', ['test-owner@example.com'], b"""\ From: Zuzu Person To: test-owner@example.com Message-ID: -- cgit v1.2.3-70-g09d2 From e94434bf2b3e1cfd34028a7bbc804ec8a8ee3788 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 15 Dec 2014 13:06:58 -0500 Subject: Use listid instead of (fqdn) listname in the metadata pickle. load_external() now always opens in utf-8 mode. More test repair. --- src/mailman/app/inject.py | 2 +- src/mailman/app/moderator.py | 2 +- src/mailman/archiving/mailarchive.py | 2 +- src/mailman/bin/gate_news.py | 2 +- src/mailman/config/config.py | 18 ++++------ src/mailman/config/tests/test_configuration.py | 20 ++--------- src/mailman/core/docs/runner.rst | 2 +- src/mailman/core/runner.py | 15 +++++++-- src/mailman/core/switchboard.py | 7 ++-- src/mailman/core/tests/test_runner.py | 2 +- src/mailman/email/message.py | 6 ++-- src/mailman/handlers/to_digest.py | 2 +- src/mailman/handlers/to_outgoing.py | 3 +- src/mailman/handlers/to_usenet.py | 3 +- src/mailman/runners/command.py | 10 +++--- src/mailman/runners/digest.py | 4 +-- src/mailman/runners/docs/digester.rst | 4 +-- src/mailman/runners/docs/nntp.rst | 2 +- src/mailman/runners/docs/outgoing.rst | 26 +++++++-------- src/mailman/runners/lmtp.py | 9 ++--- src/mailman/runners/tests/test_archiver.py | 16 ++++----- src/mailman/runners/tests/test_bounce.py | 4 +-- src/mailman/runners/tests/test_confirm.py | 14 ++++---- src/mailman/runners/tests/test_digest.py | 4 +-- src/mailman/runners/tests/test_incoming.py | 4 +-- src/mailman/runners/tests/test_join.py | 16 ++++----- src/mailman/runners/tests/test_lmtp.py | 4 +-- src/mailman/runners/tests/test_nntp.py | 18 +++++----- src/mailman/runners/tests/test_outgoing.py | 46 +++++++++++++------------- src/mailman/runners/tests/test_pipeline.py | 4 +-- src/mailman/runners/tests/test_retry.py | 2 +- 31 files changed, 131 insertions(+), 142 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/app/inject.py b/src/mailman/app/inject.py index 4c182657d..584bd7b8f 100644 --- a/src/mailman/app/inject.py +++ b/src/mailman/app/inject.py @@ -66,7 +66,7 @@ def inject_message(mlist, msg, recipients=None, switchboard=None, **kws): msg['Date'] = formatdate(localtime=True) msg.original_size = len(msg.as_string()) msgdata = dict( - listname=mlist.fqdn_listname, + listid=mlist.list_id, original_size=msg.original_size, ) msgdata.update(kws) diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py index 9a65207a6..2a8c5f8c2 100644 --- a/src/mailman/app/moderator.py +++ b/src/mailman/app/moderator.py @@ -93,7 +93,7 @@ def hold_message(mlist, msg, msgdata=None, reason=None): # Prepare the message metadata with some extra information needed only by # the moderation interface. msgdata['_mod_message_id'] = message_id - msgdata['_mod_fqdn_listname'] = mlist.fqdn_listname + msgdata['_mod_listid'] = mlist.list_id msgdata['_mod_sender'] = msg.sender msgdata['_mod_subject'] = msg.get('subject', _('(no subject)')) msgdata['_mod_reason'] = reason diff --git a/src/mailman/archiving/mailarchive.py b/src/mailman/archiving/mailarchive.py index 7c5235639..140cd0728 100644 --- a/src/mailman/archiving/mailarchive.py +++ b/src/mailman/archiving/mailarchive.py @@ -73,5 +73,5 @@ class MailArchive: if mlist.archive_policy is ArchivePolicy.public: config.switchboards['out'].enqueue( msg, - listname=mlist.fqdn_listname, + listid=mlist.list_id, recipients=[self.recipient]) diff --git a/src/mailman/bin/gate_news.py b/src/mailman/bin/gate_news.py index 9bb1e5f61..275956fc1 100644 --- a/src/mailman/bin/gate_news.py +++ b/src/mailman/bin/gate_news.py @@ -149,7 +149,7 @@ def poll_newsgroup(mlist, conn, first, last, glock): # Post the message to the locked list inq = Switchboard(config.INQUEUE_DIR) inq.enqueue(msg, - listname=mlist.internal_name(), + listid=mlist.list_id, fromusenet=True) log.info('posted to list %s: %7d', listname, num) except nntplib.NNTPError as e: diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py index c6fe2041a..7a9befa83 100644 --- a/src/mailman/config/config.py +++ b/src/mailman/config/config.py @@ -269,7 +269,7 @@ class Configuration: -def load_external(path, encoding=None): +def load_external(path): """Load the configuration file named by path. :param path: A string naming the location of the external configuration @@ -278,22 +278,16 @@ def load_external(path, encoding=None): value must name a ``.cfg`` file located within Python's import path, however the trailing ``.cfg`` suffix is implied (don't provide it here). - :param encoding: The encoding to apply to the data read from path. If - None, then bytes will be returned. - :return: A unicode string or bytes, depending on ``encoding``. + :return: The contents of the configuration file. + :rtype: str """ # Is the context coming from a file system or Python path? if path.startswith('python:'): resource_path = path[7:] package, dot, resource = resource_path.rpartition('.') - raw = resource_bytes(package, resource + '.cfg') - config_string = raw.decode('utf-8') - else: - with open(path, 'r', encoding='utf-8') as fp: - config_string = fp.read() - if encoding is None: - return config_string - return config_string.decode(encoding) + return resource_bytes(package, resource + '.cfg').decode('utf-8') + with open(path, 'r', encoding='utf-8') as fp: + return fp.read() def external_configuration(path): diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index b411f9615..ce2e6bae3 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -28,7 +28,6 @@ __all__ = [ import os -import six import mock import tempfile import unittest @@ -66,26 +65,13 @@ class TestConfiguration(unittest.TestCase): class TestExternal(unittest.TestCase): """Test external configuration file loading APIs.""" - def test_load_external_by_filename_as_bytes(self): + def test_load_external_by_filename(self): filename = resource_filename('mailman.config', 'postfix.cfg') contents = load_external(filename) - self.assertIsInstance(contents, bytes) - self.assertEqual(contents[:9], b'[postfix]') - - def test_load_external_by_path_as_bytes(self): - contents = load_external('python:mailman.config.postfix') - self.assertIsInstance(contents, bytes) - self.assertEqual(contents[:9], b'[postfix]') - - def test_load_external_by_filename_as_string(self): - filename = resource_filename('mailman.config', 'postfix.cfg') - contents = load_external(filename, encoding='utf-8') - self.assertIsInstance(contents, six.text_type) self.assertEqual(contents[:9], '[postfix]') - def test_load_external_by_path_as_string(self): - contents = load_external('python:mailman.config.postfix', 'utf-8') - self.assertIsInstance(contents, six.text_type) + def test_load_external_by_path(self): + contents = load_external('python:mailman.config.postfix') self.assertEqual(contents[:9], '[postfix]') def test_external_configuration_by_filename(self): diff --git a/src/mailman/core/docs/runner.rst b/src/mailman/core/docs/runner.rst index e9fd21c57..865635310 100644 --- a/src/mailman/core/docs/runner.rst +++ b/src/mailman/core/docs/runner.rst @@ -55,7 +55,7 @@ on instance variables. ... A test message. ... """) >>> switchboard = config.switchboards['test'] - >>> filebase = switchboard.enqueue(msg, listname=mlist.fqdn_listname, + >>> filebase = switchboard.enqueue(msg, list_id=mlist.list_id, ... foo='yes', bar='no') >>> runner.run() >>> print(runner.msg.as_string()) diff --git a/src/mailman/core/runner.py b/src/mailman/core/runner.py index d6aad2b07..83f1b469c 100644 --- a/src/mailman/core/runner.py +++ b/src/mailman/core/runner.py @@ -219,9 +219,18 @@ class Runner: # Find out which mailing list this message is destined for. mlist = None missing = object() - listname = msgdata.get('listname', missing) - if listname is missing: - mlist = getUtility(IListManager).get(listname.decode('utf-8')) + # First try to dig out the target list by id. If there's no list-id + # in the metadata, fall back to the fqdn list name for backward + # compatibility. + list_manager = getUtility(IListManager) + list_id = msgdata.get('listid', missing) + if list_id is missing: + listname = msgdata.get('listname', missing) + # XXX Deprecate. + if listname is not missing: + mlist = list_manager.get(listname) + else: + mlist = list_manager.get_by_list_id(list_id) if mlist is None: elog.error( '%s runner "%s" shunting message for missing list: %s', diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py index 3375aa1dd..d4884c4c9 100644 --- a/src/mailman/core/switchboard.py +++ b/src/mailman/core/switchboard.py @@ -112,7 +112,7 @@ class Switchboard: # of parallel runner processes. data = _metadata.copy() data.update(_kws) - listname = data.get('listname', '--nolist--') + list_id = data.get('listid', '--nolist--') # Get some data for the input to the sha hash. now = repr(time.time()) if data.get('_plaintext'): @@ -121,8 +121,9 @@ class Switchboard: else: protocol = pickle.HIGHEST_PROTOCOL msgsave = cPickle.dumps(_msg, protocol) - # listname is a str but the input to the hash function must be a bytes. - hashfood = msgsave + listname.encode('utf-8') + now.encode('utf-8') + # The list-id field is a string but the input to the hash function must + # be bytes. + hashfood = msgsave + list_id.encode('utf-8') + now.encode('utf-8') # Encode the current time into the file name for FIFO sorting. The # file name consists of two parts separated by a '+': the received # time for this message (i.e. when it first showed up on this system) diff --git a/src/mailman/core/tests/test_runner.py b/src/mailman/core/tests/test_runner.py index 2875b3b10..a48925b4c 100644 --- a/src/mailman/core/tests/test_runner.py +++ b/src/mailman/core/tests/test_runner.py @@ -68,7 +68,7 @@ To: test@example.com Message-ID: """) - config.switchboards['in'].enqueue(msg, listname='test@example.com') + config.switchboards['in'].enqueue(msg, listid='test.example.com') with event_subscribers(self._got_event): runner.run() # We should now have exactly one event, which will contain the diff --git a/src/mailman/email/message.py b/src/mailman/email/message.py index 539d151ad..92f5ff846 100644 --- a/src/mailman/email/message.py +++ b/src/mailman/email/message.py @@ -185,7 +185,7 @@ class UserNotification(Message): :param mlist: The mailing list to send the message to. :type mlist: `IMailingList` - :param add_precedence: Flag indicating whether a `Precedence: bulk` + :param add_precedence: Flag indicating whether a `Precedence: bulk` header should be added to the message or not. :type add_precedence: bool @@ -217,7 +217,7 @@ class UserNotification(Message): reduced_list_headers=True, ) if mlist is not None: - enqueue_kws['listname'] = mlist.fqdn_listname + enqueue_kws['listid'] = mlist.list_id enqueue_kws.update(_kws) virginq.enqueue(self, **enqueue_kws) @@ -246,7 +246,7 @@ class OwnerNotification(UserNotification): virginq = config.switchboards['virgin'] # The message metadata better have a `recip' attribute virginq.enqueue(self, - listname=mlist.fqdn_listname, + listid=mlist.list_id, recipients=self.recipients, nodecorate=True, reduced_list_headers=True, diff --git a/src/mailman/handlers/to_digest.py b/src/mailman/handlers/to_digest.py index 9eb5818bb..e2d6657b7 100644 --- a/src/mailman/handlers/to_digest.py +++ b/src/mailman/handlers/to_digest.py @@ -75,7 +75,7 @@ class ToDigest: os.rename(mailbox_path, mailbox_dest) config.switchboards['digest'].enqueue( Message(), - listname=mlist.fqdn_listname, + listid=mlist.list_id, digest_path=mailbox_dest, volume=volume, digest_number=digest_number) diff --git a/src/mailman/handlers/to_outgoing.py b/src/mailman/handlers/to_outgoing.py index 6dfbe88c0..92fb7fee0 100644 --- a/src/mailman/handlers/to_outgoing.py +++ b/src/mailman/handlers/to_outgoing.py @@ -47,5 +47,4 @@ class ToOutgoing: def process(self, mlist, msg, msgdata): """See `IHandler`.""" - config.switchboards['out'].enqueue( - msg, msgdata, listname=mlist.fqdn_listname) + config.switchboards['out'].enqueue(msg, msgdata, listid=mlist.list_id) diff --git a/src/mailman/handlers/to_usenet.py b/src/mailman/handlers/to_usenet.py index d5a946644..28c18c520 100644 --- a/src/mailman/handlers/to_usenet.py +++ b/src/mailman/handlers/to_usenet.py @@ -65,5 +65,4 @@ class ToUsenet: COMMASPACE.join(error)) return # Put the message in the news runner's queue. - config.switchboards['nntp'].enqueue( - msg, msgdata, listname=mlist.fqdn_listname) + config.switchboards['nntp'].enqueue(msg, msgdata, listid=mlist.list_id) diff --git a/src/mailman/runners/command.py b/src/mailman/runners/command.py index f6884de5f..7f8c7f470 100644 --- a/src/mailman/runners/command.py +++ b/src/mailman/runners/command.py @@ -76,7 +76,7 @@ class CommandFinder: # Extract the subject header and do RFC 2047 decoding. raw_subject = msg.get('subject', '') try: - subject = make_header(decode_header(raw_subject)).decode('utf-8') + subject = str(make_header(decode_header(raw_subject))) # Mail commands must be ASCII. self.command_lines.append(subject.encode('us-ascii')) except (HeaderParseError, UnicodeError, LookupError): @@ -98,7 +98,7 @@ class CommandFinder: if part is None: # There was no text/plain part to be found. return - body = part.get_payload(decode=True) + body = part.get_payload() # text/plain parts better have string payloads. assert isinstance(body, six.string_types), 'Non-string decoded payload' lines = body.splitlines() @@ -207,12 +207,12 @@ class CommandRunner(Runner): if status == ContinueProcessing.no: break # All done. Strip blank lines and send the response. - lines = filter(None, (line.strip() for line in finder.command_lines)) + lines = [line.strip() for line in finder.command_lines if line] if len(lines) > 0: print(_('\n- Unprocessed:'), file=results) for line in lines: print(line, file=results) - lines = filter(None, (line.strip() for line in finder.ignored_lines)) + lines = [line.strip() for line in finder.ignored_lines if line] if len(lines) > 0: print(_('\n- Ignored:'), file=results) for line in lines: @@ -231,7 +231,7 @@ class CommandRunner(Runner): # Find a charset for the response body. Try the original message's # charset first, then ascii, then latin-1 and finally falling back to # utf-8. - reply_body = results.decode('utf-8') + reply_body = str(results) for charset in (results.charset, 'us-ascii', 'latin-1'): try: reply_body.encode(charset) diff --git a/src/mailman/runners/digest.py b/src/mailman/runners/digest.py index 628a08e0c..1716d9694 100644 --- a/src/mailman/runners/digest.py +++ b/src/mailman/runners/digest.py @@ -383,9 +383,9 @@ class DigestRunner(Runner): queue = config.switchboards['virgin'] queue.enqueue(mime, recipients=mime_recipients, - listname=mlist.fqdn_listname, + listid=mlist.list_id, isdigest=True) queue.enqueue(rfc1153, recipients=rfc1153_recipients, - listname=mlist.fqdn_listname, + listid=mlist.list_id, isdigest=True) diff --git a/src/mailman/runners/docs/digester.rst b/src/mailman/runners/docs/digester.rst index cd0fba67c..14580c336 100644 --- a/src/mailman/runners/docs/digester.rst +++ b/src/mailman/runners/docs/digester.rst @@ -57,7 +57,7 @@ But the message metadata has a reference to the digest file. _parsemsg : False digest_number: 1 digest_path : .../lists/test@example.com/digest.1.1.mmdf - listname : test@example.com + listid : test.example.com version : 3 volume : 1 @@ -323,7 +323,7 @@ The marker message is sitting in the digest queue. _parsemsg : False digest_number: 2 digest_path : .../lists/test@example.com/digest.1.2.mmdf - listname : test@example.com + listid : test.example.com version : 3 volume : 1 diff --git a/src/mailman/runners/docs/nntp.rst b/src/mailman/runners/docs/nntp.rst index 372fa5744..4bd73cbab 100644 --- a/src/mailman/runners/docs/nntp.rst +++ b/src/mailman/runners/docs/nntp.rst @@ -37,7 +37,7 @@ are prohibited by NNTP servers such as INN. The message gets copied to the NNTP queue for preparation and posting. >>> filebase = config.switchboards['nntp'].enqueue( - ... msg, listname='test@example.com') + ... msg, listid='test.example.com') >>> from mailman.testing.helpers import make_testable_runner >>> from mailman.runners.nntp import NNTPRunner >>> runner = make_testable_runner(NNTPRunner, 'nntp') diff --git a/src/mailman/runners/docs/outgoing.rst b/src/mailman/runners/docs/outgoing.rst index d4a20d497..7c3d1a989 100644 --- a/src/mailman/runners/docs/outgoing.rst +++ b/src/mailman/runners/docs/outgoing.rst @@ -57,7 +57,7 @@ destination mailing list name. Simulate that here too. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, ... tolist=True, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) Running the outgoing runner processes the message, delivering it to the upstream SMTP. @@ -105,7 +105,7 @@ just one. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -147,7 +147,7 @@ A handler can force VERP by setting the ``verp`` key in the message metadata. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, ... verp=True, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -174,7 +174,7 @@ Again, we get three individual messages, with VERP'd ``Sender`` headers. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -215,7 +215,7 @@ VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -235,7 +235,7 @@ The second message sent to the list is also not VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -254,7 +254,7 @@ The third message though is VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -274,7 +274,7 @@ The next one is back to bulk delivery. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -308,7 +308,7 @@ The first message is VERP'd. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -328,7 +328,7 @@ As is the second message. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -348,7 +348,7 @@ And the third message. >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -387,7 +387,7 @@ Neither the first message... >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) @@ -402,7 +402,7 @@ Neither the first message... >>> ignore = outgoing_queue.enqueue( ... msg, msgdata, - ... listname=mlist.fqdn_listname) + ... listid=mlist.list_id) >>> outgoing.run() >>> messages = list(smtpd.messages) >>> len(messages) diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py index cb5b4a017..daa1e7e1c 100644 --- a/src/mailman/runners/lmtp.py +++ b/src/mailman/runners/lmtp.py @@ -206,18 +206,19 @@ class LMTPRunner(Runner, smtpd.SMTPServer): for to in rcpttos: try: to = parseaddr(to)[1].lower() - listname, subaddress, domain = split_recipient(to) + local, subaddress, domain = split_recipient(to) slog.debug('%s to: %s, list: %s, sub: %s, dom: %s', - message_id, to, listname, subaddress, domain) - listname += '@' + domain + message_id, to, local, subaddress, domain) + listname = '{}@{}'.format(local, domain) if listname not in listnames: status.append(ERR_550) continue + listid = '{}.{}'.format(local, domain) # The recipient is a valid mailing list. Find the subaddress # if there is one, and set things up to enqueue to the proper # queue. queue = None - msgdata = dict(listname=listname, + msgdata = dict(listid=listid, original_size=msg.original_size, received_time=received_time) canonical_subaddress = SUBADDRESS_NAMES.get(subaddress) diff --git a/src/mailman/runners/tests/test_archiver.py b/src/mailman/runners/tests/test_archiver.py index e11b6c805..12bdb0edd 100644 --- a/src/mailman/runners/tests/test_archiver.py +++ b/src/mailman/runners/tests/test_archiver.py @@ -110,7 +110,7 @@ First post! # Ensure that the archive runner ends up archiving the message. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now()) self._runner.run() # There should now be a copy of the message in the file system. @@ -126,7 +126,7 @@ First post! self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT) self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now()) self._runner.run() # There should now be a copy of the message in the file system. @@ -144,7 +144,7 @@ First post! self._msg['Date'] = now(strip_tzinfo=False).strftime(RFC822_DATE_FMT) self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now()) self._runner.run() # There should now be a copy of the message in the file system. @@ -163,7 +163,7 @@ First post! # again), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, received_time=now(strip_tzinfo=False)) self._runner.run() # There should now be a copy of the message in the file system. @@ -182,7 +182,7 @@ First post! # again as will happen in the runner), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) factory.fast_forward(days=4) self._runner.run() # There should now be a copy of the message in the file system. @@ -205,7 +205,7 @@ First post! # again as will happen in the runner), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) factory.fast_forward(days=4) self._runner.run() # There should now be a copy of the message in the file system. @@ -228,7 +228,7 @@ First post! # again as will happen in the runner), fast forward a few days. self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) factory.fast_forward(days=4) self._runner.run() # There should now be a copy of the message in the file system. @@ -249,6 +249,6 @@ First post! config.db.store.commit() self._archiveq.enqueue( self._msg, {}, - listname=self._mlist.fqdn_listname) + listid=self._mlist.list_id) self._runner.run() self.assertEqual(os.listdir(config.MESSAGES_DIR), []) diff --git a/src/mailman/runners/tests/test_bounce.py b/src/mailman/runners/tests/test_bounce.py index 315a81c22..b296f4476 100644 --- a/src/mailman/runners/tests/test_bounce.py +++ b/src/mailman/runners/tests/test_bounce.py @@ -69,7 +69,7 @@ To: test-bounces+anne=example.com@example.com Message-Id: """) - self._msgdata = dict(listname='test@example.com') + self._msgdata = dict(listid='test.example.com') self._processor = getUtility(IBounceProcessor) config.push('site owner', """ [mailman] @@ -284,7 +284,7 @@ To: test-bounces+anne=example.com@example.com Message-Id: """) - self._bounceq.enqueue(bounce, dict(listname='test@example.com')) + self._bounceq.enqueue(bounce, dict(listid='test.example.com')) self.assertEqual(len(self._bounceq.files), 1) self._runner.run() self.assertEqual(len(get_queue_messages('bounces')), 0) diff --git a/src/mailman/runners/tests/test_confirm.py b/src/mailman/runners/tests/test_confirm.py index 40fae368f..d387fcfe6 100644 --- a/src/mailman/runners/tests/test_confirm.py +++ b/src/mailman/runners/tests/test_confirm.py @@ -68,7 +68,7 @@ To: test-confirm@example.com """) msg['Subject'] = subject - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -88,7 +88,7 @@ To: test-confirm@example.com """) msg['Subject'] = subject - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -144,7 +144,7 @@ Franziskanerstra=C3=9Fe """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -177,7 +177,7 @@ Franziskanerstra=C3=9Fe """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # Anne is now a confirmed member so her user record and email address # should exist in the database. @@ -208,7 +208,7 @@ From: Anne Person """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com', + self._commandq.enqueue(msg, dict(listid='test.example.com', subaddress='confirm')) self._runner.run() # Anne is now a confirmed member so her user record and email address @@ -223,7 +223,7 @@ From: Anne Person # one 'Confirmation email' line. confirmation_lines = [] in_results = False - for line in body_line_iterator(messages[0].msg, decode=True): + for line in body_line_iterator(messages[0].msg): line = line.strip() if in_results: if line.startswith('- Done'): @@ -253,7 +253,7 @@ From: Anne Person """) msg['Subject'] = subject msg['To'] = to - self._commandq.enqueue(msg, dict(listname='test@example.com', + self._commandq.enqueue(msg, dict(listid='test.example.com', subaddress='confirm')) self._runner.run() # Now there's a email command notification and a welcome message. All diff --git a/src/mailman/runners/tests/test_digest.py b/src/mailman/runners/tests/test_digest.py index 80cf253bc..6cd3c9a01 100644 --- a/src/mailman/runners/tests/test_digest.py +++ b/src/mailman/runners/tests/test_digest.py @@ -65,7 +65,7 @@ message triggering a digest self._process(self._mlist, msg, {}) self._digestq.enqueue( msg, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, digest_path=mbox_path, volume=1, digest_number=1) self._runner.run() @@ -92,7 +92,7 @@ message triggering a digest mbox.add(msg.as_string()) self._digestq.enqueue( msg, - listname=self._mlist.fqdn_listname, + listid=self._mlist.list_id, digest_path=mbox_path, volume=1, digest_number=1) # Use any error logs as the error message if the test fails. diff --git a/src/mailman/runners/tests/test_incoming.py b/src/mailman/runners/tests/test_incoming.py index 9830fedb9..2d49ae550 100644 --- a/src/mailman/runners/tests/test_incoming.py +++ b/src/mailman/runners/tests/test_incoming.py @@ -76,7 +76,7 @@ To: test@example.com def test_posting(self): # A message posted to the list goes through the posting chain. - msgdata = dict(listname='test@example.com') + msgdata = dict(listid='test.example.com') config.switchboards['in'].enqueue(self._msg, msgdata) self._in.run() messages = get_queue_messages('out') @@ -85,7 +85,7 @@ To: test@example.com def test_owner(self): # A message posted to the list goes through the posting chain. - msgdata = dict(listname='test@example.com', + msgdata = dict(listid='test.example.com', to_owner=True) config.switchboards['in'].enqueue(self._msg, msgdata) self._in.run() diff --git a/src/mailman/runners/tests/test_join.py b/src/mailman/runners/tests/test_join.py index fbea9e661..2aa361254 100644 --- a/src/mailman/runners/tests/test_join.py +++ b/src/mailman/runners/tests/test_join.py @@ -72,7 +72,7 @@ subscribe # Adding the subaddress to the metadata dictionary mimics what happens # when the above email message is first processed by the lmtp runner. # For convenience, we skip that step in this test. - self._commandq.enqueue(msg, dict(listname='test@example.com', + self._commandq.enqueue(msg, dict(listid='test.example.com', subaddress='join')) self._runner.run() # There will be two messages in the queue. The first one is a reply @@ -87,7 +87,7 @@ subscribe # one 'Confirmation email' line. confirmation_lines = [] in_results = False - for line in body_line_iterator(messages[0].msg, decode=True): + for line in body_line_iterator(messages[0].msg): line = line.strip() if in_results: if line.startswith('- Done'): @@ -112,7 +112,7 @@ To: test-join@example.com Subject: join """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() # There will be one message in the queue - a reply to Anne notifying # her of the status of her command email. Because Anne is already @@ -125,7 +125,7 @@ Subject: join # one 'Confirmation email' line. confirmation_lines = [] in_results = False - for line in body_line_iterator(messages[0].msg, decode=True): + for line in body_line_iterator(messages[0].msg): line = line.strip() if in_results: if line.startswith('- Done'): @@ -181,7 +181,7 @@ To: test-request@example.com join """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') @@ -195,7 +195,7 @@ To: test-request@example.com join digest=no """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') @@ -209,7 +209,7 @@ To: test-request@example.com join digest=mime """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') @@ -223,7 +223,7 @@ To: test-request@example.com join digest=plain """) - self._commandq.enqueue(msg, dict(listname='test@example.com')) + self._commandq.enqueue(msg, dict(listid='test.example.com')) self._runner.run() anne = self._confirm() self.assertEqual(anne.address.email, 'anne@example.org') diff --git a/src/mailman/runners/tests/test_lmtp.py b/src/mailman/runners/tests/test_lmtp.py index 26308548c..ccd27c829 100644 --- a/src/mailman/runners/tests/test_lmtp.py +++ b/src/mailman/runners/tests/test_lmtp.py @@ -142,5 +142,5 @@ Message-ID: """) messages = get_queue_messages('in') self.assertEqual(len(messages), 1) - self.assertEqual(messages[0].msgdata['listname'], - 'my-list@example.com') + self.assertEqual(messages[0].msgdata['listid'], + 'my-list.example.com') diff --git a/src/mailman/runners/tests/test_nntp.py b/src/mailman/runners/tests/test_nntp.py index 191dd2657..24db00285 100644 --- a/src/mailman/runners/tests/test_nntp.py +++ b/src/mailman/runners/tests/test_nntp.py @@ -257,7 +257,7 @@ Testing @mock.patch('nntplib.NNTP') def test_connect(self, class_mock): # Test connection to the NNTP server with default values. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() class_mock.assert_called_once_with( '', 119, user='', password='', readermode=True) @@ -267,7 +267,7 @@ Testing @mock.patch('nntplib.NNTP') def test_connect_with_configuration(self, class_mock): # Test connection to the NNTP server with specific values. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() class_mock.assert_called_once_with( 'nntp.example.com', 2112, @@ -276,7 +276,7 @@ Testing @mock.patch('nntplib.NNTP') def test_post(self, class_mock): # Test that the message is posted to the NNTP server. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Get the mocked instance, which was used in the runner. conn_mock = class_mock() @@ -295,7 +295,7 @@ Testing def test_connection_got_quit(self, class_mock): # The NNTP connection gets closed after a successful post. # Test that the message is posted to the NNTP server. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Get the mocked instance, which was used in the runner. conn_mock = class_mock() @@ -306,7 +306,7 @@ Testing @mock.patch('nntplib.NNTP', side_effect=nntplib.NNTPTemporaryError) def test_connect_with_nntplib_failure(self, class_mock): - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') mark = LogFileMark('mailman.error') self._runner.run() log_message = mark.readline()[:-1] @@ -315,7 +315,7 @@ Testing @mock.patch('nntplib.NNTP', side_effect=socket.error) def test_connect_with_socket_failure(self, class_mock): - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') mark = LogFileMark('mailman.error') self._runner.run() log_message = mark.readline()[:-1] @@ -330,7 +330,7 @@ Testing # I.e. stop immediately, since the queue will not be empty. return True runner = make_testable_runner(nntp.NNTPRunner, 'nntp', predicate=once) - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') mark = LogFileMark('mailman.error') runner.run() log_message = mark.readline()[:-1] @@ -345,7 +345,7 @@ Testing def test_connection_never_gets_quit_after_failures(self, class_mock): # The NNTP connection doesn't get closed after a unsuccessful # connection, since there's nothing to close. - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Get the mocked instance, which was used in the runner. Turn off the # exception raising side effect first though! @@ -362,7 +362,7 @@ Testing # Add a side-effect to the instance mock's .post() method. conn_mock = class_mock() conn_mock.post.side_effect = nntplib.NNTPTemporaryError - self._nntpq.enqueue(self._msg, {}, listname='test@example.com') + self._nntpq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # The connection object's post() method was called once with a # file-like object containing the message's bytes. Read those bytes diff --git a/src/mailman/runners/tests/test_outgoing.py b/src/mailman/runners/tests/test_outgoing.py index 62f6776b1..68fb75fc3 100644 --- a/src/mailman/runners/tests/test_outgoing.py +++ b/src/mailman/runners/tests/test_outgoing.py @@ -96,7 +96,7 @@ Message-Id: deliver_after = now() + timedelta(days=10) self._msgdata['deliver_after'] = deliver_after self._outq.enqueue(self._msg, self._msgdata, - tolist=True, listname='test@example.com') + tolist=True, listid='test.example.com') self._runner.run() items = get_queue_messages('out') self.assertEqual(len(items), 1) @@ -149,20 +149,20 @@ Message-Id: def test_delivery_callback(self): # Test that the configuration variable calls the appropriate callback. - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() self.assertEqual(captured_mlist, self._mlist) self.assertEqual(captured_msg.as_string(), self._msg.as_string()) # Of course, the message metadata will contain a bunch of keys added # by the processing. We don't really care about the details, so this # test is a good enough stand-in. - self.assertEqual(captured_msgdata['listname'], 'test@example.com') + self.assertEqual(captured_msgdata['listid'], 'test.example.com') def test_verp_in_metadata(self): # Test that if the metadata has a 'verp' key, it is unchanged. marker = 'yepper' msgdata = dict(verp=marker) - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() self.assertEqual(captured_msgdata['verp'], marker) @@ -171,7 +171,7 @@ Message-Id: # indicates, messages will be VERP'd. msgdata = {} self._mlist.personalize = Personalization.individual - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_personalized_deliveries: yes @@ -184,7 +184,7 @@ Message-Id: # indicates, messages will be VERP'd. msgdata = {} self._mlist.personalize = Personalization.full - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_personalized_deliveries: yes @@ -197,14 +197,14 @@ Message-Id: # does not indicate, messages will not be VERP'd. msgdata = {} self._mlist.personalize = Personalization.full - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() self.assertFalse('verp' in captured_msgdata) def test_verp_never(self): # Never VERP when the interval is zero. msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 0 @@ -215,7 +215,7 @@ Message-Id: def test_verp_always(self): # Always VERP when the interval is one. msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 1 @@ -227,7 +227,7 @@ Message-Id: # VERP every so often, when the post_id matches. self._mlist.post_id = 5 msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 5 @@ -239,7 +239,7 @@ Message-Id: # VERP every so often, when the post_id matches. self._mlist.post_id = 4 msgdata = {} - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') with temporary_config('personalize', """ [mta] verp_delivery_interval: 5 @@ -287,7 +287,7 @@ Message-Id: error_log = logging.getLogger('mailman.error') filename = error_log.handlers[0].filename filepos = os.stat(filename).st_size - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') with temporary_config('port 0', """ [mta] smtp_port: 0 @@ -308,7 +308,7 @@ Message-Id: # that is a log message. Start by opening the error log and reading # the current file position. mark = LogFileMark('mailman.error') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') with temporary_config('port 0', """ [mta] smtp_port: 2112 @@ -369,7 +369,7 @@ Message-Id: token = send_probe(member, self._msg) msgdata = dict(probe_token=token) permanent_failures.append('anne@example.com') - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 1) @@ -390,7 +390,7 @@ Message-Id: getUtility(IPendings).confirm(token) msgdata = dict(probe_token=token) permanent_failures.append('anne@example.com') - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -404,7 +404,7 @@ Message-Id: getUtility(IPendings).confirm(token) msgdata = dict(probe_token=token) temporary_failures.append('anne@example.com') - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -412,7 +412,7 @@ Message-Id: def test_one_permanent_failure(self): # Normal (i.e. non-probe) permanent failures just get registered. permanent_failures.append('anne@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 1) @@ -423,7 +423,7 @@ Message-Id: # Two normal (i.e. non-probe) permanent failures just get registered. permanent_failures.append('anne@example.com') permanent_failures.append('bart@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 2) @@ -437,7 +437,7 @@ Message-Id: # put in the retry queue, but with some metadata to prevent infinite # retries. temporary_failures.append('cris@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -458,7 +458,7 @@ Message-Id: # retries. temporary_failures.append('cris@example.com') temporary_failures.append('dave@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() events = list(self._processor.unprocessed) self.assertEqual(len(events), 0) @@ -476,7 +476,7 @@ Message-Id: permanent_failures.append('fred@example.com') temporary_failures.append('gwen@example.com') temporary_failures.append('herb@example.com') - self._outq.enqueue(self._msg, {}, listname='test@example.com') + self._outq.enqueue(self._msg, {}, listid='test.example.com') self._runner.run() # Let's look at the permanent failures. events = list(self._processor.unprocessed) @@ -503,7 +503,7 @@ Message-Id: as_timedelta(config.mta.delivery_retry_period)) msgdata = dict(last_recip_count=2, deliver_until=deliver_until) - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') self._runner.run() # The retry queue should have our message waiting to be retried. items = get_queue_messages('retry') @@ -522,7 +522,7 @@ Message-Id: deliver_until = datetime(2005, 8, 1, 7, 49, 23) + retry_period msgdata = dict(last_recip_count=2, deliver_until=deliver_until) - self._outq.enqueue(self._msg, msgdata, listname='test@example.com') + self._outq.enqueue(self._msg, msgdata, listid='test.example.com') # Before the runner runs, several days pass. factory.fast_forward(retry_period.days + 1) mark = LogFileMark('mailman.smtp') diff --git a/src/mailman/runners/tests/test_pipeline.py b/src/mailman/runners/tests/test_pipeline.py index 50ec6cb9a..1eba5cfbf 100644 --- a/src/mailman/runners/tests/test_pipeline.py +++ b/src/mailman/runners/tests/test_pipeline.py @@ -101,7 +101,7 @@ To: test@example.com def test_posting(self): # A message accepted for posting gets processed through the posting # pipeline. - msgdata = dict(listname='test@example.com') + msgdata = dict(listid='test.example.com') config.switchboards['pipeline'].enqueue(self._msg, msgdata) self._pipeline.run() self.assertEqual(len(self._markers), 1) @@ -110,7 +110,7 @@ To: test@example.com def test_owner(self): # A message accepted for posting to a list's owners gets processed # through the owner pipeline. - msgdata = dict(listname='test@example.com', + msgdata = dict(listid='test.example.com', to_owner=True) config.switchboards['pipeline'].enqueue(self._msg, msgdata) self._pipeline.run() diff --git a/src/mailman/runners/tests/test_retry.py b/src/mailman/runners/tests/test_retry.py index 28289bc05..15775e5d8 100644 --- a/src/mailman/runners/tests/test_retry.py +++ b/src/mailman/runners/tests/test_retry.py @@ -54,7 +54,7 @@ To: test@example.com Message-Id: """) - self._msgdata = dict(listname='test@example.com') + self._msgdata = dict(listid='test.example.com') def test_message_put_in_outgoing_queue(self): self._retryq.enqueue(self._msg, self._msgdata) -- cgit v1.2.3-70-g09d2 From e3b97fadcf345604c9760113ddf06505a2f3b95c Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 15 Dec 2014 16:36:48 -0500 Subject: Fix pipelines tests. --- src/mailman/app/docs/pipelines.rst | 8 ++++---- src/mailman/handlers/cook_headers.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/app/docs/pipelines.rst b/src/mailman/app/docs/pipelines.rst index adcdd1ea5..daedab50a 100644 --- a/src/mailman/app/docs/pipelines.rst +++ b/src/mailman/app/docs/pipelines.rst @@ -67,7 +67,7 @@ However there are currently no recipients for this message. >>> dump_msgdata(msgdata) original_sender : aperson@example.com original_subject: My first post - recipients : set([]) + recipients : set() stripped_subject: My first post After pipeline processing, the message is now sitting in various other @@ -97,7 +97,7 @@ processing queues. _parsemsg : False original_sender : aperson@example.com original_subject: My first post - recipients : set([]) + recipients : set() stripped_subject: My first post version : 3 @@ -132,10 +132,10 @@ delivered to end recipients. >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : test@example.com + listid : test.example.com original_sender : aperson@example.com original_subject: My first post - recipients : set([]) + recipients : set() stripped_subject: My first post version : 3 diff --git a/src/mailman/handlers/cook_headers.py b/src/mailman/handlers/cook_headers.py index 5fdfc238b..1ab527bb4 100644 --- a/src/mailman/handlers/cook_headers.py +++ b/src/mailman/handlers/cook_headers.py @@ -270,7 +270,7 @@ def ch_oneline(headerstr): else: cset = 'utf-8' h = make_header(d) - ustr = h.decode('utf-8') + ustr = str(h) oneline = ''.join(ustr.splitlines()) return oneline.encode(cset, 'replace'), cset except (LookupError, UnicodeError, ValueError, HeaderParseError): -- cgit v1.2.3-70-g09d2 From 130bd8179188fbbcf488ab668baae4fe945bcfc2 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 15 Dec 2014 17:29:02 -0500 Subject: Better, but not perfect handler test passing. --- src/mailman/handlers/docs/acknowledge.rst | 8 +-- src/mailman/handlers/docs/avoid-duplicates.rst | 12 ++-- src/mailman/handlers/docs/file-recips.rst | 27 +-------- src/mailman/handlers/docs/filtering.rst | 18 ++---- src/mailman/handlers/docs/nntp.rst | 2 +- src/mailman/handlers/docs/replybot.rst | 8 +-- src/mailman/handlers/docs/rfc-2369.rst | 2 +- src/mailman/handlers/docs/subject-munging.rst | 2 +- src/mailman/handlers/docs/tagger.rst | 24 ++++---- src/mailman/handlers/docs/to-outgoing.rst | 2 +- src/mailman/handlers/mime_delete.py | 2 +- src/mailman/handlers/tagger.py | 6 +- src/mailman/handlers/tests/test_file_recips.py | 76 ++++++++++++++++++++++++++ src/mailman/handlers/tests/test_filter.py | 60 ++++++++++++++++++++ src/mailman/testing/helpers.py | 5 +- 15 files changed, 182 insertions(+), 72 deletions(-) create mode 100644 src/mailman/handlers/tests/test_file_recips.py create mode 100644 src/mailman/handlers/tests/test_filter.py (limited to 'src/mailman/handlers') diff --git a/src/mailman/handlers/docs/acknowledge.rst b/src/mailman/handlers/docs/acknowledge.rst index e91f94f62..42cab04a0 100644 --- a/src/mailman/handlers/docs/acknowledge.rst +++ b/src/mailman/handlers/docs/acknowledge.rst @@ -113,9 +113,9 @@ The receipt will include the original message's subject in the response body, 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : test@example.com + listid : test.example.com nodecorate : True - recipients : set([u'aperson@example.com']) + recipients : {'aperson@example.com'} reduced_list_headers: True ... >>> print(messages[0].msg.as_string()) @@ -150,9 +150,9 @@ If there is no subject, then the receipt will use a generic message. 1 >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : test@example.com + listid : test.example.com nodecorate : True - recipients : set([u'aperson@example.com']) + recipients : {'aperson@example.com'} reduced_list_headers: True ... >>> print(messages[0].msg.as_string()) diff --git a/src/mailman/handlers/docs/avoid-duplicates.rst b/src/mailman/handlers/docs/avoid-duplicates.rst index 612634941..19a41bf85 100644 --- a/src/mailman/handlers/docs/avoid-duplicates.rst +++ b/src/mailman/handlers/docs/avoid-duplicates.rst @@ -71,7 +71,7 @@ or ``Resent-CC``), then they will get a list copy. >>> msgdata = recips.copy() >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) - [u'aperson@example.com', u'bperson@example.com'] + ['aperson@example.com', 'bperson@example.com'] >>> print(msg.as_string()) From: Claire Person @@ -89,7 +89,7 @@ If they're mentioned on the ``CC`` line, they won't get a list copy. >>> msgdata = recips.copy() >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) - [u'bperson@example.com'] + ['bperson@example.com'] >>> print(msg.as_string()) From: Claire Person CC: aperson@example.com @@ -109,7 +109,7 @@ to ``True`` (the default), then they still get a list copy. >>> msgdata = recips.copy() >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) - [u'aperson@example.com', u'bperson@example.com'] + ['aperson@example.com', 'bperson@example.com'] >>> print(msg.as_string()) From: Claire Person CC: bperson@example.com @@ -128,7 +128,7 @@ Other headers checked for recipients include the ``To``... >>> msgdata = recips.copy() >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) - [u'bperson@example.com'] + ['bperson@example.com'] >>> print(msg.as_string()) From: Claire Person To: aperson@example.com @@ -147,7 +147,7 @@ Other headers checked for recipients include the ``To``... >>> msgdata = recips.copy() >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) - [u'bperson@example.com'] + ['bperson@example.com'] >>> print(msg.as_string()) From: Claire Person Resent-To: aperson@example.com @@ -166,7 +166,7 @@ Other headers checked for recipients include the ``To``... >>> msgdata = recips.copy() >>> handler.process(mlist, msg, msgdata) >>> sorted(msgdata['recipients']) - [u'bperson@example.com'] + ['bperson@example.com'] >>> print(msg.as_string()) From: Claire Person Resent-Cc: aperson@example.com diff --git a/src/mailman/handlers/docs/file-recips.rst b/src/mailman/handlers/docs/file-recips.rst index 58af6f480..73b47adb1 100644 --- a/src/mailman/handlers/docs/file-recips.rst +++ b/src/mailman/handlers/docs/file-recips.rst @@ -34,26 +34,6 @@ returns. recipients: 7 -Missing file -============ - -The include file must live inside the list's data directory, under the name -``members.txt``. If the file doesn't exist, the list of recipients will be -empty. - - >>> import os - >>> file_path = os.path.join(mlist.data_path, 'members.txt') - >>> open(file_path) - Traceback (most recent call last): - ... - IOError: [Errno ...] - No such file or directory: u'.../_xtest@example.com/members.txt' - >>> msgdata = {} - >>> handler.process(mlist, msg, msgdata) - >>> dump_list(msgdata['recipients']) - *Empty* - - Existing file ============= @@ -61,16 +41,15 @@ If the file exists, it contains a list of addresses, one per line. These addresses are returned as the set of recipients. :: - >>> fp = open(file_path, 'w') - >>> try: + >>> import os + >>> file_path = os.path.join(mlist.data_path, 'members.txt') + >>> with open(file_path, 'w', encoding='utf-8') as fp: ... print('bperson@example.com', file=fp) ... print('cperson@example.com', file=fp) ... print('dperson@example.com', file=fp) ... print('eperson@example.com', file=fp) ... print('fperson@example.com', file=fp) ... print('gperson@example.com', file=fp) - ... finally: - ... fp.close() >>> msgdata = {} >>> handler.process(mlist, msg, msgdata) diff --git a/src/mailman/handlers/docs/filtering.rst b/src/mailman/handlers/docs/filtering.rst index 6c3735f1b..6673933ad 100644 --- a/src/mailman/handlers/docs/filtering.rst +++ b/src/mailman/handlers/docs/filtering.rst @@ -26,6 +26,8 @@ Filtering the outer content type A simple filtering setting will just search the content types of the messages parts, discarding all parts with a matching MIME type. If the message's outer content type matches the filter, the entire message will be discarded. +However, if we turn off content filtering altogether, then the handler +short-circuits. :: >>> from mailman.interfaces.mime import FilterAction @@ -42,14 +44,6 @@ content type matches the filter, the entire message will be discarded. ... """) >>> process = config.handlers['mime-delete'].process - >>> process(mlist, msg, {}) - Traceback (most recent call last): - ... - DiscardMessage: The message's content type was explicitly disallowed - -However, if we turn off content filtering altogether, then the handler -short-circuits. - >>> mlist.filter_content = False >>> msgdata = {} >>> process(mlist, msg, msgdata) @@ -74,15 +68,15 @@ crafted internally by Mailman. MIME-Version: 1.0 xxxxx - >>> msgdata - {u'isdigest': True} + >>> dump_msgdata(msgdata) + isdigest: True Simple multipart filtering ========================== -If one of the subparts in a multipart message matches the filter type, then -just that subpart will be stripped. +If one of the subparts in a ``multipart`` message matches the filter type, +then just that subpart will be stripped. :: >>> msg = message_from_string("""\ diff --git a/src/mailman/handlers/docs/nntp.rst b/src/mailman/handlers/docs/nntp.rst index 2dfc95ce1..72bcb35f0 100644 --- a/src/mailman/handlers/docs/nntp.rst +++ b/src/mailman/handlers/docs/nntp.rst @@ -63,5 +63,5 @@ messages are gated to. >>> dump_msgdata(messages[0].msgdata) _parsemsg: False - listname : test@example.com + listid : test.example.com version : 3 diff --git a/src/mailman/handlers/docs/replybot.rst b/src/mailman/handlers/docs/replybot.rst index 638c2fdc8..9e18ce911 100644 --- a/src/mailman/handlers/docs/replybot.rst +++ b/src/mailman/handlers/docs/replybot.rst @@ -49,9 +49,9 @@ response. >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : _xtest@example.com + listid : _xtest.example.com nodecorate : True - recipients : set([u'aperson@example.com']) + recipients : {'aperson@example.com'} reduced_list_headers: True version : 3 @@ -141,9 +141,9 @@ Unless the ``X-Ack:`` header has a value of ``yes``, in which case, the >>> dump_msgdata(messages[0].msgdata) _parsemsg : False - listname : _xtest@example.com + listid : _xtest.example.com nodecorate : True - recipients : set([u'asystem@example.com']) + recipients : {'asystem@example.com'} reduced_list_headers: True version : 3 diff --git a/src/mailman/handlers/docs/rfc-2369.rst b/src/mailman/handlers/docs/rfc-2369.rst index 8180b0635..b5a783edc 100644 --- a/src/mailman/handlers/docs/rfc-2369.rst +++ b/src/mailman/handlers/docs/rfc-2369.rst @@ -13,7 +13,7 @@ headers generally start with the `List-` prefix. .. This is a helper function for the following section. >>> def list_headers(msg, only=None): - ... if isinstance(only, basestring): + ... if isinstance(only, str): ... only = (only.lower(),) ... elif only is None: ... only = set(header.lower() for header in msg.keys() diff --git a/src/mailman/handlers/docs/subject-munging.rst b/src/mailman/handlers/docs/subject-munging.rst index 072e80d17..6f70a9d5e 100644 --- a/src/mailman/handlers/docs/subject-munging.rst +++ b/src/mailman/handlers/docs/subject-munging.rst @@ -35,7 +35,7 @@ subject munging, a mailing list must have a preferred language. The original subject header is stored in the message metadata. >>> msgdata['original_subject'] - u'' + '' >>> print(msg['subject']) [XTest] (no subject) diff --git a/src/mailman/handlers/docs/tagger.rst b/src/mailman/handlers/docs/tagger.rst index f3303b7ef..fcefdb01c 100644 --- a/src/mailman/handlers/docs/tagger.rst +++ b/src/mailman/handlers/docs/tagger.rst @@ -55,7 +55,7 @@ and the message metadata gets a key with a list of matching topic names. >>> msgdata['topichits'] - [u'bar fight'] + ['bar fight'] Scanning body lines @@ -114,7 +114,7 @@ found. Keywords: barbaz >>> msgdata['topichits'] - [u'bar fight'] + ['bar fight'] However, scanning stops at the first body line that doesn't look like a header. @@ -161,7 +161,7 @@ When set to a negative number, all body lines will be scanned. >>> print(msg['x-topics']) bar fight >>> msgdata['topichits'] - [u'bar fight'] + ['bar fight'] Scanning sub-parts @@ -175,14 +175,14 @@ text payload. ... Subject: Was ... Keywords: Raw ... Content-Type: multipart/alternative; boundary="BOUNDARY" - ... + ... ... --BOUNDARY ... From: sabo ... To: obas - ... + ... ... Subject: farbaw ... Keywords: barbaz - ... + ... ... --BOUNDARY-- ... """) >>> msgdata = {} @@ -203,7 +203,7 @@ text payload. --BOUNDARY-- >>> msgdata['topichits'] - [u'bar fight'] + ['bar fight'] But the tagger will not descend into non-text parts. @@ -211,23 +211,23 @@ But the tagger will not descend into non-text parts. ... Subject: Was ... Keywords: Raw ... Content-Type: multipart/alternative; boundary=BOUNDARY - ... + ... ... --BOUNDARY ... From: sabo ... To: obas ... Content-Type: message/rfc822 - ... + ... ... Subject: farbaw ... Keywords: barbaz - ... + ... ... --BOUNDARY ... From: sabo ... To: obas ... Content-Type: message/rfc822 - ... + ... ... Subject: farbaw ... Keywords: barbaz - ... + ... ... --BOUNDARY-- ... """) >>> msgdata = {} diff --git a/src/mailman/handlers/docs/to-outgoing.rst b/src/mailman/handlers/docs/to-outgoing.rst index e87fd4f26..90ea137a5 100644 --- a/src/mailman/handlers/docs/to-outgoing.rst +++ b/src/mailman/handlers/docs/to-outgoing.rst @@ -37,6 +37,6 @@ additional key set: the mailing list name. _parsemsg: False bar : 2 foo : 1 - listname : test@example.com + listid : test.example.com verp : True version : 3 diff --git a/src/mailman/handlers/mime_delete.py b/src/mailman/handlers/mime_delete.py index 98c1de3f9..b5c937fdb 100644 --- a/src/mailman/handlers/mime_delete.py +++ b/src/mailman/handlers/mime_delete.py @@ -245,7 +245,7 @@ def to_plaintext(msg): filename = tempfile.mktemp('.html') fp = open(filename, 'w') try: - fp.write(subpart.get_payload(decode=True)) + fp.write(subpart.get_payload()) fp.close() cmd = os.popen(config.HTML_TO_PLAIN_TEXT_COMMAND % {'filename': filename}) diff --git a/src/mailman/handlers/tagger.py b/src/mailman/handlers/tagger.py index 803cc6d11..51ff6b39e 100644 --- a/src/mailman/handlers/tagger.py +++ b/src/mailman/handlers/tagger.py @@ -37,7 +37,7 @@ from mailman.interfaces.handler import IHandler OR = '|' CRNL = '\r\n' -EMPTYBYTES = b'' +EMPTYSTRING = '' NLTAB = '\n\t' @@ -104,7 +104,7 @@ def scanbody(msg, numlines=None): reader = list(email.iterators.body_line_iterator(msg)) while numlines is None or lineno < numlines: try: - line = bytes(reader.pop(0)) + line = reader.pop(0) except IndexError: break # Blank lines don't count @@ -115,7 +115,7 @@ def scanbody(msg, numlines=None): # Concatenate those body text lines with newlines, and then create a new # message object from those lines. p = _ForgivingParser() - msg = p.parsestr(EMPTYBYTES.join(lines)) + msg = p.parsestr(EMPTYSTRING.join(lines)) return msg.get_all('subject', []) + msg.get_all('keywords', []) diff --git a/src/mailman/handlers/tests/test_file_recips.py b/src/mailman/handlers/tests/test_file_recips.py new file mode 100644 index 000000000..9f3e0ec6e --- /dev/null +++ b/src/mailman/handlers/tests/test_file_recips.py @@ -0,0 +1,76 @@ +# Copyright (C) 2014 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see . + +"""Test file-recips handler.""" + +from __future__ import absolute_import, print_function, unicode_literals + +__metaclass__ = type +__all__ = [ + 'TestFileRecips', + ] + + +import os +import unittest + +from mailman.app.lifecycle import create_list +from mailman.config import config +from mailman.testing.helpers import specialized_message_from_string as mfs +from mailman.testing.layers import ConfigLayer + + + +class TestFileRecips(unittest.TestCase): + layer = ConfigLayer + + def setUp(self): + self._mlist = create_list('test@example.com') + self._handler = config.handlers['file-recipients'].process + self._msg = mfs("""\ +From: aperson@example.com + +A message. +""") + + def test_file_is_missing(self): + # It is not an error for the list's the members.txt file to be + # missing. The missing file is just ignored. + msgdata = {} + self._handler(self._mlist, self._msg, msgdata) + self.assertEqual(msgdata['recipients'], set()) + + def test_file_exists(self): + # Like above, but the file exists and contains recipients. + path = os.path.join(self._mlist.data_path, 'members.txt') + with open(path, 'w', encoding='utf-8') as fp: + print('bperson@example.com', file=fp) + print('cperson@example.com', file=fp) + print('dperson@example.com', file=fp) + print('eperson@example.com', file=fp) + print('fperson@example.com', file=fp) + print('gperson@example.com', file=fp) + msgdata = {} + self._handler(self._mlist, self._msg, msgdata) + self.assertEqual(msgdata['recipients'], set(( + 'bperson@example.com', + 'cperson@example.com', + 'dperson@example.com', + 'eperson@example.com', + 'fperson@example.com', + 'gperson@example.com', + ))) diff --git a/src/mailman/handlers/tests/test_filter.py b/src/mailman/handlers/tests/test_filter.py new file mode 100644 index 000000000..292e646cd --- /dev/null +++ b/src/mailman/handlers/tests/test_filter.py @@ -0,0 +1,60 @@ +# Copyright (C) 2014 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see . + +"""Test the filter handler.""" + +from __future__ import absolute_import, print_function, unicode_literals + +__metaclass__ = type +__all__ = [ + 'TestFilters', + ] + + +import unittest + +from mailman.app.lifecycle import create_list +from mailman.config import config +from mailman.core.errors import DiscardMessage +from mailman.interfaces.mime import FilterAction +from mailman.testing.helpers import specialized_message_from_string as mfs +from mailman.testing.layers import ConfigLayer + + + +class TestFilters(unittest.TestCase): + layer = ConfigLayer + + def setUp(self): + self._mlist = create_list('test@example.com') + + def test_discard_when_outer_type_matches(self): + # When the outer MIME type of the message matches a filter type, the + # entire message is discarded. + self._mlist.filter_content = True + self._mlist.filter_types = ['image/jpeg'] + self._mlist.filter_action = FilterAction.discard + msg = mfs("""\ +From: aperson@example.com +Content-Type: image/jpeg +MIME-Version: 1.0 + +xxxxx +""") + self.assertRaises(DiscardMessage, + config.handlers['mime-delete'].process, + self._mlist, msg, {}) diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index 882e69cd9..5bfac20ee 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -471,10 +471,11 @@ def reset_the_world(): """ # Reset the database between tests. config.db._reset() - # Remove any digest files. + # Remove any digest files and members.txt file (for the file-recips + # handler) in the lists' data directories. for dirpath, dirnames, filenames in os.walk(config.LIST_DATA_DIR): for filename in filenames: - if filename.endswith('.mmdf'): + if filename.endswith('.mmdf') or filename == 'members.txt': os.remove(os.path.join(dirpath, filename)) # Remove all residual queue files. for dirpath, dirnames, filenames in os.walk(config.QUEUE_DIR): -- cgit v1.2.3-70-g09d2 From 40c50483989c6141a528d2c3e1b5830b89a96e5e Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 15 Dec 2014 20:43:57 -0500 Subject: Core tests pass. --- src/mailman/app/tests/test_inject.py | 8 ++++---- src/mailman/chains/headers.py | 2 +- src/mailman/commands/docs/unshunt.rst | 2 +- src/mailman/core/docs/runner.rst | 4 ++-- src/mailman/core/tests/test_runner.py | 2 +- src/mailman/handlers/docs/filtering.rst | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/app/tests/test_inject.py b/src/mailman/app/tests/test_inject.py index 3bfafadf8..23abc6943 100644 --- a/src/mailman/app/tests/test_inject.py +++ b/src/mailman/app/tests/test_inject.py @@ -64,7 +64,7 @@ Nothing. self.assertEqual(len(items), 1) self.assertMultiLineEqual(items[0].msg.as_string(), self.msg.as_string()) - self.assertEqual(items[0].msgdata['listname'], 'test@example.com') + self.assertEqual(items[0].msgdata['listid'], 'test.example.com') self.assertEqual(items[0].msgdata['original_size'], len(self.msg.as_string())) @@ -84,7 +84,7 @@ Nothing. self.assertEqual(len(items), 1) self.assertMultiLineEqual(items[0].msg.as_string(), self.msg.as_string()) - self.assertEqual(items[0].msgdata['listname'], 'test@example.com') + self.assertEqual(items[0].msgdata['listid'], 'test.example.com') self.assertEqual(items[0].msgdata['original_size'], len(self.msg.as_string())) @@ -171,7 +171,7 @@ Nothing. # Delete that header because it is not in the original text. del items[0].msg['x-message-id-hash'] self.assertMultiLineEqual(items[0].msg.as_string(), self.text) - self.assertEqual(items[0].msgdata['listname'], 'test@example.com') + self.assertEqual(items[0].msgdata['listid'], 'test.example.com') self.assertEqual(items[0].msgdata['original_size'], # Add back the X-Message-ID-Header which was in the # message contributing to the original_size, but @@ -196,7 +196,7 @@ Nothing. # Remove the X-Message-ID-Hash header which isn't in the original text. del items[0].msg['x-message-id-hash'] self.assertMultiLineEqual(items[0].msg.as_string(), self.text) - self.assertEqual(items[0].msgdata['listname'], 'test@example.com') + self.assertEqual(items[0].msgdata['listid'], 'test.example.com') self.assertEqual(items[0].msgdata['original_size'], # Add back the X-Message-ID-Header which was in the # message contributing to the original_size, but diff --git a/src/mailman/chains/headers.py b/src/mailman/chains/headers.py index 7628c8b7c..b37079f7f 100644 --- a/src/mailman/chains/headers.py +++ b/src/mailman/chains/headers.py @@ -122,7 +122,7 @@ class HeaderMatchChain(Chain): """See `IMutableChain`.""" # Remove all dynamically created rules. Use the keys so we can mutate # the dictionary inside the loop. - for rule_name in config.rules.keys(): + for rule_name in list(config.rules): if rule_name.startswith('header-match-'): del config.rules[rule_name] self._extended_links = [] diff --git a/src/mailman/commands/docs/unshunt.rst b/src/mailman/commands/docs/unshunt.rst index 93d89f001..9532ae029 100644 --- a/src/mailman/commands/docs/unshunt.rst +++ b/src/mailman/commands/docs/unshunt.rst @@ -83,7 +83,7 @@ queue. 2 >>> sorted(item.msg['message-id'] for item in items) - [u'', u''] + ['', ''] Return to the original queue diff --git a/src/mailman/core/docs/runner.rst b/src/mailman/core/docs/runner.rst index 865635310..11a771fe8 100644 --- a/src/mailman/core/docs/runner.rst +++ b/src/mailman/core/docs/runner.rst @@ -55,7 +55,7 @@ on instance variables. ... A test message. ... """) >>> switchboard = config.switchboards['test'] - >>> filebase = switchboard.enqueue(msg, list_id=mlist.list_id, + >>> filebase = switchboard.enqueue(msg, listid=mlist.list_id, ... foo='yes', bar='no') >>> runner.run() >>> print(runner.msg.as_string()) @@ -69,7 +69,7 @@ on instance variables. bar : no foo : yes lang : en - listname : test@example.com + listid : test.example.com version : 3 XXX More of the Runner API should be tested. diff --git a/src/mailman/core/tests/test_runner.py b/src/mailman/core/tests/test_runner.py index a48925b4c..66111234e 100644 --- a/src/mailman/core/tests/test_runner.py +++ b/src/mailman/core/tests/test_runner.py @@ -79,7 +79,7 @@ Message-ID: self.assertTrue(isinstance(event, RunnerCrashEvent)) self.assertEqual(event.mailing_list, self._mlist) self.assertEqual(event.message['message-id'], '') - self.assertEqual(event.metadata['listname'], 'test@example.com') + self.assertEqual(event.metadata['listid'], 'test.example.com') self.assertTrue(isinstance(event.error, RuntimeError)) self.assertEqual(str(event.error), 'borked') self.assertTrue(isinstance(event.runner, CrashingRunner)) diff --git a/src/mailman/handlers/docs/filtering.rst b/src/mailman/handlers/docs/filtering.rst index 6673933ad..582211d54 100644 --- a/src/mailman/handlers/docs/filtering.rst +++ b/src/mailman/handlers/docs/filtering.rst @@ -235,8 +235,8 @@ name of the file containing the message payload to filter. >>> try: ... print("""\ ... import sys - ... print 'Converted text/html to text/plain' - ... print 'Filename:', sys.argv[1] + ... print('Converted text/html to text/plain') + ... print('Filename:', sys.argv[1]) ... """, file=fp) ... finally: ... fp.close() -- cgit v1.2.3-70-g09d2 From 94247b82d1c030eac9be3eb4c461f830a99c2f63 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 15 Dec 2014 22:09:42 -0500 Subject: Pass all command tests. --- src/mailman/commands/docs/members.rst | 2 +- src/mailman/commands/docs/qfile.rst | 6 +----- src/mailman/handlers/acknowledge.py | 3 +-- src/mailman/utilities/importer.py | 2 +- 4 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/commands/docs/members.rst b/src/mailman/commands/docs/members.rst index 5ec1521a5..28f238f31 100644 --- a/src/mailman/commands/docs/members.rst +++ b/src/mailman/commands/docs/members.rst @@ -236,7 +236,7 @@ taken from standard input. ... 'fperson@example.com (Fred Person)', ... ): ... print(address, file=fp) - >>> fp.seek(0) + >>> filepos = fp.seek(0) >>> import sys >>> sys.stdin = fp diff --git a/src/mailman/commands/docs/qfile.rst b/src/mailman/commands/docs/qfile.rst index f4732e3be..e097ebf97 100644 --- a/src/mailman/commands/docs/qfile.rst +++ b/src/mailman/commands/docs/qfile.rst @@ -54,11 +54,7 @@ Once we've figured out the file name of the shunted message, we can print it. I borkeded Mailman. <----- start object 2 -----> - { '_parsemsg': False, - 'bad': 'yes', - 'bar': 'baz', - 'foo': 7, - 'version': 3} + {'_parsemsg': False, 'bad': 'yes', 'bar': 'baz', 'foo': 7, 'version': 3} [----- end pickle -----] Maybe we don't want to print the contents of the file though, in case we want diff --git a/src/mailman/handlers/acknowledge.py b/src/mailman/handlers/acknowledge.py index c3af9ab27..bd8b8861d 100644 --- a/src/mailman/handlers/acknowledge.py +++ b/src/mailman/handlers/acknowledge.py @@ -67,14 +67,13 @@ class Acknowledge: language = (language_manager[msgdata['lang']] if 'lang' in msgdata else member.preferred_language) - charset = language_manager[language.code].charset # Now get the acknowledgement template. display_name = mlist.display_name text = make('postack.txt', mailing_list=mlist, language=language.code, wrap=False, - subject=oneline(original_subject, charset), + subject=oneline(original_subject, in_unicode=True), list_name=mlist.list_name, display_name=display_name, listinfo_url=mlist.script_url('listinfo'), diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py index b2c15e6f8..e6e51ef64 100644 --- a/src/mailman/utilities/importer.py +++ b/src/mailman/utilities/importer.py @@ -384,7 +384,7 @@ def import_config_pck(mlist, config_dict): # Import rosters. regulars_set = set(config_dict.get('members', {})) digesters_set = set(config_dict.get('digest_members', {})) - members = regulars_set + digesters_set + members = regulars_set.union(digesters_set) import_roster(mlist, config_dict, members, MemberRole.member) import_roster(mlist, config_dict, config_dict.get('owner', []), MemberRole.owner) -- cgit v1.2.3-70-g09d2 From 0274a755a4657bbec652fec29bd868a632eb6c07 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 17 Dec 2014 22:08:22 -0500 Subject: Fix subject-munging.rst --- src/mailman/handlers/docs/subject-munging.rst | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/handlers/docs/subject-munging.rst b/src/mailman/handlers/docs/subject-munging.rst index 6f70a9d5e..b51fedebd 100644 --- a/src/mailman/handlers/docs/subject-munging.rst +++ b/src/mailman/handlers/docs/subject-munging.rst @@ -122,10 +122,10 @@ set than the encoded header. ... ... """) >>> process(mlist, msg, {}) - >>> print(msg['subject']) + >>> print(msg['subject'].encode()) [XTest] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= - >>> msg['subject'].decode('utf-8') - u'[XTest] \u30e1\u30fc\u30eb\u30de\u30f3' + >>> print(msg['subject']) + [XTest] メールマン Prefix numbers @@ -178,10 +178,10 @@ in the subject prefix, and the subject is encoded non-ASCII. ... ... """) >>> process(mlist, msg, {}) - >>> print(msg['subject']) + >>> print(msg['subject'].encode()) [XTest 456] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= - >>> msg['subject'].decode('utf-8') - u'[XTest 456] \u30e1\u30fc\u30eb\u30de\u30f3' + >>> print(msg['subject']) + [XTest 456] メールマン Even more fun is when the internationalized ``Subject`` header already has a prefix, possibly with a different posting number. @@ -191,11 +191,10 @@ prefix, possibly with a different posting number. ... ... """) >>> process(mlist, msg, {}) - >>> print(msg['subject']) + >>> print(msg['subject'].encode()) [XTest 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= - - >>> msg['subject'].decode('utf-8') - u'[XTest 456] Re: \u30e1\u30fc\u30eb\u30de\u30f3' + >>> print(msg['subject']) + [XTest 456] Re: メールマン As before, old style subject prefixes are re-ordered. @@ -204,12 +203,11 @@ As before, old style subject prefixes are re-ordered. ... ... """) >>> process(mlist, msg, {}) - >>> print(msg['subject']) + >>> print(msg['subject'].encode()) [XTest 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= - - >>> msg['subject'].decode('utf-8') - u'[XTest 456] Re: \u30e1\u30fc\u30eb\u30de\u30f3' + >>> print(msg['subject']) + [XTest 456] Re: メールマン In this test case, we get an extra space between the prefix and the original -- cgit v1.2.3-70-g09d2 From d53efd9675aba93ececf45952eb8df1286610e50 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Thu, 18 Dec 2014 11:41:04 -0500 Subject: Fix the digest.rst doctest. --- src/mailman/handlers/docs/digests.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/mailman/handlers') diff --git a/src/mailman/handlers/docs/digests.rst b/src/mailman/handlers/docs/digests.rst index ac6ea33d6..c3fc62ebf 100644 --- a/src/mailman/handlers/docs/digests.rst +++ b/src/mailman/handlers/docs/digests.rst @@ -82,11 +82,13 @@ actually crafted by the handler. >>> mlist.digest_size_threshold = 1 >>> mlist.volume = 2 >>> mlist.next_digest_number = 10 + >>> digest_path = os.path.join(mlist.data_path, 'digest.mmdf') >>> size = 0 >>> for msg in message_factory: ... process(mlist, msg, {}) - ... size += len(str(msg)) - ... if size >= mlist.digest_size_threshold * 1024: + ... # When the digest reaches the proper size, it is renamed. So we + ... # can break out of this list when the file disappears. + ... if not os.path.exists(digest_path): ... break >>> sum(1 for msg in digest_mbox(mlist)) -- cgit v1.2.3-70-g09d2 From ca6384a1ad92c24ed0bc8cfe1559cdd45209e9a7 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Sun, 21 Dec 2014 16:23:49 -0500 Subject: Refactor subject-prefix handler out of cook-headers handler and make all tests pass. --- src/mailman/app/docs/pipelines.rst | 8 +- src/mailman/core/pipelines.py | 1 + src/mailman/handlers/cook_headers.py | 118 +------------- src/mailman/handlers/docs/subject-munging.rst | 81 ++++------ src/mailman/handlers/subject_prefix.py | 187 ++++++++++++++++++++++ src/mailman/handlers/tests/test_subject_prefix.py | 132 +++++++++++++++ src/mailman/runners/nntp.py | 6 +- 7 files changed, 356 insertions(+), 177 deletions(-) create mode 100644 src/mailman/handlers/subject_prefix.py create mode 100644 src/mailman/handlers/tests/test_subject_prefix.py (limited to 'src/mailman/handlers') diff --git a/src/mailman/app/docs/pipelines.rst b/src/mailman/app/docs/pipelines.rst index daedab50a..dfdc6d70c 100644 --- a/src/mailman/app/docs/pipelines.rst +++ b/src/mailman/app/docs/pipelines.rst @@ -45,9 +45,9 @@ etc. To: test@example.com Message-ID: X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB - Subject: [Test] My first post X-Mailman-Version: ... Precedence: list + Subject: [Test] My first post List-Id: Archived-At: http://lists.example.com/.../4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB List-Archive: @@ -84,9 +84,9 @@ processing queues. To: test@example.com Message-ID: X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB - Subject: [Test] My first post X-Mailman-Version: ... Precedence: list + Subject: [Test] My first post List-Id: ... @@ -121,9 +121,9 @@ delivered to end recipients. To: test@example.com Message-ID: X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB - Subject: [Test] My first post X-Mailman-Version: ... Precedence: list + Subject: [Test] My first post List-Id: ... @@ -152,9 +152,9 @@ There's now one message in the digest mailbox, getting ready to be sent. To: test@example.com Message-ID: X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB - Subject: [Test] My first post X-Mailman-Version: ... Precedence: list + Subject: [Test] My first post List-Id: ... diff --git a/src/mailman/core/pipelines.py b/src/mailman/core/pipelines.py index e164169a4..5fdba8358 100644 --- a/src/mailman/core/pipelines.py +++ b/src/mailman/core/pipelines.py @@ -120,6 +120,7 @@ class PostingPipeline(BasePipeline): 'cleanse', 'cleanse-dkim', 'cook-headers', + 'subject-prefix', 'rfc-2369', 'to-archive', 'to-digest', diff --git a/src/mailman/handlers/cook_headers.py b/src/mailman/handlers/cook_headers.py index 1ab527bb4..f37e8f0e2 100644 --- a/src/mailman/handlers/cook_headers.py +++ b/src/mailman/handlers/cook_headers.py @@ -27,8 +27,7 @@ __all__ = [ import re -from email.errors import HeaderParseError -from email.header import Header, decode_header, make_header +from email.header import Header from email.utils import parseaddr, formataddr, getaddresses from zope.interface import implementer @@ -78,13 +77,6 @@ def process(mlist, msg, msgdata): msgdata['original_sender'] = msg.sender # VirginRunner sets _fasttrack for internally crafted messages. fasttrack = msgdata.get('_fasttrack') - if not msgdata.get('isdigest') and not fasttrack: - try: - prefix_subject(mlist, msg, msgdata) - except (UnicodeError, ValueError): - # TK: Sometimes subject header is not MIME encoded for 8bit - # simply abort prefixing. - pass # Add Precedence: and other useful headers. None of these are standard # and finding information on some of them are fairly difficult. Some are # just common practice, and we'll add more here as they become necessary. @@ -170,114 +162,6 @@ def process(mlist, msg, msgdata): msg['Cc'] = COMMASPACE.join([formataddr(pair) for pair in new]) - -def prefix_subject(mlist, msg, msgdata): - """Maybe add a subject prefix. - - Add the subject prefix unless the message is a digest or is being fast - tracked (e.g. internally crafted, delivered to a single user such as the - list admin). - """ - if not mlist.subject_prefix.strip(): - return - prefix = mlist.subject_prefix - subject = msg.get('subject', '') - # Try to figure out what the continuation_ws is for the header - if isinstance(subject, Header): - lines = str(subject).splitlines() - else: - lines = subject.splitlines() - ws = '\t' - if len(lines) > 1 and lines[1] and lines[1][0] in ' \t': - ws = lines[1][0] - msgdata['original_subject'] = subject - # The subject may be multilingual but we take the first charset as major - # one and try to decode. If it is decodable, returned subject is in one - # line and cset is properly set. If fail, subject is mime-encoded and - # cset is set as us-ascii. See detail for ch_oneline() (CookHeaders one - # line function). - subject, cset = ch_oneline(subject) - # TK: Python interpreter has evolved to be strict on ascii charset code - # range. It is safe to use unicode string when manupilating header - # contents with re module. It would be best to return unicode in - # ch_oneline() but here is temporary solution. - subject = subject.decode(cset) - # If the subject_prefix contains '%d', it is replaced with the - # mailing list sequential number. Sequential number format allows - # '%d' or '%05d' like pattern. - prefix_pattern = re.escape(prefix) - # unescape '%' :-< - prefix_pattern = '%'.join(prefix_pattern.split(r'\%')) - p = re.compile('%\d*d') - if p.search(prefix, 1): - # prefix have number, so we should search prefix w/number in subject. - # Also, force new style. - prefix_pattern = p.sub(r'\s*\d+\s*', prefix_pattern) - subject = re.sub(prefix_pattern, '', subject) - rematch = re.match('((RE|AW|SV|VS)(\[\d+\])?:\s*)+', subject, re.I) - if rematch: - subject = subject[rematch.end():] - recolon = 'Re:' - else: - recolon = '' - # At this point, subject may become null if someone post mail with - # subject: [subject prefix] - if subject.strip() == '': - subject = _('(no subject)') - cset = mlist.preferred_language.charset - # and substitute %d in prefix with post_id - try: - prefix = prefix % mlist.post_id - except TypeError: - pass - # Get the header as a Header instance, with proper unicode conversion - if not recolon: - h = uheader(mlist, prefix, 'Subject', continuation_ws=ws) - else: - h = uheader(mlist, prefix, 'Subject', continuation_ws=ws) - h.append(recolon) - # TK: Subject is concatenated and unicode string. - subject = subject.encode(cset, 'replace') - h.append(subject, cset) - del msg['subject'] - msg['Subject'] = h - ss = uheader(mlist, recolon, 'Subject', continuation_ws=ws) - ss.append(subject, cset) - msgdata['stripped_subject'] = ss - - - -def ch_oneline(headerstr): - # Decode header string in one line and convert into single charset. - # Return (string, cset) tuple as check for failure. - try: - d = decode_header(headerstr) - # At this point, we should rstrip() every string because some - # MUA deliberately add trailing spaces when composing return - # message. - d = [(s.rstrip(), c) for (s, c) in d] - # Find all charsets in the original header. We use 'utf-8' rather - # than using the first charset (in mailman 2.1.x) if multiple - # charsets are used. - csets = [] - for (s, c) in d: - if c and c not in csets: - csets.append(c) - if len(csets) == 0: - cset = 'us-ascii' - elif len(csets) == 1: - cset = csets[0] - else: - cset = 'utf-8' - h = make_header(d) - ustr = str(h) - oneline = ''.join(ustr.splitlines()) - return oneline.encode(cset, 'replace'), cset - except (LookupError, UnicodeError, ValueError, HeaderParseError): - # possibly charset problem. return with undecoded string in one line. - return ''.join(headerstr.splitlines()), 'us-ascii' - - @implementer(IHandler) class CookHeaders: diff --git a/src/mailman/handlers/docs/subject-munging.rst b/src/mailman/handlers/docs/subject-munging.rst index b51fedebd..de22a928c 100644 --- a/src/mailman/handlers/docs/subject-munging.rst +++ b/src/mailman/handlers/docs/subject-munging.rst @@ -1,44 +1,42 @@ -=============== -Subject munging -=============== +================ +Subject prefixes +================ -Messages that flow through the global pipeline get their headers *cooked*, -which basically means that their headers go through several mostly unrelated -transformations. Some headers get added, others get changed. Some of these -changes depend on mailing list settings and others depend on how the message -is getting sent through the system. We'll take things one-by-one. +Mailing lists can define a *subject prefix* which gets added to the front of +any ``Subject`` text. This can be used to quickly identify which mailing list +the message was posted to. >>> mlist = create_list('test@example.com') +The default list style gives the mailing list a default prefix. -Inserting a prefix -================== + >>> print(mlist.subject_prefix) + [Test] -Another thing header cooking does is *munge* the ``Subject`` header by -inserting the subject prefix for the list at the front. If there's no subject -header in the original message, Mailman uses a canned default. In order to do -subject munging, a mailing list must have a preferred language. -:: +This can be changed to anything, but typically ends with a trailing space. >>> mlist.subject_prefix = '[XTest] ' - >>> mlist.preferred_language = 'en' + >>> process = config.handlers['subject-prefix'].process + + +No Subject +========== + +If the original message has no ``Subject``, then a canned one is used. + >>> msg = message_from_string("""\ ... From: aperson@example.com ... ... A message of great import. ... """) - >>> msgdata = {} - - >>> from mailman.handlers.cook_headers import process - >>> process(mlist, msg, msgdata) - -The original subject header is stored in the message metadata. - - >>> msgdata['original_subject'] - '' + >>> process(mlist, msg, {}) >>> print(msg['subject']) [XTest] (no subject) + +Inserting a prefix +================== + If the original message had a ``Subject`` header, then the prefix is inserted at the beginning of the header's value. @@ -50,34 +48,12 @@ at the beginning of the header's value. ... """) >>> msgdata = {} >>> process(mlist, msg, msgdata) - >>> print(msgdata['original_subject']) - Something important >>> print(msg['subject']) [XTest] Something important -``Subject`` headers are not munged for digest messages. - - >>> msg = message_from_string("""\ - ... From: aperson@example.com - ... Subject: Something important - ... - ... A message of great import. - ... """) - >>> process(mlist, msg, dict(isdigest=True)) - >>> print(msg['subject']) - Something important +The original ``Subject`` is available in the metadata. -Nor are they munged for *fast tracked* messages, which are generally defined -as messages that Mailman crafts internally. - - >>> msg = message_from_string("""\ - ... From: aperson@example.com - ... Subject: Something important - ... - ... A message of great import. - ... """) - >>> process(mlist, msg, dict(_fasttrack=True)) - >>> print(msg['subject']) + >>> print(msgdata['original_subject']) Something important If a ``Subject`` header already has a prefix, usually following a ``Re:`` @@ -95,8 +71,7 @@ front of the header text. [XTest] Re: Something important If the ``Subject`` header has a prefix at the front of the header text, that's -where it will stay. This is called *new style* prefixing and is the only -option available in Mailman 3. +where it will stay. >>> msg = message_from_string("""\ ... From: aperson@example.com @@ -124,7 +99,7 @@ set than the encoded header. >>> process(mlist, msg, {}) >>> print(msg['subject'].encode()) [XTest] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= - >>> print(msg['subject']) + >>> print(str(msg['subject'])) [XTest] メールマン @@ -194,7 +169,7 @@ prefix, possibly with a different posting number. >>> print(msg['subject'].encode()) [XTest 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?= >>> print(msg['subject']) - [XTest 456] Re: メールマン + [XTest 456] Re: メールマン As before, old style subject prefixes are re-ordered. diff --git a/src/mailman/handlers/subject_prefix.py b/src/mailman/handlers/subject_prefix.py new file mode 100644 index 000000000..ee1921ac2 --- /dev/null +++ b/src/mailman/handlers/subject_prefix.py @@ -0,0 +1,187 @@ +# Copyright (C) 2014 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see . + +"""Subject header prefix munging.""" + +from __future__ import absolute_import, print_function, unicode_literals + +__metaclass__ = type +__all__ = [ + 'SubjectPrefix', + ] + + +import re + +from email.header import Header, make_header, decode_header +from mailman.core.i18n import _ +from mailman.interfaces.handler import IHandler +from zope.interface import implementer + + +RE_PATTERN = '((RE|AW|SV|VS)(\[\d+\])?:\s*)+' +ASCII_CHARSETS = (None, 'ascii', 'us-ascii') +EMPTYSTRING = '' + + + +def ascii_header(mlist, msgdata, subject, prefix, prefix_pattern, ws): + if mlist.preferred_language.charset not in ASCII_CHARSETS: + return None + for chunk, charset in decode_header(subject.encode()): + if charset not in ASCII_CHARSETS: + return None + subject_text = EMPTYSTRING.join(str(subject).splitlines()) + rematch = re.match(RE_PATTERN, subject_text, re.I) + if rematch: + subject_text = subject_text[rematch.end():] + recolon = 'Re: ' + else: + recolon = '' + # At this point, the subject may become null if someone posted mail + # with "Subject: [subject prefix]". + if subject_text.strip() == '': + with _.using(mlist.preferred_language.code): + subject_text = _('(no subject)') + else: + subject_text = re.sub(prefix_pattern, '', subject_text) + msgdata['stripped_subject'] = subject_text + lines = subject_text.splitlines() + first_line = [lines[0]] + if recolon: + first_line.insert(0, recolon) + if prefix: + first_line.insert(0, prefix) + subject_text = EMPTYSTRING.join(first_line) + return Header(subject_text, continuation_ws=ws) + + +def all_same_charset(mlist, msgdata, subject, prefix, prefix_pattern, ws): + list_charset = mlist.preferred_language.charset + chunks = [] + for chunk, charset in decode_header(subject.encode()): + if charset is None: + charset = 'us-ascii' + chunks.append(chunk.decode(charset)) + if charset != list_charset: + return None + subject_text = EMPTYSTRING.join(chunks) + rematch = re.match(RE_PATTERN, subject_text, re.I) + if rematch: + subject_text = subject_text[rematch.end():] + recolon = 'Re: ' + else: + recolon = '' + # At this point, the subject may become null if someone posted mail + # with "Subject: [subject prefix]". + if subject_text.strip() == '': + with _.push(mlist.preferred_language.code): + subject_text = _('(no subject)') + else: + subject_text = re.sub(prefix_pattern, '', subject_text) + msgdata['stripped_subject'] = subject_text + lines = subject_text.splitlines() + first_line = [lines[0]] + if recolon: + first_line.insert(0, recolon) + if prefix: + first_line.insert(0, prefix) + subject_text = EMPTYSTRING.join(first_line) + return Header(subject_text, charset=list_charset, continuation_ws=ws) + + +def mixed_charsets(mlist, msgdata, subject, prefix, prefix_pattern, ws): + list_charset = mlist.preferred_language.charset + chunks = decode_header(subject.encode()) + if len(chunks) == 0: + with _.push(mlist.preferred_language.code): + subject_text = _('(no subject)') + chunks = [(prefix, list_charset), + (subject_text, list_charset), + ] + return make_header(chunks, continuation_ws=ws) + # Only search the first chunk for Re and existing prefix. + chunk_text, chunk_charset = chunks[0] + if chunk_charset is None: + chunk_charset = 'us-ascii' + first_text = chunk_text.decode(chunk_charset) + first_text = re.sub(prefix_pattern, '', first_text).lstrip() + rematch = re.match(RE_PATTERN, first_text, re.I) + if rematch: + first_text = 'Re: ' + first_text[rematch.end():] + chunks[0] = (first_text, chunk_charset) + # The subject text stripped of the prefix, for use in the NNTP gateway. + msgdata['stripped_subject'] = str(make_header(chunks, continuation_ws=ws)) + chunks.insert(0, (prefix, list_charset)) + return make_header(chunks, continuation_ws=ws) + + + +@implementer(IHandler) +class SubjectPrefix: + """Add a list-specific prefix to the Subject header value.""" + + name = 'subject-prefix' + description = _('Add a list-specific prefix to the Subject header value.') + + def process(self, mlist, msg, msgdata): + """See `IHandler`.""" + if msgdata.get('isdigest') or msgdata.get('_fasttrack'): + return + prefix = mlist.subject_prefix + if not prefix.strip(): + return + subject = msg.get('subject', '') + # Turn the value into a Header instance and try to figure out what + # continuation whitespace is being used. + # Save the original Subject. + msgdata['original_subject'] = subject + if isinstance(subject, Header): + subject_text = str(subject) + else: + subject = make_header(decode_header(subject)) + subject_text = str(subject) + lines = subject_text.splitlines() + ws = '\t' + if len(lines) > 1 and lines[1] and lines[1][0] in ' \t': + ws = lines[1][0] + # If the subject_prefix contains '%d', it is replaced with the mailing + # list's sequence number. The sequential number format allows '%d' or + # '%05d' like pattern. + prefix_pattern = re.escape(prefix) + # Unescape '%'. + prefix_pattern = '%'.join(prefix_pattern.split(r'\%')) + p = re.compile('%\d*d') + if p.search(prefix, 1): + # The prefix has number, so we should search prefix w/number in + # subject. Also, force new style. + prefix_pattern = p.sub(r'\s*\d+\s*', prefix_pattern) + # Substitute %d in prefix with post_id + try: + prefix = prefix % mlist.post_id + except TypeError: + pass + for handler in (ascii_header, + all_same_charset, + mixed_charsets, + ): + new_subject = handler( + mlist, msgdata, subject, prefix, prefix_pattern, ws) + if new_subject is not None: + del msg['subject'] + msg['Subject'] = new_subject + return diff --git a/src/mailman/handlers/tests/test_subject_prefix.py b/src/mailman/handlers/tests/test_subject_prefix.py new file mode 100644 index 000000000..1125f3811 --- /dev/null +++ b/src/mailman/handlers/tests/test_subject_prefix.py @@ -0,0 +1,132 @@ +# Copyright (C) 2014 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see . + +"""Test the Subject header prefix munging..""" + +from __future__ import absolute_import, print_function, unicode_literals + +__metaclass__ = type +__all__ = [ + 'TestSubjectPrefix', + ] + + +import unittest + +from mailman.app.lifecycle import create_list +from mailman.config import config +from mailman.email.message import Message +from mailman.testing.layers import ConfigLayer + + + +class TestSubjectPrefix(unittest.TestCase): + layer = ConfigLayer + + def setUp(self): + self._mlist = create_list('test@example.com') + self._process = config.handlers['subject-prefix'].process + + def test_isdigest(self): + # If the message is destined for the digest, the Subject header does + # not get touched. + msg = Message() + msg['Subject'] = 'A test message' + self._process(self._mlist, msg, dict(isdigest=True)) + self.assertEqual(str(msg['subject']), 'A test message') + + def test_fasttrack(self): + # Messages internally crafted are 'fast tracked' and don't get their + # Subjects prefixed either. + msg = Message() + msg['Subject'] = 'A test message' + self._process(self._mlist, msg, dict(_fasttrack=True)) + self.assertEqual(str(msg['subject']), 'A test message') + + def test_whitespace_only_prefix(self): + # If the Subject prefix only contains whitespace, ignore it. + self._mlist.subject_prefix = ' ' + msg = Message() + msg['Subject'] = 'A test message' + self._process(self._mlist, msg, dict(_fasttrack=True)) + self.assertEqual(str(msg['subject']), 'A test message') + + def test_save_original_subject(self): + # When the Subject gets prefixed, the original is saved in the message + # metadata. + msgdata = {} + msg = Message() + msg['Subject'] = 'A test message' + self._process(self._mlist, msg, msgdata) + self.assertEqual(msgdata['original_subject'], 'A test message') + + def test_prefix(self): + # The Subject gets prefixed. The prefix gets automatically set by the + # list style when the list gets created. + msg = Message() + msg['Subject'] = 'A test message' + self._process(self._mlist, msg, {}) + self.assertEqual(str(msg['subject']), '[Test] A test message') + + def test_no_double_prefix(self): + # Don't add a prefix if the subject already contains one. + msg = Message() + msg['Subject'] = '[Test] A test message' + self._process(self._mlist, msg, {}) + self.assertEqual(str(msg['subject']), '[Test] A test message') + + def test_re_prefix(self): + # The subject has a Re: prefix. Make sure that gets preserved, but + # after the list prefix. + msg = Message() + msg['Subject'] = 'Re: [Test] A test message' + self._process(self._mlist, msg, {}) + self.assertEqual(str(msg['subject']), '[Test] Re: A test message') + + def test_multiline_subject(self): + # The subject appears on multiple lines. + msg = Message() + msg['Subject'] = '\n A test message' + self._process(self._mlist, msg, {}) + self.assertEqual(str(msg['subject']), '[Test] A test message') + + def test_i18n_prefix(self): + # The Subject header is encoded, but the prefix is still added. + msg = Message() + msg['Subject'] = '=?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?=' + self._process(self._mlist, msg, {}) + subject = msg['subject'] + self.assertEqual(subject.encode(), + '[Test] =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?=') + self.assertEqual(str(subject), '[Test] メールマン') + + def test_i18n_subject_with_sequential_prefix_and_re(self): + # The mailing list defines a sequential prefix, and the original + # Subject has a prefix with a different sequence number, *and* it also + # contains a Re: prefix. Make sure the sequence gets updated and all + # the bits get put back together in the right order. + self._mlist.subject_prefix = '[Test %d]' + self._mlist.post_id = 456 + msg = Message() + msg['Subject'] = \ + '[Test 123] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?=' + self._process(self._mlist, msg, {}) + subject = msg['subject'] + self.assertEqual( + subject.encode(), + '[Test 456] Re: =?iso-2022-jp?b?GyRCJWEhPCVrJV4lcxsoQg==?=') + self.assertEqual(str(subject), '[Test 456] Re: メールマン') diff --git a/src/mailman/runners/nntp.py b/src/mailman/runners/nntp.py index 5d0013055..d26001a57 100644 --- a/src/mailman/runners/nntp.py +++ b/src/mailman/runners/nntp.py @@ -111,9 +111,9 @@ def prepare_message(mlist, msg, msgdata): del msg['approved'] msg['Approved'] = mlist.posting_address # Should we restore the original, non-prefixed subject for gatewayed - # messages? TK: We use stripped_subject (prefix stripped) which was - # crafted in CookHeaders.py to ensure prefix was stripped from the subject - # came from mailing list user. + # messages? TK: We use stripped_subject (prefix stripped) which was crafted + # in the subject-prefix handler to ensure prefix was stripped from the + # subject came from mailing list user. stripped_subject = msgdata.get('stripped_subject', msgdata.get('original_subject')) if not mlist.nntp_prefix_subject_too and stripped_subject is not None: -- cgit v1.2.3-70-g09d2 From 286fac3f7c580dfc137ac11290a2ba5713f69472 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Mon, 22 Dec 2014 20:06:20 -0500 Subject: Remove huge amounts of now unnecessary file boilerplate. --- setup.py | 4 +--- src/mailman/__init__.py | 7 ------- src/mailman/app/bounces.py | 11 ++++------- src/mailman/app/commands.py | 6 +----- src/mailman/app/domain.py | 6 +----- src/mailman/app/events.py | 6 +----- src/mailman/app/inject.py | 4 ---- src/mailman/app/lifecycle.py | 6 +----- src/mailman/app/membership.py | 6 +----- src/mailman/app/moderator.py | 3 --- src/mailman/app/notifications.py | 3 --- src/mailman/app/registrar.py | 10 +++------- src/mailman/app/replybot.py | 3 --- src/mailman/app/subscriptions.py | 9 ++------- src/mailman/app/templates.py | 3 --- src/mailman/app/tests/test_bounces.py | 10 ++-------- src/mailman/app/tests/test_inject.py | 5 ++--- src/mailman/app/tests/test_lifecycle.py | 3 --- src/mailman/app/tests/test_membership.py | 6 +----- src/mailman/app/tests/test_moderation.py | 6 +----- src/mailman/app/tests/test_notifications.py | 7 ++----- src/mailman/app/tests/test_registration.py | 8 ++------ src/mailman/app/tests/test_subscriptions.py | 6 +----- src/mailman/app/tests/test_templates.py | 3 --- src/mailman/archiving/mailarchive.py | 3 --- src/mailman/archiving/mhonarc.py | 3 --- src/mailman/archiving/prototype.py | 3 --- src/mailman/archiving/tests/test_prototype.py | 4 ---- src/mailman/bin/mailman.py | 6 +----- src/mailman/bin/master.py | 4 ---- src/mailman/bin/onebounce.py | 3 --- src/mailman/bin/runner.py | 3 --- src/mailman/bin/tests/test_master.py | 3 --- src/mailman/chains/accept.py | 6 +----- src/mailman/chains/base.py | 6 +----- src/mailman/chains/builtin.py | 6 +----- src/mailman/chains/discard.py | 5 +---- src/mailman/chains/headers.py | 6 +----- src/mailman/chains/hold.py | 10 +++------- src/mailman/chains/moderation.py | 6 +----- src/mailman/chains/owner.py | 6 +----- src/mailman/chains/reject.py | 6 +----- src/mailman/chains/tests/test_base.py | 3 --- src/mailman/chains/tests/test_headers.py | 3 --- src/mailman/chains/tests/test_hold.py | 6 +----- src/mailman/chains/tests/test_owner.py | 6 +----- src/mailman/commands/cli_aliases.py | 6 +----- src/mailman/commands/cli_conf.py | 6 +----- src/mailman/commands/cli_control.py | 8 ++------ src/mailman/commands/cli_help.py | 6 +----- src/mailman/commands/cli_import.py | 3 --- src/mailman/commands/cli_info.py | 6 +----- src/mailman/commands/cli_inject.py | 3 --- src/mailman/commands/cli_lists.py | 8 ++------ src/mailman/commands/cli_members.py | 12 ++++-------- src/mailman/commands/cli_qfile.py | 4 +--- src/mailman/commands/cli_status.py | 6 +----- src/mailman/commands/cli_unshunt.py | 8 ++------ src/mailman/commands/cli_version.py | 6 +----- src/mailman/commands/cli_withlist.py | 9 +++------ src/mailman/commands/eml_confirm.py | 10 +++------- src/mailman/commands/eml_echo.py | 6 +----- src/mailman/commands/eml_end.py | 6 +----- src/mailman/commands/eml_help.py | 6 +----- src/mailman/commands/eml_membership.py | 9 +++------ src/mailman/commands/tests/test_conf.py | 3 --- src/mailman/commands/tests/test_confirm.py | 6 +----- src/mailman/commands/tests/test_control.py | 5 +---- src/mailman/commands/tests/test_create.py | 3 --- src/mailman/commands/tests/test_help.py | 4 +--- src/mailman/config/__init__.py | 3 --- src/mailman/config/config.py | 19 +++++++------------ src/mailman/config/tests/test_archivers.py | 3 --- src/mailman/config/tests/test_configuration.py | 3 --- src/mailman/core/chains.py | 6 +----- src/mailman/core/constants.py | 8 ++------ src/mailman/core/errors.py | 3 --- src/mailman/core/i18n.py | 8 +++----- src/mailman/core/initialize.py | 12 ++++-------- src/mailman/core/logging.py | 3 --- src/mailman/core/pipelines.py | 8 ++------ src/mailman/core/rules.py | 6 +----- src/mailman/core/runner.py | 3 --- src/mailman/core/switchboard.py | 3 --- src/mailman/core/system.py | 6 +----- src/mailman/core/tests/test_pipelines.py | 14 ++++---------- src/mailman/core/tests/test_runner.py | 3 --- src/mailman/database/alembic/__init__.py | 3 --- src/mailman/database/alembic/env.py | 6 +----- .../database/alembic/versions/51b7f92bd06c_initial.py | 3 --- src/mailman/database/base.py | 11 ++++------- src/mailman/database/factory.py | 10 +++------- src/mailman/database/model.py | 3 --- src/mailman/database/postgresql.py | 3 --- src/mailman/database/sqlite.py | 3 --- src/mailman/database/tests/test_factory.py | 12 ++++-------- src/mailman/database/transaction.py | 4 ---- src/mailman/database/types.py | 7 ++----- src/mailman/docs/__init__.py | 3 --- src/mailman/email/message.py | 4 ---- src/mailman/email/tests/test_message.py | 9 +++------ src/mailman/email/validate.py | 6 +----- src/mailman/handlers/acknowledge.py | 8 ++------ src/mailman/handlers/after_delivery.py | 6 +----- src/mailman/handlers/avoid_duplicates.py | 6 +----- src/mailman/handlers/cleanse.py | 6 +----- src/mailman/handlers/cleanse_dkim.py | 6 +----- src/mailman/handlers/cook_headers.py | 13 ++++--------- src/mailman/handlers/decorate.py | 3 --- src/mailman/handlers/file_recipients.py | 6 +----- src/mailman/handlers/member_recipients.py | 6 +----- src/mailman/handlers/mime_delete.py | 8 ++------ src/mailman/handlers/owner_recipients.py | 6 +----- src/mailman/handlers/replybot.py | 8 ++------ src/mailman/handlers/rfc_2369.py | 6 +----- src/mailman/handlers/subject_prefix.py | 3 --- src/mailman/handlers/tagger.py | 6 +----- src/mailman/handlers/tests/test_cook_headers.py | 7 ++----- src/mailman/handlers/tests/test_file_recips.py | 3 --- src/mailman/handlers/tests/test_filter.py | 3 --- src/mailman/handlers/tests/test_mimedel.py | 6 +----- src/mailman/handlers/tests/test_recipients.py | 3 --- src/mailman/handlers/tests/test_subject_prefix.py | 3 --- src/mailman/handlers/tests/test_to_digest.py | 3 --- src/mailman/handlers/to_archive.py | 6 +----- src/mailman/handlers/to_digest.py | 6 +----- src/mailman/handlers/to_outgoing.py | 6 +----- src/mailman/handlers/to_usenet.py | 8 ++------ src/mailman/interfaces/action.py | 1 - src/mailman/interfaces/address.py | 6 +----- src/mailman/interfaces/archiver.py | 3 --- src/mailman/interfaces/autorespond.py | 4 +--- src/mailman/interfaces/bans.py | 3 --- src/mailman/interfaces/bounce.py | 3 --- src/mailman/interfaces/chain.py | 3 --- src/mailman/interfaces/command.py | 3 --- src/mailman/interfaces/configuration.py | 6 +----- src/mailman/interfaces/database.py | 3 --- src/mailman/interfaces/digests.py | 3 --- src/mailman/interfaces/domain.py | 3 --- src/mailman/interfaces/errors.py | 3 --- src/mailman/interfaces/handler.py | 3 --- src/mailman/interfaces/languages.py | 3 --- src/mailman/interfaces/listmanager.py | 3 --- src/mailman/interfaces/mailinglist.py | 6 +----- src/mailman/interfaces/member.py | 6 +----- src/mailman/interfaces/messages.py | 3 --- src/mailman/interfaces/mime.py | 3 --- src/mailman/interfaces/mlistrequest.py | 3 --- src/mailman/interfaces/mta.py | 6 +----- src/mailman/interfaces/nntp.py | 3 --- src/mailman/interfaces/pending.py | 3 --- src/mailman/interfaces/permissions.py | 3 --- src/mailman/interfaces/pipeline.py | 4 ---- src/mailman/interfaces/preferences.py | 3 --- src/mailman/interfaces/registrar.py | 3 --- src/mailman/interfaces/requests.py | 3 --- src/mailman/interfaces/roster.py | 3 --- src/mailman/interfaces/rules.py | 3 --- src/mailman/interfaces/runner.py | 3 --- src/mailman/interfaces/styles.py | 5 +---- src/mailman/interfaces/subscriptions.py | 6 +----- src/mailman/interfaces/switchboard.py | 3 --- src/mailman/interfaces/system.py | 3 --- src/mailman/interfaces/templates.py | 3 --- src/mailman/interfaces/user.py | 6 +----- src/mailman/interfaces/usermanager.py | 3 --- src/mailman/languages/language.py | 6 +----- src/mailman/languages/manager.py | 8 ++------ src/mailman/model/address.py | 12 ++++-------- src/mailman/model/autorespond.py | 10 +++------- src/mailman/model/bans.py | 8 ++------ src/mailman/model/bounce.py | 8 ++------ src/mailman/model/digests.py | 10 +++------- src/mailman/model/domain.py | 3 --- src/mailman/model/language.py | 8 ++------ src/mailman/model/listmanager.py | 8 ++------ src/mailman/model/mailinglist.py | 3 --- src/mailman/model/member.py | 13 +++++-------- src/mailman/model/message.py | 7 ++----- src/mailman/model/messagestore.py | 3 --- src/mailman/model/mime.py | 10 +++------- src/mailman/model/pending.py | 13 ++++--------- src/mailman/model/preferences.py | 10 +++------- src/mailman/model/requests.py | 5 ++--- src/mailman/model/roster.py | 8 ++------ src/mailman/model/tests/test_address.py | 3 --- src/mailman/model/tests/test_bounce.py | 7 ++----- src/mailman/model/tests/test_domain.py | 6 +----- src/mailman/model/tests/test_listmanager.py | 3 --- src/mailman/model/tests/test_mailinglist.py | 3 --- src/mailman/model/tests/test_member.py | 3 --- src/mailman/model/tests/test_messagestore.py | 3 --- src/mailman/model/tests/test_requests.py | 3 --- src/mailman/model/tests/test_roster.py | 6 +----- src/mailman/model/tests/test_uid.py | 4 +--- src/mailman/model/tests/test_user.py | 3 --- src/mailman/model/uid.py | 6 +----- src/mailman/model/user.py | 12 ++++-------- src/mailman/model/usermanager.py | 6 +----- src/mailman/mta/aliases.py | 6 +----- src/mailman/mta/base.py | 6 +----- src/mailman/mta/bulk.py | 4 ---- src/mailman/mta/connection.py | 3 --- src/mailman/mta/decorating.py | 3 --- src/mailman/mta/deliver.py | 3 --- src/mailman/mta/exim4.py | 3 --- src/mailman/mta/null.py | 6 +----- src/mailman/mta/personalized.py | 6 +----- src/mailman/mta/postfix.py | 10 +++------- src/mailman/mta/tests/test_aliases.py | 6 +----- src/mailman/mta/tests/test_connection.py | 3 --- src/mailman/mta/tests/test_delivery.py | 3 --- src/mailman/mta/verp.py | 3 --- src/mailman/options.py | 6 +----- src/mailman/rest/addresses.py | 8 ++------ src/mailman/rest/configuration.py | 3 --- src/mailman/rest/docs/__init__.py | 3 --- src/mailman/rest/domains.py | 3 --- src/mailman/rest/helpers.py | 3 --- src/mailman/rest/lists.py | 8 ++------ src/mailman/rest/members.py | 10 +++------- src/mailman/rest/moderation.py | 3 --- src/mailman/rest/preferences.py | 3 --- src/mailman/rest/root.py | 6 +----- src/mailman/rest/templates.py | 3 --- src/mailman/rest/tests/test_addresses.py | 3 --- src/mailman/rest/tests/test_configuration.py | 3 --- src/mailman/rest/tests/test_domains.py | 3 --- src/mailman/rest/tests/test_lists.py | 3 --- src/mailman/rest/tests/test_membership.py | 3 --- src/mailman/rest/tests/test_moderation.py | 4 +--- src/mailman/rest/tests/test_paginate.py | 3 --- src/mailman/rest/tests/test_preferences.py | 4 +--- src/mailman/rest/tests/test_root.py | 3 --- src/mailman/rest/tests/test_users.py | 3 --- src/mailman/rest/users.py | 13 ++++++------- src/mailman/rest/validator.py | 8 ++------ src/mailman/rest/wsgiapp.py | 3 --- src/mailman/rules/administrivia.py | 6 +----- src/mailman/rules/any.py | 6 +----- src/mailman/rules/approved.py | 6 +----- src/mailman/rules/emergency.py | 6 +----- src/mailman/rules/implicit_dest.py | 7 ++----- src/mailman/rules/loop.py | 6 +----- src/mailman/rules/max_recipients.py | 6 +----- src/mailman/rules/max_size.py | 6 +----- src/mailman/rules/moderation.py | 8 ++------ src/mailman/rules/news_moderation.py | 6 +----- src/mailman/rules/no_subject.py | 6 +----- src/mailman/rules/suspicious.py | 7 ++----- src/mailman/rules/tests/test_approved.py | 6 +----- src/mailman/rules/tests/test_moderation.py | 3 --- src/mailman/rules/truth.py | 6 +----- src/mailman/runners/archive.py | 4 ---- src/mailman/runners/bounce.py | 5 ++--- src/mailman/runners/command.py | 8 ++------ src/mailman/runners/digest.py | 3 --- src/mailman/runners/incoming.py | 6 +----- src/mailman/runners/lmtp.py | 6 +----- src/mailman/runners/nntp.py | 3 --- src/mailman/runners/outgoing.py | 10 +++++++--- src/mailman/runners/pipeline.py | 5 +++++ src/mailman/runners/rest.py | 3 --- src/mailman/runners/retry.py | 3 --- src/mailman/runners/tests/test_archiver.py | 9 ++------- src/mailman/runners/tests/test_bounce.py | 12 +++--------- src/mailman/runners/tests/test_confirm.py | 9 ++------- src/mailman/runners/tests/test_digest.py | 3 --- src/mailman/runners/tests/test_incoming.py | 6 +----- src/mailman/runners/tests/test_join.py | 6 +----- src/mailman/runners/tests/test_lmtp.py | 3 --- src/mailman/runners/tests/test_nntp.py | 8 +------- src/mailman/runners/tests/test_outgoing.py | 14 ++++++-------- src/mailman/runners/tests/test_owner.py | 12 +++--------- src/mailman/runners/tests/test_pipeline.py | 9 ++------- src/mailman/runners/tests/test_rest.py | 3 --- src/mailman/runners/tests/test_retry.py | 6 +----- src/mailman/runners/virgin.py | 5 +++++ src/mailman/styles/base.py | 4 ---- src/mailman/styles/default.py | 6 +----- src/mailman/styles/manager.py | 10 +++------- src/mailman/styles/tests/test_styles.py | 10 +++------- src/mailman/testing/documentation.py | 9 --------- src/mailman/testing/helpers.py | 12 ++++-------- src/mailman/testing/i18n.py | 6 +----- src/mailman/testing/layers.py | 17 ++++++----------- src/mailman/testing/mta.py | 6 +----- src/mailman/testing/nose.py | 4 +--- src/mailman/tests/test_configfile.py | 9 +++++---- src/mailman/utilities/datetime.py | 4 ---- src/mailman/utilities/email.py | 3 --- src/mailman/utilities/filesystem.py | 3 --- src/mailman/utilities/i18n.py | 6 +----- src/mailman/utilities/importer.py | 3 --- src/mailman/utilities/interact.py | 3 --- src/mailman/utilities/mailbox.py | 5 +---- src/mailman/utilities/modules.py | 3 --- src/mailman/utilities/passwords.py | 7 +------ src/mailman/utilities/string.py | 3 --- src/mailman/utilities/tests/test_email.py | 3 --- src/mailman/utilities/tests/test_import.py | 15 ++++++++------- src/mailman/utilities/tests/test_passwords.py | 3 --- src/mailman/utilities/tests/test_templates.py | 19 +++++++++---------- src/mailman/utilities/tests/test_wrap.py | 4 +--- src/mailman/utilities/uid.py | 4 ---- 306 files changed, 339 insertions(+), 1381 deletions(-) (limited to 'src/mailman/handlers') diff --git a/setup.py b/setup.py index 3e8b1a7cc..87c7ee144 100644 --- a/setup.py +++ b/setup.py @@ -15,15 +15,13 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -# Do *not* import unicode_literals. This breaks setuptools. -from __future__ import absolute_import, print_function - import re import sys from setuptools import setup, find_packages from string import Template + if sys.hexversion < 0x30400f0: print('Mailman requires at least Python 3.4') sys.exit(1) diff --git a/src/mailman/__init__.py b/src/mailman/__init__.py index db7befab7..74040d211 100644 --- a/src/mailman/__init__.py +++ b/src/mailman/__init__.py @@ -17,13 +17,6 @@ """The `mailman` package.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type -__all__ = [ - ] - - import sys diff --git a/src/mailman/app/bounces.py b/src/mailman/app/bounces.py index 4f3fd187a..ebfe63cff 100644 --- a/src/mailman/app/bounces.py +++ b/src/mailman/app/bounces.py @@ -17,9 +17,6 @@ """Application level bounce handling.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ProbeVERP', 'StandardVERP', @@ -36,10 +33,6 @@ import logging from email.mime.message import MIMEMessage from email.mime.text import MIMEText from email.utils import parseaddr -from string import Template -from zope.component import getUtility -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.email.message import OwnerNotification, UserNotification @@ -50,6 +43,10 @@ from mailman.interfaces.subscriptions import ISubscriptionService from mailman.utilities.email import split_email from mailman.utilities.i18n import make from mailman.utilities.string import oneline +from string import Template +from zope.component import getUtility +from zope.interface import implementer + log = logging.getLogger('mailman.config') elog = logging.getLogger('mailman.error') diff --git a/src/mailman/app/commands.py b/src/mailman/app/commands.py index a0f717138..cfa672de5 100644 --- a/src/mailman/app/commands.py +++ b/src/mailman/app/commands.py @@ -17,19 +17,15 @@ """Initialize the email commands.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'initialize', ] -from zope.interface.verify import verifyObject - from mailman.config import config from mailman.interfaces.command import IEmailCommand from mailman.utilities.modules import find_components +from zope.interface.verify import verifyObject diff --git a/src/mailman/app/domain.py b/src/mailman/app/domain.py index 7ad976699..a8a2cd71a 100644 --- a/src/mailman/app/domain.py +++ b/src/mailman/app/domain.py @@ -17,18 +17,14 @@ """Application level domain support.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'handle_DomainDeletingEvent', ] -from zope.component import getUtility - from mailman.interfaces.domain import DomainDeletingEvent from mailman.interfaces.listmanager import IListManager +from zope.component import getUtility diff --git a/src/mailman/app/events.py b/src/mailman/app/events.py index 16817c202..0b7f2309e 100644 --- a/src/mailman/app/events.py +++ b/src/mailman/app/events.py @@ -17,22 +17,18 @@ """Global events.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'initialize', ] -from zope import event - from mailman.app import ( domain, membership, moderator, registrar, subscriptions) from mailman.core import i18n, switchboard from mailman.languages import manager as language_manager from mailman.styles import manager as style_manager from mailman.utilities import passwords +from zope import event diff --git a/src/mailman/app/inject.py b/src/mailman/app/inject.py index 584bd7b8f..77ad8dedb 100644 --- a/src/mailman/app/inject.py +++ b/src/mailman/app/inject.py @@ -17,9 +17,6 @@ """Inject a message into a queue.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'inject_message', 'inject_text', @@ -28,7 +25,6 @@ __all__ = [ from email import message_from_string from email.utils import formatdate, make_msgid - from mailman.config import config from mailman.email.message import Message from mailman.utilities.email import add_message_hash diff --git a/src/mailman/app/lifecycle.py b/src/mailman/app/lifecycle.py index 8110fe69d..bef8320d0 100644 --- a/src/mailman/app/lifecycle.py +++ b/src/mailman/app/lifecycle.py @@ -17,9 +17,6 @@ """Application level list creation.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'create_list', 'remove_list', @@ -31,8 +28,6 @@ import errno import shutil import logging -from zope.component import getUtility - from mailman.config import config from mailman.interfaces.address import IEmailValidator from mailman.interfaces.domain import ( @@ -42,6 +37,7 @@ from mailman.interfaces.member import MemberRole from mailman.interfaces.styles import IStyleManager from mailman.interfaces.usermanager import IUserManager from mailman.utilities.modules import call_name +from zope.component import getUtility log = logging.getLogger('mailman.error') diff --git a/src/mailman/app/membership.py b/src/mailman/app/membership.py index 4ec6b7878..0a6c8b971 100644 --- a/src/mailman/app/membership.py +++ b/src/mailman/app/membership.py @@ -17,9 +17,6 @@ """Application support for membership management.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'add_member', 'delete_member', @@ -28,8 +25,6 @@ __all__ = [ from email.utils import formataddr -from zope.component import getUtility - from mailman.app.notifications import ( send_goodbye_message, send_welcome_message) from mailman.config import config @@ -40,6 +35,7 @@ from mailman.interfaces.member import ( MemberRole, MembershipIsBannedError, NotAMemberError, SubscriptionEvent) from mailman.interfaces.usermanager import IUserManager from mailman.utilities.i18n import make +from zope.component import getUtility diff --git a/src/mailman/app/moderator.py b/src/mailman/app/moderator.py index e5fbc9044..d4c5b1036 100644 --- a/src/mailman/app/moderator.py +++ b/src/mailman/app/moderator.py @@ -17,9 +17,6 @@ """Application support for moderators.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'handle_ListDeletingEvent', 'handle_message', diff --git a/src/mailman/app/notifications.py b/src/mailman/app/notifications.py index f5dd7ed19..163b02653 100644 --- a/src/mailman/app/notifications.py +++ b/src/mailman/app/notifications.py @@ -17,9 +17,6 @@ """Sending notifications.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'send_admin_subscription_notice', 'send_goodbye_message', diff --git a/src/mailman/app/registrar.py b/src/mailman/app/registrar.py index aa4e35483..fd84f7aa0 100644 --- a/src/mailman/app/registrar.py +++ b/src/mailman/app/registrar.py @@ -17,9 +17,6 @@ """Implementation of the IUserRegistrar interface.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Registrar', 'handle_ConfirmationNeededEvent', @@ -28,10 +25,6 @@ __all__ = [ import logging -from zope.component import getUtility -from zope.event import notify -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.email.message import UserNotification from mailman.interfaces.address import IEmailValidator @@ -42,6 +35,9 @@ from mailman.interfaces.registrar import ConfirmationNeededEvent, IRegistrar from mailman.interfaces.templates import ITemplateLoader from mailman.interfaces.usermanager import IUserManager from mailman.utilities.datetime import now +from zope.component import getUtility +from zope.event import notify +from zope.interface import implementer log = logging.getLogger('mailman.error') diff --git a/src/mailman/app/replybot.py b/src/mailman/app/replybot.py index 4ade73faf..ca563ea0a 100644 --- a/src/mailman/app/replybot.py +++ b/src/mailman/app/replybot.py @@ -21,9 +21,6 @@ # mailing list. The reply governor should really apply site-wide per # recipient (I think). -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'can_acknowledge', ] diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py index 620b99c20..e3239e97e 100644 --- a/src/mailman/app/subscriptions.py +++ b/src/mailman/app/subscriptions.py @@ -15,19 +15,14 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -"""Module stuff.""" +"""Handle subscriptions.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'SubscriptionService', 'handle_ListDeletingEvent', ] -import six - from operator import attrgetter from passlib.utils import generate_password as generate from sqlalchemy import and_, or_ @@ -110,7 +105,7 @@ class SubscriptionService: # the parameter can either be an email address or a user id. query = [] if subscriber is not None: - if isinstance(subscriber, six.text_type): + if isinstance(subscriber, str): # subscriber is an email address. address = user_manager.get_address(subscriber) user = user_manager.get_user(subscriber) diff --git a/src/mailman/app/templates.py b/src/mailman/app/templates.py index d62ac7f16..a5f9fc1b5 100644 --- a/src/mailman/app/templates.py +++ b/src/mailman/app/templates.py @@ -17,9 +17,6 @@ """Template loader.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TemplateLoader', ] diff --git a/src/mailman/app/tests/test_bounces.py b/src/mailman/app/tests/test_bounces.py index 0cb1728cd..b89664209 100644 --- a/src/mailman/app/tests/test_bounces.py +++ b/src/mailman/app/tests/test_bounces.py @@ -17,9 +17,6 @@ """Testing app.bounces functions.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestBounceMessage', 'TestMaybeForward', @@ -36,8 +33,6 @@ import shutil import tempfile import unittest -from zope.component import getUtility - from mailman.app.bounces import ( ProbeVERP, StandardVERP, bounce_message, maybe_forward, send_probe) from mailman.app.lifecycle import create_list @@ -49,10 +44,9 @@ from mailman.interfaces.member import DeliveryMode, MemberRole from mailman.interfaces.pending import IPendings from mailman.interfaces.usermanager import IUserManager from mailman.testing.helpers import ( - LogFileMark, - get_queue_messages, - specialized_message_from_string as mfs) + LogFileMark, get_queue_messages, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/app/tests/test_inject.py b/src/mailman/app/tests/test_inject.py index 23abc6943..196c32182 100644 --- a/src/mailman/app/tests/test_inject.py +++ b/src/mailman/app/tests/test_inject.py @@ -17,10 +17,9 @@ """Testing app.inject functions.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestInjectMessage', + 'TestInjectText', ] diff --git a/src/mailman/app/tests/test_lifecycle.py b/src/mailman/app/tests/test_lifecycle.py index 0fb54f193..75386b870 100644 --- a/src/mailman/app/tests/test_lifecycle.py +++ b/src/mailman/app/tests/test_lifecycle.py @@ -17,9 +17,6 @@ """Test the high level list lifecycle API.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestLifecycle', ] diff --git a/src/mailman/app/tests/test_membership.py b/src/mailman/app/tests/test_membership.py index 95e8de1d0..5b2caf103 100644 --- a/src/mailman/app/tests/test_membership.py +++ b/src/mailman/app/tests/test_membership.py @@ -17,9 +17,6 @@ """Tests of application level membership functions.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestAddMember', 'TestAddMemberPassword', @@ -29,8 +26,6 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.app.membership import add_member, delete_member from mailman.core.constants import system_preferences @@ -40,6 +35,7 @@ from mailman.interfaces.member import ( NotAMemberError) from mailman.interfaces.usermanager import IUserManager from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/app/tests/test_moderation.py b/src/mailman/app/tests/test_moderation.py index edb6b8c28..190b670d8 100644 --- a/src/mailman/app/tests/test_moderation.py +++ b/src/mailman/app/tests/test_moderation.py @@ -17,9 +17,6 @@ """Moderation tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestModeration', ] @@ -27,8 +24,6 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.app.moderator import handle_message, hold_message from mailman.interfaces.action import Action @@ -41,6 +36,7 @@ from mailman.testing.helpers import ( get_queue_messages, make_testable_runner, specialized_message_from_string) from mailman.testing.layers import SMTPLayer from mailman.utilities.datetime import now +from zope.component import getUtility diff --git a/src/mailman/app/tests/test_notifications.py b/src/mailman/app/tests/test_notifications.py index 4cdc1c01c..fda4aaa0b 100644 --- a/src/mailman/app/tests/test_notifications.py +++ b/src/mailman/app/tests/test_notifications.py @@ -17,10 +17,8 @@ """Test notifications.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestNotifications', ] @@ -29,8 +27,6 @@ import shutil import tempfile import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.app.membership import add_member from mailman.config import config @@ -38,6 +34,7 @@ from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.member import DeliveryMode, MemberRole from mailman.testing.helpers import get_queue_messages from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/app/tests/test_registration.py b/src/mailman/app/tests/test_registration.py index ff128ae6f..fa34005c8 100644 --- a/src/mailman/app/tests/test_registration.py +++ b/src/mailman/app/tests/test_registration.py @@ -1,4 +1,4 @@ -# Copyright (C) 2012 by the Free Software Foundation, Inc. +# Copyright (C) 2012-2014 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -17,9 +17,6 @@ """Test email address registration.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestEmailValidation', 'TestRegistration', @@ -28,14 +25,13 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.pending import IPendings from mailman.interfaces.registrar import ConfirmationNeededEvent, IRegistrar from mailman.testing.helpers import event_subscribers from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/app/tests/test_subscriptions.py b/src/mailman/app/tests/test_subscriptions.py index bd1994c19..1ba3cc24b 100644 --- a/src/mailman/app/tests/test_subscriptions.py +++ b/src/mailman/app/tests/test_subscriptions.py @@ -17,9 +17,6 @@ """Tests for the subscription service.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestJoin' ] @@ -28,14 +25,13 @@ __all__ = [ import uuid import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.member import MemberRole, MissingPreferredAddressError from mailman.interfaces.subscriptions import ( MissingUserError, ISubscriptionService) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/app/tests/test_templates.py b/src/mailman/app/tests/test_templates.py index c20c98280..68bab9f49 100644 --- a/src/mailman/app/tests/test_templates.py +++ b/src/mailman/app/tests/test_templates.py @@ -17,9 +17,6 @@ """Test the template downloader API.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestTemplateLoader', ] diff --git a/src/mailman/archiving/mailarchive.py b/src/mailman/archiving/mailarchive.py index e6b43b530..a712e4052 100644 --- a/src/mailman/archiving/mailarchive.py +++ b/src/mailman/archiving/mailarchive.py @@ -17,9 +17,6 @@ """The Mail-Archive.com archiver.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MailArchive', ] diff --git a/src/mailman/archiving/mhonarc.py b/src/mailman/archiving/mhonarc.py index b50ceaf51..31853183f 100644 --- a/src/mailman/archiving/mhonarc.py +++ b/src/mailman/archiving/mhonarc.py @@ -17,9 +17,6 @@ """MHonArc archiver.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MHonArc', ] diff --git a/src/mailman/archiving/prototype.py b/src/mailman/archiving/prototype.py index 3085f5700..a27a2e57f 100644 --- a/src/mailman/archiving/prototype.py +++ b/src/mailman/archiving/prototype.py @@ -17,9 +17,6 @@ """Prototypical permalinking archiver.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Prototype', ] diff --git a/src/mailman/archiving/tests/test_prototype.py b/src/mailman/archiving/tests/test_prototype.py index 6bc4f25b4..4cd33d431 100644 --- a/src/mailman/archiving/tests/test_prototype.py +++ b/src/mailman/archiving/tests/test_prototype.py @@ -17,9 +17,6 @@ """Test the prototype archiver.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestPrototypeArchiver', ] @@ -33,7 +30,6 @@ import threading from email import message_from_file from flufl.lock import Lock - from mailman.app.lifecycle import create_list from mailman.archiving.prototype import Prototype from mailman.config import config diff --git a/src/mailman/bin/mailman.py b/src/mailman/bin/mailman.py index f9352fac6..ad8de144f 100644 --- a/src/mailman/bin/mailman.py +++ b/src/mailman/bin/mailman.py @@ -17,9 +17,6 @@ """The 'mailman' command dispatcher.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'main', ] @@ -29,13 +26,12 @@ import os import argparse from functools import cmp_to_key -from zope.interface.verify import verifyObject - from mailman.core.i18n import _ from mailman.core.initialize import initialize from mailman.interfaces.command import ICLISubCommand from mailman.utilities.modules import find_components from mailman.version import MAILMAN_VERSION_FULL +from zope.interface.verify import verifyObject diff --git a/src/mailman/bin/master.py b/src/mailman/bin/master.py index fa0ec0f16..6dc2a451f 100644 --- a/src/mailman/bin/master.py +++ b/src/mailman/bin/master.py @@ -17,9 +17,6 @@ """Master subprocess watcher.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Loop', 'main', @@ -37,7 +34,6 @@ from datetime import timedelta from enum import Enum from flufl.lock import Lock, NotLockedError, TimeOutError from lazr.config import as_boolean - from mailman.config import config from mailman.core.i18n import _ from mailman.core.logging import reopen diff --git a/src/mailman/bin/onebounce.py b/src/mailman/bin/onebounce.py index 1c23fc42a..b504b4c00 100644 --- a/src/mailman/bin/onebounce.py +++ b/src/mailman/bin/onebounce.py @@ -18,9 +18,6 @@ """Test bounce detection on message files.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'main', ] diff --git a/src/mailman/bin/runner.py b/src/mailman/bin/runner.py index 7648ed961..88e02254f 100644 --- a/src/mailman/bin/runner.py +++ b/src/mailman/bin/runner.py @@ -17,9 +17,6 @@ """The runner process.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'main', ] diff --git a/src/mailman/bin/tests/test_master.py b/src/mailman/bin/tests/test_master.py index d6e301e58..c65777e5e 100644 --- a/src/mailman/bin/tests/test_master.py +++ b/src/mailman/bin/tests/test_master.py @@ -17,9 +17,6 @@ """Test master watcher utilities.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMasterLock', ] diff --git a/src/mailman/chains/accept.py b/src/mailman/chains/accept.py index f5dd5a73d..89995b5a1 100644 --- a/src/mailman/chains/accept.py +++ b/src/mailman/chains/accept.py @@ -17,9 +17,6 @@ """The terminal 'accept' chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AcceptChain', ] @@ -27,12 +24,11 @@ __all__ = [ import logging -from zope.event import notify - from mailman.chains.base import TerminalChainBase from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.chain import AcceptEvent +from zope.event import notify log = logging.getLogger('mailman.vette') diff --git a/src/mailman/chains/base.py b/src/mailman/chains/base.py index 37d8e76f3..7db31de73 100644 --- a/src/mailman/chains/base.py +++ b/src/mailman/chains/base.py @@ -17,9 +17,6 @@ """Base class for terminal chains.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Chain', 'Link', @@ -27,11 +24,10 @@ __all__ = [ ] -from zope.interface import implementer - from mailman.config import config from mailman.interfaces.chain import ( IChain, IChainIterator, IChainLink, IMutableChain, LinkAction) +from zope.interface import implementer diff --git a/src/mailman/chains/builtin.py b/src/mailman/chains/builtin.py index bce9349a1..b26b31550 100644 --- a/src/mailman/chains/builtin.py +++ b/src/mailman/chains/builtin.py @@ -17,9 +17,6 @@ """The default built-in starting chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BuiltInChain', ] @@ -27,12 +24,11 @@ __all__ = [ import logging -from zope.interface import implementer - from mailman.chains.base import Link from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.chain import IChain, LinkAction +from zope.interface import implementer log = logging.getLogger('mailman.vette') diff --git a/src/mailman/chains/discard.py b/src/mailman/chains/discard.py index 001b243ac..9eb419201 100644 --- a/src/mailman/chains/discard.py +++ b/src/mailman/chains/discard.py @@ -17,20 +17,17 @@ """The terminal 'discard' chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'DiscardChain', ] import logging -from zope.event import notify from mailman.chains.base import TerminalChainBase from mailman.core.i18n import _ from mailman.interfaces.chain import DiscardEvent +from zope.event import notify log = logging.getLogger('mailman.vette') diff --git a/src/mailman/chains/headers.py b/src/mailman/chains/headers.py index b37079f7f..5738336e8 100644 --- a/src/mailman/chains/headers.py +++ b/src/mailman/chains/headers.py @@ -17,9 +17,6 @@ """The header-matching chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'HeaderMatchChain', ] @@ -28,13 +25,12 @@ __all__ = [ import re import logging -from zope.interface import implementer - from mailman.chains.base import Chain, Link from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.chain import LinkAction from mailman.interfaces.rules import IRule +from zope.interface import implementer log = logging.getLogger('mailman.error') diff --git a/src/mailman/chains/hold.py b/src/mailman/chains/hold.py index 5bb482cd5..7a516dc0d 100644 --- a/src/mailman/chains/hold.py +++ b/src/mailman/chains/hold.py @@ -17,9 +17,6 @@ """The terminal 'hold' chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'HoldChain', ] @@ -30,10 +27,6 @@ import logging from email.mime.message import MIMEMessage from email.mime.text import MIMEText from email.utils import formatdate, make_msgid -from zope.component import getUtility -from zope.event import notify -from zope.interface import implementer - from mailman.app.moderator import hold_message from mailman.app.replybot import can_acknowledge from mailman.chains.base import TerminalChainBase @@ -47,6 +40,9 @@ from mailman.interfaces.pending import IPendable, IPendings from mailman.interfaces.usermanager import IUserManager from mailman.utilities.i18n import make from mailman.utilities.string import oneline, wrap +from zope.component import getUtility +from zope.event import notify +from zope.interface import implementer log = logging.getLogger('mailman.vette') diff --git a/src/mailman/chains/moderation.py b/src/mailman/chains/moderation.py index 9b34f6389..944a66089 100644 --- a/src/mailman/chains/moderation.py +++ b/src/mailman/chains/moderation.py @@ -34,21 +34,17 @@ made as to the disposition of the message. `defer` is the default for members, while `hold` is the default for nonmembers. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ModerationChain', ] -from zope.interface import implementer - from mailman.chains.base import Link from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.action import Action from mailman.interfaces.chain import IChain, LinkAction +from zope.interface import implementer diff --git a/src/mailman/chains/owner.py b/src/mailman/chains/owner.py index 8e9aac154..9b0670ac9 100644 --- a/src/mailman/chains/owner.py +++ b/src/mailman/chains/owner.py @@ -17,9 +17,6 @@ """The standard -owner posting chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BuiltInOwnerChain', ] @@ -27,12 +24,11 @@ __all__ = [ import logging -from zope.event import notify - from mailman.chains.base import TerminalChainBase from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.chain import AcceptOwnerEvent +from zope.event import notify log = logging.getLogger('mailman.vette') diff --git a/src/mailman/chains/reject.py b/src/mailman/chains/reject.py index e24cedb85..2f358afe1 100644 --- a/src/mailman/chains/reject.py +++ b/src/mailman/chains/reject.py @@ -17,9 +17,6 @@ """The terminal 'reject' chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'RejectChain', ] @@ -27,12 +24,11 @@ __all__ = [ import logging -from zope.event import notify - from mailman.app.bounces import bounce_message from mailman.chains.base import TerminalChainBase from mailman.core.i18n import _ from mailman.interfaces.chain import RejectEvent +from zope.event import notify log = logging.getLogger('mailman.vette') diff --git a/src/mailman/chains/tests/test_base.py b/src/mailman/chains/tests/test_base.py index 8d0d70449..784309395 100644 --- a/src/mailman/chains/tests/test_base.py +++ b/src/mailman/chains/tests/test_base.py @@ -17,9 +17,6 @@ """Test the base chain stuff.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMiscellaneous', ] diff --git a/src/mailman/chains/tests/test_headers.py b/src/mailman/chains/tests/test_headers.py index adfc0ecb6..55bed3af0 100644 --- a/src/mailman/chains/tests/test_headers.py +++ b/src/mailman/chains/tests/test_headers.py @@ -17,9 +17,6 @@ """Test the header chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestHeaderChain', ] diff --git a/src/mailman/chains/tests/test_hold.py b/src/mailman/chains/tests/test_hold.py index a1fddd558..2a49b0ff0 100644 --- a/src/mailman/chains/tests/test_hold.py +++ b/src/mailman/chains/tests/test_hold.py @@ -17,9 +17,6 @@ """Additional tests for the hold chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestAutorespond', ] @@ -27,14 +24,13 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.chains.hold import autorespond_to_sender from mailman.interfaces.autorespond import IAutoResponseSet, Response from mailman.interfaces.usermanager import IUserManager from mailman.testing.helpers import configuration, get_queue_messages from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/chains/tests/test_owner.py b/src/mailman/chains/tests/test_owner.py index 96b858317..0766ba630 100644 --- a/src/mailman/chains/tests/test_owner.py +++ b/src/mailman/chains/tests/test_owner.py @@ -17,9 +17,6 @@ """Test the owner chain.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestOwnerChain', ] @@ -32,8 +29,7 @@ from mailman.chains.owner import BuiltInOwnerChain from mailman.core.chains import process from mailman.interfaces.chain import AcceptOwnerEvent from mailman.testing.helpers import ( - event_subscribers, - get_queue_messages, + event_subscribers, get_queue_messages, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer diff --git a/src/mailman/commands/cli_aliases.py b/src/mailman/commands/cli_aliases.py index 7c85ad9e0..2e1dc88ec 100644 --- a/src/mailman/commands/cli_aliases.py +++ b/src/mailman/commands/cli_aliases.py @@ -17,20 +17,16 @@ """Generate Mailman alias files for your MTA.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Aliases', ] -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.utilities.modules import call_name +from zope.interface import implementer diff --git a/src/mailman/commands/cli_conf.py b/src/mailman/commands/cli_conf.py index 7fe9fce7d..d0b7f7d2f 100644 --- a/src/mailman/commands/cli_conf.py +++ b/src/mailman/commands/cli_conf.py @@ -17,9 +17,6 @@ """Print the mailman configuration.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Conf' ] @@ -29,11 +26,10 @@ import sys from contextlib import closing from lazr.config._config import Section -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from zope.interface import implementer diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py index b0afc1337..2febe08e5 100644 --- a/src/mailman/commands/cli_control.py +++ b/src/mailman/commands/cli_control.py @@ -15,11 +15,8 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -"""Module stuff.""" +"""Start/stop/reopen/restart commands.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Reopen', 'Restart', @@ -34,12 +31,11 @@ import errno import signal import logging -from zope.interface import implementer - from mailman.bin.master import WatcherState, master_state from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from zope.interface import implementer qlog = logging.getLogger('mailman.runner') diff --git a/src/mailman/commands/cli_help.py b/src/mailman/commands/cli_help.py index ce39eeda5..721c8936e 100644 --- a/src/mailman/commands/cli_help.py +++ b/src/mailman/commands/cli_help.py @@ -17,17 +17,13 @@ """The 'help' subcommand.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Help', ] -from zope.interface import implementer - from mailman.interfaces.command import ICLISubCommand +from zope.interface import implementer diff --git a/src/mailman/commands/cli_import.py b/src/mailman/commands/cli_import.py index 7b18b888c..38b6fcef4 100644 --- a/src/mailman/commands/cli_import.py +++ b/src/mailman/commands/cli_import.py @@ -17,9 +17,6 @@ """Importing list data into Mailman 3.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Import21', ] diff --git a/src/mailman/commands/cli_info.py b/src/mailman/commands/cli_info.py index 4304e0ddb..6dd938127 100644 --- a/src/mailman/commands/cli_info.py +++ b/src/mailman/commands/cli_info.py @@ -17,9 +17,6 @@ """Information about this Mailman instance.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Info' ] @@ -28,13 +25,12 @@ __all__ = [ import sys from lazr.config import as_boolean -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.rest.helpers import path_to from mailman.version import MAILMAN_VERSION_FULL +from zope.interface import implementer diff --git a/src/mailman/commands/cli_inject.py b/src/mailman/commands/cli_inject.py index 9339dc074..ad4b53291 100644 --- a/src/mailman/commands/cli_inject.py +++ b/src/mailman/commands/cli_inject.py @@ -17,9 +17,6 @@ """bin/mailman inject""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Inject', ] diff --git a/src/mailman/commands/cli_lists.py b/src/mailman/commands/cli_lists.py index 9d857992c..fac1dcd1d 100644 --- a/src/mailman/commands/cli_lists.py +++ b/src/mailman/commands/cli_lists.py @@ -17,9 +17,6 @@ """The 'lists' subcommand.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Create', 'Lists', @@ -27,9 +24,6 @@ __all__ = [ ] -from zope.component import getUtility -from zope.interface import implementer - from mailman.app.lifecycle import create_list, remove_list from mailman.core.constants import system_preferences from mailman.core.i18n import _ @@ -43,6 +37,8 @@ from mailman.interfaces.domain import ( from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.listmanager import IListManager, ListAlreadyExistsError from mailman.utilities.i18n import make +from zope.component import getUtility +from zope.interface import implementer COMMASPACE = ', ' diff --git a/src/mailman/commands/cli_members.py b/src/mailman/commands/cli_members.py index 756771877..21d78ec54 100644 --- a/src/mailman/commands/cli_members.py +++ b/src/mailman/commands/cli_members.py @@ -17,9 +17,6 @@ """The 'members' subcommand.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Members', ] @@ -29,11 +26,6 @@ import sys import codecs from email.utils import formataddr, parseaddr -from operator import attrgetter -from passlib.utils import generate_password as generate -from zope.component import getUtility -from zope.interface import implementer - from mailman.app.membership import add_member from mailman.config import config from mailman.core.i18n import _ @@ -42,6 +34,10 @@ from mailman.interfaces.command import ICLISubCommand from mailman.interfaces.listmanager import IListManager from mailman.interfaces.member import ( AlreadySubscribedError, DeliveryMode, DeliveryStatus) +from operator import attrgetter +from passlib.utils import generate_password as generate +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/commands/cli_qfile.py b/src/mailman/commands/cli_qfile.py index 499476772..e502deac8 100644 --- a/src/mailman/commands/cli_qfile.py +++ b/src/mailman/commands/cli_qfile.py @@ -17,9 +17,6 @@ """Getting information out of a qfile.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'QFile', ] @@ -35,6 +32,7 @@ from six.moves import cPickle from zope.interface import implementer +# This is deliberately called 'm' for use with --interactive. m = [] diff --git a/src/mailman/commands/cli_status.py b/src/mailman/commands/cli_status.py index 207b44e04..2bef9d73c 100644 --- a/src/mailman/commands/cli_status.py +++ b/src/mailman/commands/cli_status.py @@ -17,9 +17,6 @@ """bin/mailman status.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Status', ] @@ -27,11 +24,10 @@ __all__ = [ import socket -from zope.interface import implementer - from mailman.bin.master import WatcherState, master_state from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from zope.interface import implementer diff --git a/src/mailman/commands/cli_unshunt.py b/src/mailman/commands/cli_unshunt.py index 77196565b..7cfa9e4ed 100644 --- a/src/mailman/commands/cli_unshunt.py +++ b/src/mailman/commands/cli_unshunt.py @@ -17,9 +17,6 @@ """The 'unshunt' command.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Unshunt', ] @@ -27,11 +24,10 @@ __all__ = [ import sys -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from zope.interface import implementer @@ -62,7 +58,7 @@ class Unshunt: which_queue = msgdata.get('whichq', 'in') if not args.discard: config.switchboards[which_queue].enqueue(msg, msgdata) - except Exception as error: + except Exception: print(_('Cannot unshunt message $filebase, skipping:\n$error'), file=sys.stderr) else: diff --git a/src/mailman/commands/cli_version.py b/src/mailman/commands/cli_version.py index 86ce9ab68..bc0f34a34 100644 --- a/src/mailman/commands/cli_version.py +++ b/src/mailman/commands/cli_version.py @@ -17,18 +17,14 @@ """The Mailman version.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Version', ] -from zope.interface import implementer - from mailman.interfaces.command import ICLISubCommand from mailman.version import MAILMAN_VERSION_FULL +from zope.interface import implementer diff --git a/src/mailman/commands/cli_withlist.py b/src/mailman/commands/cli_withlist.py index fc2363816..7cf8c0451 100644 --- a/src/mailman/commands/cli_withlist.py +++ b/src/mailman/commands/cli_withlist.py @@ -17,9 +17,6 @@ """bin/mailman withlist""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Shell', 'Withlist', @@ -30,15 +27,15 @@ import re import sys from lazr.config import as_boolean -from zope.component import getUtility -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand from mailman.interfaces.listmanager import IListManager from mailman.utilities.interact import DEFAULT_BANNER, interact from mailman.utilities.modules import call_name +from zope.component import getUtility +from zope.interface import implementer + # Global holding onto the open mailing list. m = None diff --git a/src/mailman/commands/eml_confirm.py b/src/mailman/commands/eml_confirm.py index 0239e0f25..2cef7cbad 100644 --- a/src/mailman/commands/eml_confirm.py +++ b/src/mailman/commands/eml_confirm.py @@ -15,22 +15,18 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -"""Module stuff.""" +"""The 'confirm' email command.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Confirm', ] -from zope.component import getUtility -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand from mailman.interfaces.registrar import IRegistrar +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/commands/eml_echo.py b/src/mailman/commands/eml_echo.py index eb476dc7d..2bd55edbc 100644 --- a/src/mailman/commands/eml_echo.py +++ b/src/mailman/commands/eml_echo.py @@ -17,18 +17,14 @@ """The email command 'echo'.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Echo', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand +from zope.interface import implementer SPACE = ' ' diff --git a/src/mailman/commands/eml_end.py b/src/mailman/commands/eml_end.py index 447d4066b..d25c19fcb 100644 --- a/src/mailman/commands/eml_end.py +++ b/src/mailman/commands/eml_end.py @@ -17,19 +17,15 @@ """The email commands 'end' and 'stop'.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'End', 'Stop', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand +from zope.interface import implementer diff --git a/src/mailman/commands/eml_help.py b/src/mailman/commands/eml_help.py index 139d484fb..8b93b272a 100644 --- a/src/mailman/commands/eml_help.py +++ b/src/mailman/commands/eml_help.py @@ -17,20 +17,16 @@ """The email command 'help'.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Help', ] -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand from mailman.utilities.string import wrap +from zope.interface import implementer SPACE = ' ' diff --git a/src/mailman/commands/eml_membership.py b/src/mailman/commands/eml_membership.py index c56b14041..e6a6825ed 100644 --- a/src/mailman/commands/eml_membership.py +++ b/src/mailman/commands/eml_membership.py @@ -17,9 +17,6 @@ """The email commands 'join' and 'subscribe'.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Join', 'Subscribe', @@ -29,15 +26,14 @@ __all__ = [ from email.utils import formataddr, parseaddr -from zope.component import getUtility -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.command import ContinueProcessing, IEmailCommand from mailman.interfaces.member import DeliveryMode, MemberRole from mailman.interfaces.registrar import IRegistrar from mailman.interfaces.subscriptions import ISubscriptionService from mailman.interfaces.usermanager import IUserManager +from zope.component import getUtility +from zope.interface import implementer @@ -182,6 +178,7 @@ You may be asked to confirm your request.""") return ContinueProcessing.yes + class Unsubscribe(Leave): """The email 'unsubscribe' command (an alias for 'leave').""" diff --git a/src/mailman/commands/tests/test_conf.py b/src/mailman/commands/tests/test_conf.py index cc0f61ba2..07036df3a 100644 --- a/src/mailman/commands/tests/test_conf.py +++ b/src/mailman/commands/tests/test_conf.py @@ -17,9 +17,6 @@ """Test the conf subcommand.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestConf', ] diff --git a/src/mailman/commands/tests/test_confirm.py b/src/mailman/commands/tests/test_confirm.py index 19a9068bc..f067a2a0a 100644 --- a/src/mailman/commands/tests/test_confirm.py +++ b/src/mailman/commands/tests/test_confirm.py @@ -17,9 +17,6 @@ """Test the `confirm` command.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestConfirm', ] @@ -27,8 +24,6 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.commands.eml_confirm import Confirm from mailman.email.message import Message @@ -37,6 +32,7 @@ from mailman.interfaces.registrar import IRegistrar from mailman.runners.command import Results from mailman.testing.helpers import get_queue_messages, reset_the_world from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/commands/tests/test_control.py b/src/mailman/commands/tests/test_control.py index 0847d86b1..299f0da25 100644 --- a/src/mailman/commands/tests/test_control.py +++ b/src/mailman/commands/tests/test_control.py @@ -17,9 +17,6 @@ """Test some additional corner cases for starting/stopping.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestStart', 'find_master', @@ -37,11 +34,11 @@ import socket import unittest from datetime import timedelta, datetime - from mailman.commands.cli_control import Start, kill_watcher from mailman.config import config from mailman.testing.layers import ConfigLayer + SEP = '|' diff --git a/src/mailman/commands/tests/test_create.py b/src/mailman/commands/tests/test_create.py index c2dffb929..47808c997 100644 --- a/src/mailman/commands/tests/test_create.py +++ b/src/mailman/commands/tests/test_create.py @@ -17,9 +17,6 @@ """Test `bin/mailman create`.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestCreate', ] diff --git a/src/mailman/commands/tests/test_help.py b/src/mailman/commands/tests/test_help.py index ea8105d2a..b2de0297d 100644 --- a/src/mailman/commands/tests/test_help.py +++ b/src/mailman/commands/tests/test_help.py @@ -17,10 +17,8 @@ """Additional tests for the `help` email command.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestHelp', ] diff --git a/src/mailman/config/__init__.py b/src/mailman/config/__init__.py index fb240ad76..4b9b1d07a 100644 --- a/src/mailman/config/__init__.py +++ b/src/mailman/config/__init__.py @@ -17,9 +17,6 @@ """Mailman configuration package.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'config', ] diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py index 7a9befa83..b2f400fc3 100644 --- a/src/mailman/config/config.py +++ b/src/mailman/config/config.py @@ -17,9 +17,6 @@ """Configuration file loading and management.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Configuration', 'external_configuration', @@ -29,9 +26,16 @@ __all__ = [ import os import sys +import mailman.templates from flufl.lock import Lock from lazr.config import ConfigSchema, as_boolean +from mailman import version +from mailman.interfaces.configuration import ( + ConfigurationUpdatedEvent, IConfiguration, MissingConfigurationFileError) +from mailman.interfaces.languages import ILanguageManager +from mailman.utilities.filesystem import makedirs +from mailman.utilities.modules import call_name, expand_path from pkg_resources import resource_filename, resource_string as resource_bytes from six.moves.configparser import ConfigParser, RawConfigParser from string import Template @@ -40,15 +44,6 @@ from zope.component import getUtility from zope.event import notify from zope.interface import implementer -import mailman.templates - -from mailman import version -from mailman.interfaces.configuration import ( - ConfigurationUpdatedEvent, IConfiguration, MissingConfigurationFileError) -from mailman.interfaces.languages import ILanguageManager -from mailman.utilities.filesystem import makedirs -from mailman.utilities.modules import call_name, expand_path - SPACE = ' ' diff --git a/src/mailman/config/tests/test_archivers.py b/src/mailman/config/tests/test_archivers.py index 08e466878..b74f680d9 100644 --- a/src/mailman/config/tests/test_archivers.py +++ b/src/mailman/config/tests/test_archivers.py @@ -17,9 +17,6 @@ """Site-wide archiver configuration tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestArchivers', ] diff --git a/src/mailman/config/tests/test_configuration.py b/src/mailman/config/tests/test_configuration.py index f6bee4209..b4b2145c0 100644 --- a/src/mailman/config/tests/test_configuration.py +++ b/src/mailman/config/tests/test_configuration.py @@ -17,9 +17,6 @@ """Test the system-wide global configuration.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestConfiguration', 'TestConfigurationErrors', diff --git a/src/mailman/core/chains.py b/src/mailman/core/chains.py index df4c199d5..610c396b0 100644 --- a/src/mailman/core/chains.py +++ b/src/mailman/core/chains.py @@ -17,21 +17,17 @@ """Application support for chain processing.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'initialize', 'process', ] -from zope.interface.verify import verifyObject - from mailman.chains.base import Chain, TerminalChainBase from mailman.config import config from mailman.interfaces.chain import LinkAction, IChain from mailman.utilities.modules import find_components +from zope.interface.verify import verifyObject diff --git a/src/mailman/core/constants.py b/src/mailman/core/constants.py index f8e354199..63fa0d0d8 100644 --- a/src/mailman/core/constants.py +++ b/src/mailman/core/constants.py @@ -17,21 +17,17 @@ """Various constants and enumerations.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'system_preferences', ] -from zope.component import getUtility -from zope.interface import implementer - from mailman.config import config from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.member import DeliveryMode, DeliveryStatus from mailman.interfaces.preferences import IPreferences +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/core/errors.py b/src/mailman/core/errors.py index b8f5a1f64..95b1ae821 100644 --- a/src/mailman/core/errors.py +++ b/src/mailman/core/errors.py @@ -26,9 +26,6 @@ interfaces. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AlreadyReceivingDigests', 'AlreadyReceivingRegularDeliveries', diff --git a/src/mailman/core/i18n.py b/src/mailman/core/i18n.py index b078a985f..ae9dcc8b8 100644 --- a/src/mailman/core/i18n.py +++ b/src/mailman/core/i18n.py @@ -17,9 +17,6 @@ """Internationalization.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ '_', 'ctime', @@ -28,11 +25,12 @@ __all__ = [ import time -from flufl.i18n import PackageStrategy, registry - import mailman.messages + +from flufl.i18n import PackageStrategy, registry from mailman.interfaces.configuration import ConfigurationUpdatedEvent + _ = None diff --git a/src/mailman/core/initialize.py b/src/mailman/core/initialize.py index 6c7196990..6c93a8162 100644 --- a/src/mailman/core/initialize.py +++ b/src/mailman/core/initialize.py @@ -24,9 +24,6 @@ line argument parsing, since some of the initialization behavior is controlled by the command line arguments. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'initialize', 'initialize_1', @@ -38,16 +35,15 @@ __all__ = [ import os import sys - -from pkg_resources import resource_string as resource_bytes -from zope.component import getUtility -from zope.configuration import xmlconfig - import mailman.config.config import mailman.core.logging from mailman.interfaces.database import IDatabaseFactory from mailman.utilities.modules import call_name +from pkg_resources import resource_string as resource_bytes +from zope.component import getUtility +from zope.configuration import xmlconfig + # The test infrastructure uses this to prevent the search and loading of any # existing configuration file. Otherwise the existence of say a diff --git a/src/mailman/core/logging.py b/src/mailman/core/logging.py index c5ce1a538..7529cc1d7 100644 --- a/src/mailman/core/logging.py +++ b/src/mailman/core/logging.py @@ -17,9 +17,6 @@ """Logging initialization, using Python's standard logging package.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'initialize', 'reopen', diff --git a/src/mailman/core/pipelines.py b/src/mailman/core/pipelines.py index 5fdba8358..b7773736c 100644 --- a/src/mailman/core/pipelines.py +++ b/src/mailman/core/pipelines.py @@ -17,9 +17,6 @@ """Built-in pipelines.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BasePipeline', 'OwnerPipeline', @@ -32,9 +29,6 @@ __all__ = [ import logging -from zope.interface import implementer -from zope.interface.verify import verifyObject - from mailman.app.bounces import bounce_message from mailman.config import config from mailman.core import errors @@ -42,6 +36,8 @@ from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler from mailman.interfaces.pipeline import IPipeline from mailman.utilities.modules import find_components +from zope.interface import implementer +from zope.interface.verify import verifyObject dlog = logging.getLogger('mailman.debug') diff --git a/src/mailman/core/rules.py b/src/mailman/core/rules.py index 1a2b9f56d..0110c07f7 100644 --- a/src/mailman/core/rules.py +++ b/src/mailman/core/rules.py @@ -17,19 +17,15 @@ """Various rule helpers""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'initialize', ] -from zope.interface.verify import verifyObject - from mailman.config import config from mailman.interfaces.rules import IRule from mailman.utilities.modules import find_components +from zope.interface.verify import verifyObject diff --git a/src/mailman/core/runner.py b/src/mailman/core/runner.py index 83f1b469c..1fabe0a8f 100644 --- a/src/mailman/core/runner.py +++ b/src/mailman/core/runner.py @@ -17,9 +17,6 @@ """The process runner base class.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Runner', ] diff --git a/src/mailman/core/switchboard.py b/src/mailman/core/switchboard.py index d4884c4c9..f54bc243a 100644 --- a/src/mailman/core/switchboard.py +++ b/src/mailman/core/switchboard.py @@ -24,9 +24,6 @@ written. First, the message is written to the pickle, then the metadata dictionary is written. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Switchboard', 'handle_ConfigurationUpdatedEvent', diff --git a/src/mailman/core/system.py b/src/mailman/core/system.py index 495cc37ee..0c01d94aa 100644 --- a/src/mailman/core/system.py +++ b/src/mailman/core/system.py @@ -17,9 +17,6 @@ """System information.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'system', ] @@ -27,10 +24,9 @@ __all__ = [ import sys -from zope.interface import implementer - from mailman import version from mailman.interfaces.system import ISystem +from zope.interface import implementer diff --git a/src/mailman/core/tests/test_pipelines.py b/src/mailman/core/tests/test_pipelines.py index 67e6af36e..91be1f79f 100644 --- a/src/mailman/core/tests/test_pipelines.py +++ b/src/mailman/core/tests/test_pipelines.py @@ -17,9 +17,6 @@ """Test the core modification pipelines.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestOwnerPipeline', 'TestPostingPipeline', @@ -28,9 +25,6 @@ __all__ = [ import unittest -from zope.component import getUtility -from zope.interface import implementer - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.core.errors import DiscardMessage, RejectMessage @@ -40,11 +34,11 @@ from mailman.interfaces.member import MemberRole from mailman.interfaces.pipeline import IPipeline from mailman.interfaces.usermanager import IUserManager from mailman.testing.helpers import ( - LogFileMark, - get_queue_messages, - reset_the_world, + LogFileMark, get_queue_messages, reset_the_world, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility +from zope.interface import implementer @@ -175,5 +169,5 @@ To: test-owner@example.com pipeline_name='default-owner-pipeline') messages = get_queue_messages('out', sort_on='to') self.assertEqual(len(messages), 1) - self.assertEqual(messages[0].msgdata['recipients'], + self.assertEqual(messages[0].msgdata['recipients'], set(('anne@example.com', 'bart@example.com'))) diff --git a/src/mailman/core/tests/test_runner.py b/src/mailman/core/tests/test_runner.py index 3ebddd7cc..3d2e76096 100644 --- a/src/mailman/core/tests/test_runner.py +++ b/src/mailman/core/tests/test_runner.py @@ -17,9 +17,6 @@ """Test some Runner base class behavior.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestRunner', ] diff --git a/src/mailman/database/alembic/__init__.py b/src/mailman/database/alembic/__init__.py index ffd3af6df..4dbbc31d9 100644 --- a/src/mailman/database/alembic/__init__.py +++ b/src/mailman/database/alembic/__init__.py @@ -17,9 +17,6 @@ """Alembic configuration initization.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'alembic_cfg', ] diff --git a/src/mailman/database/alembic/env.py b/src/mailman/database/alembic/env.py index 125868566..261782d29 100644 --- a/src/mailman/database/alembic/env.py +++ b/src/mailman/database/alembic/env.py @@ -17,9 +17,6 @@ """Alembic migration environment.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'run_migrations_offline', 'run_migrations_online', @@ -28,11 +25,10 @@ __all__ = [ from alembic import context from contextlib import closing -from sqlalchemy import create_engine - from mailman.config import config from mailman.database.model import Model from mailman.utilities.string import expand +from sqlalchemy import create_engine diff --git a/src/mailman/database/alembic/versions/51b7f92bd06c_initial.py b/src/mailman/database/alembic/versions/51b7f92bd06c_initial.py index 3feb24fff..5e3527abe 100644 --- a/src/mailman/database/alembic/versions/51b7f92bd06c_initial.py +++ b/src/mailman/database/alembic/versions/51b7f92bd06c_initial.py @@ -29,9 +29,6 @@ Revises: None Create Date: 2014-10-10 09:53:35.624472 """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'downgrade', 'upgrade', diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py index 55edf6005..09fd47b80 100644 --- a/src/mailman/database/base.py +++ b/src/mailman/database/base.py @@ -15,9 +15,8 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -from __future__ import absolute_import, print_function, unicode_literals +"""Common database support.""" -__metaclass__ = type __all__ = [ 'SABaseDatabase', ] @@ -25,17 +24,15 @@ __all__ = [ import logging -from sqlalchemy import create_engine -from sqlalchemy.orm import sessionmaker -from zope.interface import implementer - from mailman.config import config from mailman.interfaces.database import IDatabase from mailman.utilities.string import expand +from sqlalchemy import create_engine +from sqlalchemy.orm import sessionmaker +from zope.interface import implementer log = logging.getLogger('mailman.database') -NL = '\n' diff --git a/src/mailman/database/factory.py b/src/mailman/database/factory.py index 64174449d..9fffd4545 100644 --- a/src/mailman/database/factory.py +++ b/src/mailman/database/factory.py @@ -17,9 +17,6 @@ """Database factory.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'DatabaseFactory', 'DatabaseTestingFactory', @@ -33,16 +30,15 @@ import alembic.command from alembic.migration import MigrationContext from alembic.script import ScriptDirectory from flufl.lock import Lock -from sqlalchemy import MetaData -from zope.interface import implementer -from zope.interface.verify import verifyObject - from mailman.config import config from mailman.database.alembic import alembic_cfg from mailman.database.model import Model from mailman.interfaces.database import ( DatabaseError, IDatabase, IDatabaseFactory) from mailman.utilities.modules import call_name +from sqlalchemy import MetaData +from zope.interface import implementer +from zope.interface.verify import verifyObject LAST_STORM_SCHEMA_VERSION = '20130406000000' diff --git a/src/mailman/database/model.py b/src/mailman/database/model.py index a6056bf63..8dad6f0cf 100644 --- a/src/mailman/database/model.py +++ b/src/mailman/database/model.py @@ -17,9 +17,6 @@ """Base class for all database classes.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Model', ] diff --git a/src/mailman/database/postgresql.py b/src/mailman/database/postgresql.py index 717b69dd1..4a6f02da6 100644 --- a/src/mailman/database/postgresql.py +++ b/src/mailman/database/postgresql.py @@ -17,9 +17,6 @@ """PostgreSQL database support.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'PostgreSQLDatabase', ] diff --git a/src/mailman/database/sqlite.py b/src/mailman/database/sqlite.py index 8540846e1..95dba460e 100644 --- a/src/mailman/database/sqlite.py +++ b/src/mailman/database/sqlite.py @@ -17,9 +17,6 @@ """SQLite database support.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'SQLiteDatabase', ] diff --git a/src/mailman/database/tests/test_factory.py b/src/mailman/database/tests/test_factory.py index 29cca41ba..71f810a56 100644 --- a/src/mailman/database/tests/test_factory.py +++ b/src/mailman/database/tests/test_factory.py @@ -17,9 +17,6 @@ """Test database schema migrations""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestSchemaManager', ] @@ -28,17 +25,16 @@ __all__ = [ import unittest import alembic.command -from mock import patch -from sqlalchemy import MetaData, Table, Column, Integer, Unicode -from sqlalchemy.exc import ProgrammingError, OperationalError -from sqlalchemy.schema import Index - from mailman.config import config from mailman.database.alembic import alembic_cfg from mailman.database.factory import LAST_STORM_SCHEMA_VERSION, SchemaManager from mailman.database.model import Model from mailman.interfaces.database import DatabaseError from mailman.testing.layers import ConfigLayer +from mock import patch +from sqlalchemy import MetaData, Table, Column, Integer, Unicode +from sqlalchemy.exc import ProgrammingError, OperationalError +from sqlalchemy.schema import Index diff --git a/src/mailman/database/transaction.py b/src/mailman/database/transaction.py index 3e156cfb8..dc468aaab 100644 --- a/src/mailman/database/transaction.py +++ b/src/mailman/database/transaction.py @@ -17,9 +17,6 @@ """Transactional support.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'dbconnection', 'transaction', @@ -28,7 +25,6 @@ __all__ = [ from contextlib import contextmanager - from mailman.config import config diff --git a/src/mailman/database/types.py b/src/mailman/database/types.py index 1984b08b5..463d271f0 100644 --- a/src/mailman/database/types.py +++ b/src/mailman/database/types.py @@ -15,17 +15,14 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -"""Storm type conversions.""" +"""Database type conversions.""" - -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Enum', 'UUID', ] + import uuid from sqlalchemy import Integer diff --git a/src/mailman/docs/__init__.py b/src/mailman/docs/__init__.py index f588eb14d..fa09dde76 100644 --- a/src/mailman/docs/__init__.py +++ b/src/mailman/docs/__init__.py @@ -17,9 +17,6 @@ """General Mailman doc tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'layer', ] diff --git a/src/mailman/email/message.py b/src/mailman/email/message.py index d77afcbe0..d4b373bea 100644 --- a/src/mailman/email/message.py +++ b/src/mailman/email/message.py @@ -23,9 +23,6 @@ safe pickle deserialization, even if the email package adds additional Message attributes. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Message', 'MultipartDigestMessage', @@ -40,7 +37,6 @@ import email.utils from email.header import Header from email.mime.multipart import MIMEMultipart - from mailman.config import config diff --git a/src/mailman/email/tests/test_message.py b/src/mailman/email/tests/test_message.py index 280a86477..59335b890 100644 --- a/src/mailman/email/tests/test_message.py +++ b/src/mailman/email/tests/test_message.py @@ -17,9 +17,6 @@ """Test the message API.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMessage', 'TestMessageSubclass', @@ -27,8 +24,8 @@ __all__ = [ import unittest -from email.parser import FeedParser +from email.parser import FeedParser from mailman.app.lifecycle import create_list from mailman.email.message import Message, UserNotification from mailman.testing.helpers import get_queue_messages @@ -88,6 +85,6 @@ Test content attachment = msg.get_payload(1) try: filename = attachment.get_filename() - except TypeError as e: - self.fail(e) + except TypeError as error: + self.fail(error) self.assertEqual(filename, u'd\xe9jeuner.txt') diff --git a/src/mailman/email/validate.py b/src/mailman/email/validate.py index b4cf8b5e2..d6f664b01 100644 --- a/src/mailman/email/validate.py +++ b/src/mailman/email/validate.py @@ -17,9 +17,6 @@ """Email address validation.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Validator', ] @@ -27,11 +24,10 @@ __all__ = [ import re -from zope.interface import implementer - from mailman.interfaces.address import ( IEmailValidator, InvalidEmailAddressError) from mailman.utilities.email import split_email +from zope.interface import implementer # What other characters should be disallowed? diff --git a/src/mailman/handlers/acknowledge.py b/src/mailman/handlers/acknowledge.py index bd8b8861d..c10043981 100644 --- a/src/mailman/handlers/acknowledge.py +++ b/src/mailman/handlers/acknowledge.py @@ -20,23 +20,19 @@ This only happens if the sender has set their AcknowledgePosts attribute. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Acknowledge', ] -from zope.component import getUtility -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.email.message import UserNotification from mailman.interfaces.handler import IHandler from mailman.interfaces.languages import ILanguageManager from mailman.utilities.i18n import make from mailman.utilities.string import oneline +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/handlers/after_delivery.py b/src/mailman/handlers/after_delivery.py index 7fa7a4554..464fafd8c 100644 --- a/src/mailman/handlers/after_delivery.py +++ b/src/mailman/handlers/after_delivery.py @@ -17,19 +17,15 @@ """Perform some bookkeeping after a successful post.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AfterDelivery', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler from mailman.utilities.datetime import now +from zope.interface import implementer diff --git a/src/mailman/handlers/avoid_duplicates.py b/src/mailman/handlers/avoid_duplicates.py index 529a99f68..636a9f24d 100644 --- a/src/mailman/handlers/avoid_duplicates.py +++ b/src/mailman/handlers/avoid_duplicates.py @@ -23,19 +23,15 @@ has already received a copy, we either drop the message, add a duplicate warning header, or pass it through, depending on the user's preferences. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AvoidDuplicates', ] from email.utils import getaddresses, formataddr -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler +from zope.interface import implementer COMMASPACE = ', ' diff --git a/src/mailman/handlers/cleanse.py b/src/mailman/handlers/cleanse.py index 6b653bb34..0dad3077e 100644 --- a/src/mailman/handlers/cleanse.py +++ b/src/mailman/handlers/cleanse.py @@ -17,9 +17,6 @@ """Cleanse certain headers from all messages.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Cleanse', ] @@ -28,11 +25,10 @@ __all__ = [ import logging from email.utils import formataddr -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.handlers.cook_headers import uheader from mailman.interfaces.handler import IHandler +from zope.interface import implementer log = logging.getLogger('mailman.post') diff --git a/src/mailman/handlers/cleanse_dkim.py b/src/mailman/handlers/cleanse_dkim.py index 225666bf1..a4c16d31e 100644 --- a/src/mailman/handlers/cleanse_dkim.py +++ b/src/mailman/handlers/cleanse_dkim.py @@ -25,20 +25,16 @@ and it will also give the MTA the opportunity to regenerate valid keys originating at the Mailman server for the outgoing message. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'CleanseDKIM', ] from lazr.config import as_boolean -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler +from zope.interface import implementer diff --git a/src/mailman/handlers/cook_headers.py b/src/mailman/handlers/cook_headers.py index f37e8f0e2..44ef02e36 100644 --- a/src/mailman/handlers/cook_headers.py +++ b/src/mailman/handlers/cook_headers.py @@ -17,9 +17,6 @@ """Cook a message's headers.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'CookHeaders', ] @@ -29,18 +26,16 @@ import re from email.header import Header from email.utils import parseaddr, formataddr, getaddresses -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler from mailman.interfaces.mailinglist import Personalization, ReplyToMunging from mailman.version import VERSION +from zope.interface import implementer COMMASPACE = ', ' MAXLINELEN = 78 - -nonascii = re.compile('[^\s!-~]') +NONASCII = re.compile('[^\s!-~]') @@ -53,12 +48,12 @@ def uheader(mlist, s, header_name=None, continuation_ws='\t', maxlinelen=None): specified. """ charset = mlist.preferred_language.charset - if nonascii.search(s): + if NONASCII.search(s): # use list charset but ... if charset == 'us-ascii': charset = 'iso-8859-1' else: - # there is no nonascii so ... + # there is no non-ascii so ... charset = 'us-ascii' return Header(s, charset, maxlinelen, header_name, continuation_ws) diff --git a/src/mailman/handlers/decorate.py b/src/mailman/handlers/decorate.py index 03f0c009f..78fafb3ca 100644 --- a/src/mailman/handlers/decorate.py +++ b/src/mailman/handlers/decorate.py @@ -17,9 +17,6 @@ """Decorate a message by sticking the header and footer around it.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Decorate', 'decorate', diff --git a/src/mailman/handlers/file_recipients.py b/src/mailman/handlers/file_recipients.py index ec8868649..4b115bb53 100644 --- a/src/mailman/handlers/file_recipients.py +++ b/src/mailman/handlers/file_recipients.py @@ -17,9 +17,6 @@ """Get the normal delivery recipients from a Sendmail style :include: file.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'FileRecipients', ] @@ -28,10 +25,9 @@ __all__ = [ import os import errno -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler +from zope.interface import implementer diff --git a/src/mailman/handlers/member_recipients.py b/src/mailman/handlers/member_recipients.py index 0f99bf709..7497746eb 100644 --- a/src/mailman/handlers/member_recipients.py +++ b/src/mailman/handlers/member_recipients.py @@ -23,22 +23,18 @@ on the `recipients' attribute of the message. This attribute is used by the SendmailDeliver and BulkDeliver modules. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MemberRecipients', ] -from zope.interface import implementer - from mailman.config import config from mailman.core import errors from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler from mailman.interfaces.member import DeliveryStatus from mailman.utilities.string import wrap +from zope.interface import implementer diff --git a/src/mailman/handlers/mime_delete.py b/src/mailman/handlers/mime_delete.py index b5c937fdb..1d107522d 100644 --- a/src/mailman/handlers/mime_delete.py +++ b/src/mailman/handlers/mime_delete.py @@ -24,9 +24,6 @@ wrapping only single sections after other processing are replaced by their contents. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MIMEDelete', ] @@ -41,9 +38,6 @@ from email.iterators import typed_subpart_iterator from email.mime.message import MIMEMessage from email.mime.text import MIMEText from lazr.config import as_boolean -from os.path import splitext -from zope.interface import implementer - from mailman.config import config from mailman.core import errors from mailman.core.i18n import _ @@ -52,6 +46,8 @@ from mailman.interfaces.action import FilterAction from mailman.interfaces.handler import IHandler from mailman.utilities.string import oneline from mailman.version import VERSION +from os.path import splitext +from zope.interface import implementer log = logging.getLogger('mailman.error') diff --git a/src/mailman/handlers/owner_recipients.py b/src/mailman/handlers/owner_recipients.py index 5a1d0bd2e..dbb203728 100644 --- a/src/mailman/handlers/owner_recipients.py +++ b/src/mailman/handlers/owner_recipients.py @@ -17,20 +17,16 @@ """Calculate the list owner recipients (includes moderators).""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'OwnerRecipients', ] -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler from mailman.interfaces.member import DeliveryStatus +from zope.interface import implementer diff --git a/src/mailman/handlers/replybot.py b/src/mailman/handlers/replybot.py index 63f3ca4cf..44df2344e 100644 --- a/src/mailman/handlers/replybot.py +++ b/src/mailman/handlers/replybot.py @@ -17,9 +17,6 @@ """Handler for automatic responses.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Replybot', ] @@ -27,9 +24,6 @@ __all__ = [ import logging -from zope.component import getUtility -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.email.message import UserNotification from mailman.interfaces.autorespond import ( @@ -38,6 +32,8 @@ from mailman.interfaces.handler import IHandler from mailman.interfaces.usermanager import IUserManager from mailman.utilities.datetime import today from mailman.utilities.string import expand, wrap +from zope.component import getUtility +from zope.interface import implementer log = logging.getLogger('mailman.error') diff --git a/src/mailman/handlers/rfc_2369.py b/src/mailman/handlers/rfc_2369.py index ea909f41b..c835f2a67 100644 --- a/src/mailman/handlers/rfc_2369.py +++ b/src/mailman/handlers/rfc_2369.py @@ -17,22 +17,18 @@ """RFC 2369 List-* and related headers.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'RFC2369', ] from email.utils import formataddr -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.handlers.cook_headers import uheader from mailman.interfaces.archiver import ArchivePolicy from mailman.interfaces.mailinglist import IListArchiverSet from mailman.interfaces.handler import IHandler +from zope.interface import implementer CONTINUATION = ',\n\t' diff --git a/src/mailman/handlers/subject_prefix.py b/src/mailman/handlers/subject_prefix.py index ee1921ac2..20abd1036 100644 --- a/src/mailman/handlers/subject_prefix.py +++ b/src/mailman/handlers/subject_prefix.py @@ -17,9 +17,6 @@ """Subject header prefix munging.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'SubjectPrefix', ] diff --git a/src/mailman/handlers/tagger.py b/src/mailman/handlers/tagger.py index 51ff6b39e..199c5907f 100644 --- a/src/mailman/handlers/tagger.py +++ b/src/mailman/handlers/tagger.py @@ -17,9 +17,6 @@ """Extract topics from the original mail message.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Tagger', ] @@ -29,10 +26,9 @@ import re import email.iterators import email.parser -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler +from zope.interface import implementer OR = '|' diff --git a/src/mailman/handlers/tests/test_cook_headers.py b/src/mailman/handlers/tests/test_cook_headers.py index d83a44f20..385f402c5 100644 --- a/src/mailman/handlers/tests/test_cook_headers.py +++ b/src/mailman/handlers/tests/test_cook_headers.py @@ -17,9 +17,6 @@ """Test the cook_headers handler.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestCookHeaders', ] @@ -50,6 +47,6 @@ class TestCookHeaders(unittest.TestCase): for msg in messages: try: cook_headers.process(self._mlist, msg, {}) - except AttributeError as e: + except AttributeError as error: # LP: #1130696 would raise an AttributeError on .sender - self.fail(e) + self.fail(error) diff --git a/src/mailman/handlers/tests/test_file_recips.py b/src/mailman/handlers/tests/test_file_recips.py index 9f3e0ec6e..906530762 100644 --- a/src/mailman/handlers/tests/test_file_recips.py +++ b/src/mailman/handlers/tests/test_file_recips.py @@ -17,9 +17,6 @@ """Test file-recips handler.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestFileRecips', ] diff --git a/src/mailman/handlers/tests/test_filter.py b/src/mailman/handlers/tests/test_filter.py index 292e646cd..b81744008 100644 --- a/src/mailman/handlers/tests/test_filter.py +++ b/src/mailman/handlers/tests/test_filter.py @@ -17,9 +17,6 @@ """Test the filter handler.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestFilters', ] diff --git a/src/mailman/handlers/tests/test_mimedel.py b/src/mailman/handlers/tests/test_mimedel.py index c7c37152f..02cb275e0 100644 --- a/src/mailman/handlers/tests/test_mimedel.py +++ b/src/mailman/handlers/tests/test_mimedel.py @@ -17,9 +17,6 @@ """Test the mime_delete handler.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestDispose', ] @@ -27,8 +24,6 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.core import errors @@ -40,6 +35,7 @@ from mailman.testing.helpers import ( LogFileMark, configuration, get_queue_messages, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/handlers/tests/test_recipients.py b/src/mailman/handlers/tests/test_recipients.py index ef2021d2c..688dcce04 100644 --- a/src/mailman/handlers/tests/test_recipients.py +++ b/src/mailman/handlers/tests/test_recipients.py @@ -17,9 +17,6 @@ """Testing various recipients stuff.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMemberRecipients', 'TestOwnerRecipients', diff --git a/src/mailman/handlers/tests/test_subject_prefix.py b/src/mailman/handlers/tests/test_subject_prefix.py index 1125f3811..f4fd8c113 100644 --- a/src/mailman/handlers/tests/test_subject_prefix.py +++ b/src/mailman/handlers/tests/test_subject_prefix.py @@ -17,9 +17,6 @@ """Test the Subject header prefix munging..""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestSubjectPrefix', ] diff --git a/src/mailman/handlers/tests/test_to_digest.py b/src/mailman/handlers/tests/test_to_digest.py index 451ebf9a5..8562c3fd7 100644 --- a/src/mailman/handlers/tests/test_to_digest.py +++ b/src/mailman/handlers/tests/test_to_digest.py @@ -17,9 +17,6 @@ """Test the to_digest handler.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestToDigest', ] diff --git a/src/mailman/handlers/to_archive.py b/src/mailman/handlers/to_archive.py index d18742f3c..d8c61bc7d 100644 --- a/src/mailman/handlers/to_archive.py +++ b/src/mailman/handlers/to_archive.py @@ -17,20 +17,16 @@ """Add the message to the archives.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ToArchive', ] -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.archiver import ArchivePolicy from mailman.interfaces.handler import IHandler +from zope.interface import implementer diff --git a/src/mailman/handlers/to_digest.py b/src/mailman/handlers/to_digest.py index e2d6657b7..70aeb0dcc 100644 --- a/src/mailman/handlers/to_digest.py +++ b/src/mailman/handlers/to_digest.py @@ -17,9 +17,6 @@ """Add the message to the list's current digest.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ToDigest', ] @@ -27,8 +24,6 @@ __all__ = [ import os -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.email.message import Message @@ -36,6 +31,7 @@ from mailman.interfaces.digests import DigestFrequency from mailman.interfaces.handler import IHandler from mailman.utilities.datetime import now as right_now from mailman.utilities.mailbox import Mailbox +from zope.interface import implementer diff --git a/src/mailman/handlers/to_outgoing.py b/src/mailman/handlers/to_outgoing.py index 92fb7fee0..95686d9c7 100644 --- a/src/mailman/handlers/to_outgoing.py +++ b/src/mailman/handlers/to_outgoing.py @@ -22,19 +22,15 @@ posted to the list membership. Anything else that needs to go out to some recipient should just be placed in the out queue directly. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ToOutgoing', ] -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler +from zope.interface import implementer diff --git a/src/mailman/handlers/to_usenet.py b/src/mailman/handlers/to_usenet.py index 28c18c520..8d86ea86e 100644 --- a/src/mailman/handlers/to_usenet.py +++ b/src/mailman/handlers/to_usenet.py @@ -17,9 +17,6 @@ """Move the message to the mail->news queue.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ToUsenet', ] @@ -27,14 +24,13 @@ __all__ = [ import logging -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.handler import IHandler +from zope.interface import implementer -COMMASPACE = ', ' +COMMASPACE = ', ' log = logging.getLogger('mailman.error') diff --git a/src/mailman/interfaces/action.py b/src/mailman/interfaces/action.py index 5d4b150a3..c4147f57a 100644 --- a/src/mailman/interfaces/action.py +++ b/src/mailman/interfaces/action.py @@ -17,7 +17,6 @@ """Message actions.""" -__metaclass__ = type __all__ = [ 'Action', 'FilterAction', diff --git a/src/mailman/interfaces/address.py b/src/mailman/interfaces/address.py index 28a9e8ef4..24d0899f5 100644 --- a/src/mailman/interfaces/address.py +++ b/src/mailman/interfaces/address.py @@ -17,9 +17,6 @@ """Interface for email address related information.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AddressAlreadyLinkedError', 'AddressError', @@ -33,9 +30,8 @@ __all__ = [ ] -from zope.interface import Interface, Attribute - from mailman.interfaces.errors import MailmanError +from zope.interface import Interface, Attribute diff --git a/src/mailman/interfaces/archiver.py b/src/mailman/interfaces/archiver.py index 8b843bc60..b2fc4f1af 100644 --- a/src/mailman/interfaces/archiver.py +++ b/src/mailman/interfaces/archiver.py @@ -17,9 +17,6 @@ """Interface for archiving schemes.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ArchivePolicy', 'ClobberDate', diff --git a/src/mailman/interfaces/autorespond.py b/src/mailman/interfaces/autorespond.py index 8da2fc795..d53e181f0 100644 --- a/src/mailman/interfaces/autorespond.py +++ b/src/mailman/interfaces/autorespond.py @@ -17,9 +17,6 @@ """Autoresponder.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ALWAYS_REPLY', 'IAutoResponseRecord', @@ -33,6 +30,7 @@ from datetime import timedelta from enum import Enum from zope.interface import Interface, Attribute + ALWAYS_REPLY = timedelta() diff --git a/src/mailman/interfaces/bans.py b/src/mailman/interfaces/bans.py index 48b3415c8..ea19abc38 100644 --- a/src/mailman/interfaces/bans.py +++ b/src/mailman/interfaces/bans.py @@ -17,9 +17,6 @@ """Manager of email address bans.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IBan', 'IBanManager', diff --git a/src/mailman/interfaces/bounce.py b/src/mailman/interfaces/bounce.py index 8a0ffd4b2..9556830eb 100644 --- a/src/mailman/interfaces/bounce.py +++ b/src/mailman/interfaces/bounce.py @@ -17,9 +17,6 @@ """Interface to bounce detection components.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BounceContext', 'IBounceEvent', diff --git a/src/mailman/interfaces/chain.py b/src/mailman/interfaces/chain.py index 85bad22a4..788112f0b 100644 --- a/src/mailman/interfaces/chain.py +++ b/src/mailman/interfaces/chain.py @@ -17,9 +17,6 @@ """Interfaces describing the basics of chains and links.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AcceptEvent', 'AcceptOwnerEvent', diff --git a/src/mailman/interfaces/command.py b/src/mailman/interfaces/command.py index 720e59ee8..a73d0b1de 100644 --- a/src/mailman/interfaces/command.py +++ b/src/mailman/interfaces/command.py @@ -17,9 +17,6 @@ """Interfaces defining email commands.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ContinueProcessing', 'ICLISubCommand', diff --git a/src/mailman/interfaces/configuration.py b/src/mailman/interfaces/configuration.py index 65547d44d..49d0bb3c6 100644 --- a/src/mailman/interfaces/configuration.py +++ b/src/mailman/interfaces/configuration.py @@ -17,9 +17,6 @@ """Configuration system interface.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ConfigurationUpdatedEvent', 'IConfiguration', @@ -27,9 +24,8 @@ __all__ = [ ] -from zope.interface import Interface - from mailman.core.errors import MailmanError +from zope.interface import Interface diff --git a/src/mailman/interfaces/database.py b/src/mailman/interfaces/database.py index 9ca05b747..37830329a 100644 --- a/src/mailman/interfaces/database.py +++ b/src/mailman/interfaces/database.py @@ -17,9 +17,6 @@ """Interfaces for database interaction.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'DatabaseError', 'IDatabase', diff --git a/src/mailman/interfaces/digests.py b/src/mailman/interfaces/digests.py index c5231e488..c343669f5 100644 --- a/src/mailman/interfaces/digests.py +++ b/src/mailman/interfaces/digests.py @@ -17,9 +17,6 @@ """One last digest.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IOneLastDigest' ] diff --git a/src/mailman/interfaces/domain.py b/src/mailman/interfaces/domain.py index a4f929ddb..aed76ebe9 100644 --- a/src/mailman/interfaces/domain.py +++ b/src/mailman/interfaces/domain.py @@ -17,9 +17,6 @@ """Interface representing domains.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BadDomainSpecificationError', 'DomainCreatedEvent', diff --git a/src/mailman/interfaces/errors.py b/src/mailman/interfaces/errors.py index 187c329b3..ecb4270f1 100644 --- a/src/mailman/interfaces/errors.py +++ b/src/mailman/interfaces/errors.py @@ -22,9 +22,6 @@ components. More specific exceptions will be located in the relevant interfaces. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MailmanError', ] diff --git a/src/mailman/interfaces/handler.py b/src/mailman/interfaces/handler.py index 2e6c3fa20..6c52f017b 100644 --- a/src/mailman/interfaces/handler.py +++ b/src/mailman/interfaces/handler.py @@ -17,9 +17,6 @@ """Interface describing a pipeline handler.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IHandler', ] diff --git a/src/mailman/interfaces/languages.py b/src/mailman/interfaces/languages.py index 9e88dd78f..810de7af1 100644 --- a/src/mailman/interfaces/languages.py +++ b/src/mailman/interfaces/languages.py @@ -17,9 +17,6 @@ """Interfaces for managing languages.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ILanguage', 'ILanguageManager', diff --git a/src/mailman/interfaces/listmanager.py b/src/mailman/interfaces/listmanager.py index 7fe8ed35a..27b6b5838 100644 --- a/src/mailman/interfaces/listmanager.py +++ b/src/mailman/interfaces/listmanager.py @@ -17,9 +17,6 @@ """Interface for list storage, deleting, and finding.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IListManager', 'ListAlreadyExistsError', diff --git a/src/mailman/interfaces/mailinglist.py b/src/mailman/interfaces/mailinglist.py index 3900e3349..2d145dc6c 100644 --- a/src/mailman/interfaces/mailinglist.py +++ b/src/mailman/interfaces/mailinglist.py @@ -17,9 +17,6 @@ """Interface for a mailing list.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IAcceptableAlias', 'IAcceptableAliasSet', @@ -32,9 +29,8 @@ __all__ = [ from enum import Enum -from zope.interface import Interface, Attribute - from mailman.interfaces.member import MemberRole +from zope.interface import Interface, Attribute diff --git a/src/mailman/interfaces/member.py b/src/mailman/interfaces/member.py index e2a5dc4fe..9e3917b86 100644 --- a/src/mailman/interfaces/member.py +++ b/src/mailman/interfaces/member.py @@ -17,9 +17,6 @@ """Interface describing the basics of a member.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AlreadySubscribedError', 'DeliveryMode', @@ -37,9 +34,8 @@ __all__ = [ from enum import Enum -from zope.interface import Interface, Attribute - from mailman.core.errors import MailmanError +from zope.interface import Interface, Attribute diff --git a/src/mailman/interfaces/messages.py b/src/mailman/interfaces/messages.py index 7b99578c4..c78971dfd 100644 --- a/src/mailman/interfaces/messages.py +++ b/src/mailman/interfaces/messages.py @@ -17,9 +17,6 @@ """The message storage service.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IMessage', 'IMessageStore', diff --git a/src/mailman/interfaces/mime.py b/src/mailman/interfaces/mime.py index 4729c426c..11feca331 100644 --- a/src/mailman/interfaces/mime.py +++ b/src/mailman/interfaces/mime.py @@ -17,9 +17,6 @@ """MIME content filtering.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'FilterAction', 'FilterType', diff --git a/src/mailman/interfaces/mlistrequest.py b/src/mailman/interfaces/mlistrequest.py index 77451f8bf..2af0f1776 100644 --- a/src/mailman/interfaces/mlistrequest.py +++ b/src/mailman/interfaces/mlistrequest.py @@ -17,9 +17,6 @@ """Interface for a web request accessing a mailing list.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IMailingListRequest', ] diff --git a/src/mailman/interfaces/mta.py b/src/mailman/interfaces/mta.py index 22c3d121e..44c0aba42 100644 --- a/src/mailman/interfaces/mta.py +++ b/src/mailman/interfaces/mta.py @@ -17,9 +17,6 @@ """Interface for mail transport agent integration.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IMailTransportAgentAliases', 'IMailTransportAgentDelivery', @@ -27,9 +24,8 @@ __all__ = [ ] -from zope.interface import Interface - from mailman.core.errors import MailmanError +from zope.interface import Interface diff --git a/src/mailman/interfaces/nntp.py b/src/mailman/interfaces/nntp.py index 8e73c2c50..46d705489 100644 --- a/src/mailman/interfaces/nntp.py +++ b/src/mailman/interfaces/nntp.py @@ -17,9 +17,6 @@ """NNTP and newsgroup interfaces.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'NewsgroupModeration', ] diff --git a/src/mailman/interfaces/pending.py b/src/mailman/interfaces/pending.py index a97552306..ff156d95a 100644 --- a/src/mailman/interfaces/pending.py +++ b/src/mailman/interfaces/pending.py @@ -22,9 +22,6 @@ maps these events to a unique hash that can be used as a token for end user confirmation. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IPendable', 'IPended', diff --git a/src/mailman/interfaces/permissions.py b/src/mailman/interfaces/permissions.py index 8d06e9ffb..cf32936ff 100644 --- a/src/mailman/interfaces/permissions.py +++ b/src/mailman/interfaces/permissions.py @@ -17,9 +17,6 @@ """Interfaces for various permissions.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IPostingPermission', ] diff --git a/src/mailman/interfaces/pipeline.py b/src/mailman/interfaces/pipeline.py index 817ebfc62..4ce11d8a6 100644 --- a/src/mailman/interfaces/pipeline.py +++ b/src/mailman/interfaces/pipeline.py @@ -17,9 +17,6 @@ """Interface for describing pipelines.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IPipeline', ] @@ -37,4 +34,3 @@ class IPipeline(Interface): def __iter__(): """Iterate over all the handlers in this pipeline.""" - diff --git a/src/mailman/interfaces/preferences.py b/src/mailman/interfaces/preferences.py index 27ae49faa..b68d7a0f5 100644 --- a/src/mailman/interfaces/preferences.py +++ b/src/mailman/interfaces/preferences.py @@ -17,9 +17,6 @@ """Interface for preferences.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IPreferences', ] diff --git a/src/mailman/interfaces/registrar.py b/src/mailman/interfaces/registrar.py index 413f3284e..df7c4ed86 100644 --- a/src/mailman/interfaces/registrar.py +++ b/src/mailman/interfaces/registrar.py @@ -22,9 +22,6 @@ etc. than the IUserManager. The latter does no validation, syntax checking, or confirmation, while this interface does. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ConfirmationNeededEvent', 'IRegistrar', diff --git a/src/mailman/interfaces/requests.py b/src/mailman/interfaces/requests.py index 4dcb3cace..ed3540e4c 100644 --- a/src/mailman/interfaces/requests.py +++ b/src/mailman/interfaces/requests.py @@ -21,9 +21,6 @@ The request database handles events that must be approved by the list moderators, such as subscription requests and held messages. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IListRequests', 'RequestType', diff --git a/src/mailman/interfaces/roster.py b/src/mailman/interfaces/roster.py index c4a7f5567..79c9fd573 100644 --- a/src/mailman/interfaces/roster.py +++ b/src/mailman/interfaces/roster.py @@ -17,9 +17,6 @@ """Interface for a roster of members.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IRoster', ] diff --git a/src/mailman/interfaces/rules.py b/src/mailman/interfaces/rules.py index feb773fca..2118a0b43 100644 --- a/src/mailman/interfaces/rules.py +++ b/src/mailman/interfaces/rules.py @@ -17,9 +17,6 @@ """Interface describing the basics of rules.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IRule', ] diff --git a/src/mailman/interfaces/runner.py b/src/mailman/interfaces/runner.py index 9cb554597..74038ab71 100644 --- a/src/mailman/interfaces/runner.py +++ b/src/mailman/interfaces/runner.py @@ -17,9 +17,6 @@ """Interface for runners.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IRunner', 'RunnerCrashEvent', diff --git a/src/mailman/interfaces/styles.py b/src/mailman/interfaces/styles.py index 33ab8ee84..615cb6abd 100644 --- a/src/mailman/interfaces/styles.py +++ b/src/mailman/interfaces/styles.py @@ -17,9 +17,6 @@ """Interfaces for list styles.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'DuplicateStyleError', 'IStyle', @@ -27,8 +24,8 @@ __all__ = [ ] -from zope.interface import Interface, Attribute from mailman.interfaces.errors import MailmanError +from zope.interface import Interface, Attribute diff --git a/src/mailman/interfaces/subscriptions.py b/src/mailman/interfaces/subscriptions.py index 64d4280d6..036cc4631 100644 --- a/src/mailman/interfaces/subscriptions.py +++ b/src/mailman/interfaces/subscriptions.py @@ -17,18 +17,14 @@ """Membership interface for REST.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ISubscriptionService', ] -from zope.interface import Interface - from mailman.interfaces.errors import MailmanError from mailman.interfaces.member import DeliveryMode, MemberRole +from zope.interface import Interface diff --git a/src/mailman/interfaces/switchboard.py b/src/mailman/interfaces/switchboard.py index ae613700a..c763c142b 100644 --- a/src/mailman/interfaces/switchboard.py +++ b/src/mailman/interfaces/switchboard.py @@ -17,9 +17,6 @@ """Interface for switchboards.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ISwitchboard', ] diff --git a/src/mailman/interfaces/system.py b/src/mailman/interfaces/system.py index 83992629c..36aa3279e 100644 --- a/src/mailman/interfaces/system.py +++ b/src/mailman/interfaces/system.py @@ -17,9 +17,6 @@ """System information.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ISystem', ] diff --git a/src/mailman/interfaces/templates.py b/src/mailman/interfaces/templates.py index de5fa11a9..9e39747a3 100644 --- a/src/mailman/interfaces/templates.py +++ b/src/mailman/interfaces/templates.py @@ -17,9 +17,6 @@ """Template downloader with cache.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ITemplateLoader', ] diff --git a/src/mailman/interfaces/user.py b/src/mailman/interfaces/user.py index e1c1df243..c42bb6c33 100644 --- a/src/mailman/interfaces/user.py +++ b/src/mailman/interfaces/user.py @@ -17,9 +17,6 @@ """Interface describing the basics of a user.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IUser', 'PasswordChangeEvent', @@ -27,9 +24,8 @@ __all__ = [ ] -from zope.interface import Interface, Attribute - from mailman.interfaces.address import AddressError +from zope.interface import Interface, Attribute diff --git a/src/mailman/interfaces/usermanager.py b/src/mailman/interfaces/usermanager.py index f37d39f6a..ab58347dc 100644 --- a/src/mailman/interfaces/usermanager.py +++ b/src/mailman/interfaces/usermanager.py @@ -17,9 +17,6 @@ """Interface describing the user management service.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IUserManager', ] diff --git a/src/mailman/languages/language.py b/src/mailman/languages/language.py index 35e142559..de406e10c 100644 --- a/src/mailman/languages/language.py +++ b/src/mailman/languages/language.py @@ -18,17 +18,13 @@ """The representation of a language.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Language', ] -from zope.interface import implementer - from mailman.interfaces.languages import ILanguage +from zope.interface import implementer diff --git a/src/mailman/languages/manager.py b/src/mailman/languages/manager.py index 7e73c11b0..2732d490a 100644 --- a/src/mailman/languages/manager.py +++ b/src/mailman/languages/manager.py @@ -17,20 +17,16 @@ """Language manager.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'LanguageManager', ] -from zope.component import getUtility -from zope.interface import implementer - from mailman.interfaces.configuration import ConfigurationUpdatedEvent from mailman.interfaces.languages import ILanguageManager from mailman.languages.language import Language +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/model/address.py b/src/mailman/model/address.py index 5d1994567..5ded77dd8 100644 --- a/src/mailman/model/address.py +++ b/src/mailman/model/address.py @@ -17,26 +17,22 @@ """Model for addresses.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Address', ] from email.utils import formataddr +from mailman.database.model import Model +from mailman.interfaces.address import ( + AddressVerificationEvent, IAddress, IEmailValidator) +from mailman.utilities.datetime import now from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode from sqlalchemy.orm import relationship, backref from zope.component import getUtility from zope.event import notify from zope.interface import implementer -from mailman.database.model import Model -from mailman.interfaces.address import ( - AddressVerificationEvent, IAddress, IEmailValidator) -from mailman.utilities.datetime import now - @implementer(IAddress) diff --git a/src/mailman/model/autorespond.py b/src/mailman/model/autorespond.py index cfb9e017d..332d04521 100644 --- a/src/mailman/model/autorespond.py +++ b/src/mailman/model/autorespond.py @@ -17,25 +17,21 @@ """Module stuff.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AutoResponseRecord', 'AutoResponseSet', ] -from sqlalchemy import Column, Date, ForeignKey, Integer, desc -from sqlalchemy.orm import relationship -from zope.interface import implementer - from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.database.types import Enum from mailman.interfaces.autorespond import ( IAutoResponseRecord, IAutoResponseSet, Response) from mailman.utilities.datetime import today +from sqlalchemy import Column, Date, ForeignKey, Integer, desc +from sqlalchemy.orm import relationship +from zope.interface import implementer diff --git a/src/mailman/model/bans.py b/src/mailman/model/bans.py index 8678fc1e7..3ad11cbf6 100644 --- a/src/mailman/model/bans.py +++ b/src/mailman/model/bans.py @@ -17,9 +17,6 @@ """Ban manager.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BanManager', ] @@ -27,12 +24,11 @@ __all__ = [ import re -from sqlalchemy import Column, Integer, Unicode -from zope.interface import implementer - from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.interfaces.bans import IBan, IBanManager +from sqlalchemy import Column, Integer, Unicode +from zope.interface import implementer diff --git a/src/mailman/model/bounce.py b/src/mailman/model/bounce.py index 26ebbe0c6..585a92594 100644 --- a/src/mailman/model/bounce.py +++ b/src/mailman/model/bounce.py @@ -17,9 +17,6 @@ """Bounce support.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BounceEvent', 'BounceProcessor', @@ -27,15 +24,14 @@ __all__ = [ -from sqlalchemy import Boolean, Column, DateTime, Integer, Unicode -from zope.interface import implementer - from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.database.types import Enum from mailman.interfaces.bounce import ( BounceContext, IBounceEvent, IBounceProcessor) from mailman.utilities.datetime import now +from sqlalchemy import Boolean, Column, DateTime, Integer, Unicode +from zope.interface import implementer diff --git a/src/mailman/model/digests.py b/src/mailman/model/digests.py index 7bfd512b6..8e8f7dedd 100644 --- a/src/mailman/model/digests.py +++ b/src/mailman/model/digests.py @@ -17,22 +17,18 @@ """One last digest.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'OneLastDigest', ] -from sqlalchemy import Column, Integer, ForeignKey -from sqlalchemy.orm import relationship -from zope.interface import implementer - from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.digests import IOneLastDigest from mailman.interfaces.member import DeliveryMode +from sqlalchemy import Column, Integer, ForeignKey +from sqlalchemy.orm import relationship +from zope.interface import implementer diff --git a/src/mailman/model/domain.py b/src/mailman/model/domain.py index a9020e816..b9d2c88ab 100644 --- a/src/mailman/model/domain.py +++ b/src/mailman/model/domain.py @@ -17,9 +17,6 @@ """Domains.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Domain', 'DomainManager', diff --git a/src/mailman/model/language.py b/src/mailman/model/language.py index f4d48fc97..7317b6328 100644 --- a/src/mailman/model/language.py +++ b/src/mailman/model/language.py @@ -17,19 +17,15 @@ """Model for languages.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Language', ] -from sqlalchemy import Column, Integer, Unicode -from zope.interface import implementer - from mailman.database.model import Model from mailman.interfaces.languages import ILanguage +from sqlalchemy import Column, Integer, Unicode +from zope.interface import implementer diff --git a/src/mailman/model/listmanager.py b/src/mailman/model/listmanager.py index 261490a92..7c228bcb9 100644 --- a/src/mailman/model/listmanager.py +++ b/src/mailman/model/listmanager.py @@ -17,17 +17,11 @@ """A mailing list manager.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ListManager', ] -from zope.event import notify -from zope.interface import implementer - from mailman.database.transaction import dbconnection from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import ( @@ -36,6 +30,8 @@ from mailman.interfaces.listmanager import ( from mailman.model.mailinglist import MailingList from mailman.model.mime import ContentFilter from mailman.utilities.datetime import now +from zope.event import notify +from zope.interface import implementer diff --git a/src/mailman/model/mailinglist.py b/src/mailman/model/mailinglist.py index 8e42bb172..ea3317bb6 100644 --- a/src/mailman/model/mailinglist.py +++ b/src/mailman/model/mailinglist.py @@ -17,9 +17,6 @@ """Model for mailing lists.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MailingList', ] diff --git a/src/mailman/model/member.py b/src/mailman/model/member.py index 9da9d5d0d..19a30074e 100644 --- a/src/mailman/model/member.py +++ b/src/mailman/model/member.py @@ -17,18 +17,10 @@ """Model for members.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Member', ] -from sqlalchemy import Column, ForeignKey, Integer, Unicode -from sqlalchemy.orm import relationship -from zope.component import getUtility -from zope.event import notify -from zope.interface import implementer from mailman.core.constants import system_preferences from mailman.database.model import Model @@ -42,6 +34,11 @@ from mailman.interfaces.member import ( from mailman.interfaces.user import IUser, UnverifiedAddressError from mailman.interfaces.usermanager import IUserManager from mailman.utilities.uid import UniqueIDFactory +from sqlalchemy import Column, ForeignKey, Integer, Unicode +from sqlalchemy.orm import relationship +from zope.component import getUtility +from zope.event import notify +from zope.interface import implementer uid_factory = UniqueIDFactory(context='members') diff --git a/src/mailman/model/message.py b/src/mailman/model/message.py index 099e5a511..105066daa 100644 --- a/src/mailman/model/message.py +++ b/src/mailman/model/message.py @@ -17,19 +17,16 @@ """Model for messages.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Message', ] -from sqlalchemy import Column, Integer, Unicode -from zope.interface import implementer from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.interfaces.messages import IMessage +from sqlalchemy import Column, Integer, Unicode +from zope.interface import implementer diff --git a/src/mailman/model/messagestore.py b/src/mailman/model/messagestore.py index 8dbe19b80..05069119c 100644 --- a/src/mailman/model/messagestore.py +++ b/src/mailman/model/messagestore.py @@ -17,9 +17,6 @@ """Model for message stores.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MessageStore', ] diff --git a/src/mailman/model/mime.py b/src/mailman/model/mime.py index dc6a54437..240fd6e2b 100644 --- a/src/mailman/model/mime.py +++ b/src/mailman/model/mime.py @@ -17,21 +17,17 @@ """The content filter.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ContentFilter' ] -from sqlalchemy import Column, ForeignKey, Integer, Unicode -from sqlalchemy.orm import relationship -from zope.interface import implementer - from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.mime import IContentFilter, FilterType +from sqlalchemy import Column, ForeignKey, Integer, Unicode +from sqlalchemy.orm import relationship +from zope.interface import implementer diff --git a/src/mailman/model/pending.py b/src/mailman/model/pending.py index 80fbeafe2..05cea4e29 100644 --- a/src/mailman/model/pending.py +++ b/src/mailman/model/pending.py @@ -17,9 +17,6 @@ """Implementations of the IPendable and IPending interfaces.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Pended', 'Pendings', @@ -32,18 +29,16 @@ import random import hashlib from lazr.config import as_timedelta -from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode -from sqlalchemy.orm import relationship -from zope.interface import implementer -from zope.interface.verify import verifyObject - from mailman.config import config from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.interfaces.pending import ( IPendable, IPended, IPendedKeyValue, IPendings) from mailman.utilities.datetime import now -from mailman.utilities.modules import call_name +from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode +from sqlalchemy.orm import relationship +from zope.interface import implementer +from zope.interface.verify import verifyObject diff --git a/src/mailman/model/preferences.py b/src/mailman/model/preferences.py index 1278f80b7..8cec6036e 100644 --- a/src/mailman/model/preferences.py +++ b/src/mailman/model/preferences.py @@ -17,23 +17,19 @@ """Model for preferences.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Preferences', ] -from sqlalchemy import Boolean, Column, Integer, Unicode -from zope.component import getUtility -from zope.interface import implementer - from mailman.database.model import Model from mailman.database.types import Enum from mailman.interfaces.languages import ILanguageManager from mailman.interfaces.member import DeliveryMode, DeliveryStatus from mailman.interfaces.preferences import IPreferences +from sqlalchemy import Boolean, Column, Integer, Unicode +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/model/requests.py b/src/mailman/model/requests.py index 394084b71..9d9692b30 100644 --- a/src/mailman/model/requests.py +++ b/src/mailman/model/requests.py @@ -17,10 +17,9 @@ """Implementations of the pending requests interfaces.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'DataPendable', + 'ListRequests', ] diff --git a/src/mailman/model/roster.py b/src/mailman/model/roster.py index 54bc11617..7ea3ad2a4 100644 --- a/src/mailman/model/roster.py +++ b/src/mailman/model/roster.py @@ -22,9 +22,6 @@ the ones that fit a particular role. These are used as the member, owner, moderator, and administrator roster filters. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AdministratorRoster', 'DigestMemberRoster', @@ -37,14 +34,13 @@ __all__ = [ ] -from sqlalchemy import and_, or_ -from zope.interface import implementer - from mailman.database.transaction import dbconnection from mailman.interfaces.member import DeliveryMode, MemberRole from mailman.interfaces.roster import IRoster from mailman.model.address import Address from mailman.model.member import Member +from sqlalchemy import and_, or_ +from zope.interface import implementer diff --git a/src/mailman/model/tests/test_address.py b/src/mailman/model/tests/test_address.py index 7de77c019..29b32f542 100644 --- a/src/mailman/model/tests/test_address.py +++ b/src/mailman/model/tests/test_address.py @@ -17,9 +17,6 @@ """Test addresses.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestAddress', ] diff --git a/src/mailman/model/tests/test_bounce.py b/src/mailman/model/tests/test_bounce.py index a22da4416..2929747bc 100644 --- a/src/mailman/model/tests/test_bounce.py +++ b/src/mailman/model/tests/test_bounce.py @@ -17,24 +17,21 @@ """Test bounce model objects.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestBounceEvents', ] import unittest from datetime import datetime -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.database.transaction import transaction from mailman.interfaces.bounce import BounceContext, IBounceProcessor from mailman.testing.helpers import ( specialized_message_from_string as message_from_string) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/model/tests/test_domain.py b/src/mailman/model/tests/test_domain.py index 88e2fe312..a483d9567 100644 --- a/src/mailman/model/tests/test_domain.py +++ b/src/mailman/model/tests/test_domain.py @@ -17,9 +17,6 @@ """Test domains.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestDomainLifecycleEvents', 'TestDomainManager', @@ -28,8 +25,6 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.interfaces.domain import ( DomainCreatedEvent, DomainCreatingEvent, DomainDeletedEvent, @@ -37,6 +32,7 @@ from mailman.interfaces.domain import ( from mailman.interfaces.listmanager import IListManager from mailman.testing.helpers import event_subscribers from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/model/tests/test_listmanager.py b/src/mailman/model/tests/test_listmanager.py index 5582b46c1..a28698eb1 100644 --- a/src/mailman/model/tests/test_listmanager.py +++ b/src/mailman/model/tests/test_listmanager.py @@ -17,9 +17,6 @@ """Test the ListManager.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestListCreation', 'TestListLifecycleEvents', diff --git a/src/mailman/model/tests/test_mailinglist.py b/src/mailman/model/tests/test_mailinglist.py index 2fd000422..6e7c11fe6 100644 --- a/src/mailman/model/tests/test_mailinglist.py +++ b/src/mailman/model/tests/test_mailinglist.py @@ -17,9 +17,6 @@ """Test MailingLists and related model objects..""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestDisabledListArchiver', 'TestListArchiver', diff --git a/src/mailman/model/tests/test_member.py b/src/mailman/model/tests/test_member.py index 5bd3d1594..38f36acde 100644 --- a/src/mailman/model/tests/test_member.py +++ b/src/mailman/model/tests/test_member.py @@ -17,9 +17,6 @@ """Test members.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMember', ] diff --git a/src/mailman/model/tests/test_messagestore.py b/src/mailman/model/tests/test_messagestore.py index 9661a109e..39d1d97ed 100644 --- a/src/mailman/model/tests/test_messagestore.py +++ b/src/mailman/model/tests/test_messagestore.py @@ -17,9 +17,6 @@ """Test the message store.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMessageStore', ] diff --git a/src/mailman/model/tests/test_requests.py b/src/mailman/model/tests/test_requests.py index 419c6077f..c47c61013 100644 --- a/src/mailman/model/tests/test_requests.py +++ b/src/mailman/model/tests/test_requests.py @@ -17,9 +17,6 @@ """Test the various pending requests interfaces.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestRequests', ] diff --git a/src/mailman/model/tests/test_roster.py b/src/mailman/model/tests/test_roster.py index 5bd06f485..8cf189e08 100644 --- a/src/mailman/model/tests/test_roster.py +++ b/src/mailman/model/tests/test_roster.py @@ -17,9 +17,6 @@ """Test rosters.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMailingListRoster', 'TestMembershipsRoster', @@ -28,13 +25,12 @@ __all__ = [ import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.interfaces.member import DeliveryMode, MemberRole from mailman.interfaces.usermanager import IUserManager from mailman.testing.layers import ConfigLayer from mailman.utilities.datetime import now +from zope.component import getUtility diff --git a/src/mailman/model/tests/test_uid.py b/src/mailman/model/tests/test_uid.py index 4c541205a..dd61ccc51 100644 --- a/src/mailman/model/tests/test_uid.py +++ b/src/mailman/model/tests/test_uid.py @@ -17,10 +17,8 @@ """Test the UID model class.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestUID', ] diff --git a/src/mailman/model/tests/test_user.py b/src/mailman/model/tests/test_user.py index c0da87515..ba5ba116f 100644 --- a/src/mailman/model/tests/test_user.py +++ b/src/mailman/model/tests/test_user.py @@ -17,9 +17,6 @@ """Test users.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestUser', ] diff --git a/src/mailman/model/uid.py b/src/mailman/model/uid.py index 72ddd7b5a..94a4f1a17 100644 --- a/src/mailman/model/uid.py +++ b/src/mailman/model/uid.py @@ -17,20 +17,16 @@ """Unique IDs.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'UID', ] -from sqlalchemy import Column, Integer - from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.database.types import UUID +from sqlalchemy import Column, Integer diff --git a/src/mailman/model/user.py b/src/mailman/model/user.py index 3a268fd6f..a85ef0d00 100644 --- a/src/mailman/model/user.py +++ b/src/mailman/model/user.py @@ -17,19 +17,11 @@ """Model for users.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'User', ] -from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode -from sqlalchemy.orm import relationship, backref -from zope.event import notify -from zope.interface import implementer - from mailman.database.model import Model from mailman.database.transaction import dbconnection from mailman.database.types import UUID @@ -42,6 +34,10 @@ from mailman.model.preferences import Preferences from mailman.model.roster import Memberships from mailman.utilities.datetime import factory as date_factory from mailman.utilities.uid import UniqueIDFactory +from sqlalchemy import Column, DateTime, ForeignKey, Integer, Unicode +from sqlalchemy.orm import relationship, backref +from zope.event import notify +from zope.interface import implementer uid_factory = UniqueIDFactory(context='users') diff --git a/src/mailman/model/usermanager.py b/src/mailman/model/usermanager.py index 726aa6120..374352033 100644 --- a/src/mailman/model/usermanager.py +++ b/src/mailman/model/usermanager.py @@ -17,16 +17,11 @@ """A user manager.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'UserManager', ] -from zope.interface import implementer - from mailman.database.transaction import dbconnection from mailman.interfaces.address import ExistingAddressError from mailman.interfaces.usermanager import IUserManager @@ -34,6 +29,7 @@ from mailman.model.address import Address from mailman.model.member import Member from mailman.model.preferences import Preferences from mailman.model.user import User +from zope.interface import implementer diff --git a/src/mailman/mta/aliases.py b/src/mailman/mta/aliases.py index 1b5f37d44..c309fb27b 100644 --- a/src/mailman/mta/aliases.py +++ b/src/mailman/mta/aliases.py @@ -17,17 +17,13 @@ """Utility for generating all the aliases of a mailing list.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MailTransportAgentAliases', ] -from zope.interface import implementer - from mailman.interfaces.mta import IMailTransportAgentAliases +from zope.interface import implementer SUBDESTINATIONS = ( diff --git a/src/mailman/mta/base.py b/src/mailman/mta/base.py index 7b9180ea3..8d7ca75af 100644 --- a/src/mailman/mta/base.py +++ b/src/mailman/mta/base.py @@ -17,9 +17,6 @@ """Base delivery class.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BaseDelivery', 'IndividualDelivery', @@ -31,11 +28,10 @@ import socket import logging import smtplib -from zope.interface import implementer - from mailman.config import config from mailman.interfaces.mta import IMailTransportAgentDelivery from mailman.mta.connection import Connection +from zope.interface import implementer log = logging.getLogger('mailman.smtp') diff --git a/src/mailman/mta/bulk.py b/src/mailman/mta/bulk.py index 4255e0c33..0dcd2cdf6 100644 --- a/src/mailman/mta/bulk.py +++ b/src/mailman/mta/bulk.py @@ -17,9 +17,6 @@ """Bulk message delivery.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BulkDelivery', ] @@ -108,4 +105,3 @@ class BulkDelivery(BaseDelivery): mlist, msg, msgdata, recipients) refused.update(chunk_refused) return refused - diff --git a/src/mailman/mta/connection.py b/src/mailman/mta/connection.py index 8cf419545..9c49e5fb0 100644 --- a/src/mailman/mta/connection.py +++ b/src/mailman/mta/connection.py @@ -17,9 +17,6 @@ """MTA connections.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Connection', ] diff --git a/src/mailman/mta/decorating.py b/src/mailman/mta/decorating.py index ac99b3624..b4944d960 100644 --- a/src/mailman/mta/decorating.py +++ b/src/mailman/mta/decorating.py @@ -17,9 +17,6 @@ """Individualized delivery with header/footer decorations.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'DecoratingDelivery', 'DecoratingMixin', diff --git a/src/mailman/mta/deliver.py b/src/mailman/mta/deliver.py index be04a48bd..f01390397 100644 --- a/src/mailman/mta/deliver.py +++ b/src/mailman/mta/deliver.py @@ -17,9 +17,6 @@ """Generic delivery.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'deliver', ] diff --git a/src/mailman/mta/exim4.py b/src/mailman/mta/exim4.py index 1180b59eb..f25b12233 100644 --- a/src/mailman/mta/exim4.py +++ b/src/mailman/mta/exim4.py @@ -17,9 +17,6 @@ """Creation/deletion hooks for the Exim4 MTA.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'LMTP', ] diff --git a/src/mailman/mta/null.py b/src/mailman/mta/null.py index 7a3624b31..3b9f6322e 100644 --- a/src/mailman/mta/null.py +++ b/src/mailman/mta/null.py @@ -20,17 +20,13 @@ Exim one example of an MTA that Just Works. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'NullMTA', ] -from zope.interface import implementer - from mailman.interfaces.mta import IMailTransportAgentLifecycle +from zope.interface import implementer diff --git a/src/mailman/mta/personalized.py b/src/mailman/mta/personalized.py index 967bca68a..4ea9075a3 100644 --- a/src/mailman/mta/personalized.py +++ b/src/mailman/mta/personalized.py @@ -17,9 +17,6 @@ """Personalized delivery.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'PersonalizedDelivery', 'PersonalizedMixin', @@ -28,11 +25,10 @@ __all__ = [ from email.header import Header from email.utils import formataddr -from zope.component import getUtility - from mailman.interfaces.mailinglist import Personalization from mailman.interfaces.usermanager import IUserManager from mailman.mta.verp import VERPDelivery +from zope.component import getUtility diff --git a/src/mailman/mta/postfix.py b/src/mailman/mta/postfix.py index bb709c6b4..f76a401fa 100644 --- a/src/mailman/mta/postfix.py +++ b/src/mailman/mta/postfix.py @@ -17,9 +17,6 @@ """Creation/deletion hooks for the Postfix MTA.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'LMTP', ] @@ -29,16 +26,15 @@ import os import logging from flufl.lock import Lock -from operator import attrgetter -from zope.component import getUtility -from zope.interface import implementer - from mailman.config import config from mailman.config.config import external_configuration from mailman.interfaces.listmanager import IListManager from mailman.interfaces.mta import ( IMailTransportAgentAliases, IMailTransportAgentLifecycle) from mailman.utilities.datetime import now +from operator import attrgetter +from zope.component import getUtility +from zope.interface import implementer log = logging.getLogger('mailman.error') diff --git a/src/mailman/mta/tests/test_aliases.py b/src/mailman/mta/tests/test_aliases.py index 30c57e292..8eeeef2c8 100644 --- a/src/mailman/mta/tests/test_aliases.py +++ b/src/mailman/mta/tests/test_aliases.py @@ -17,9 +17,6 @@ """Test the MTA file generating utility.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestAliases', 'TestPostfix', @@ -31,13 +28,12 @@ import shutil import tempfile import unittest -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.interfaces.domain import IDomainManager from mailman.interfaces.mta import IMailTransportAgentAliases from mailman.mta.postfix import LMTP from mailman.testing.layers import ConfigLayer +from zope.component import getUtility NL = '\n' diff --git a/src/mailman/mta/tests/test_connection.py b/src/mailman/mta/tests/test_connection.py index 94b5904b5..74d0e537c 100644 --- a/src/mailman/mta/tests/test_connection.py +++ b/src/mailman/mta/tests/test_connection.py @@ -17,9 +17,6 @@ """Test MTA connections.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestConnection', ] diff --git a/src/mailman/mta/tests/test_delivery.py b/src/mailman/mta/tests/test_delivery.py index 0a910c13d..a2960f7cc 100644 --- a/src/mailman/mta/tests/test_delivery.py +++ b/src/mailman/mta/tests/test_delivery.py @@ -17,9 +17,6 @@ """Test various aspects of email delivery.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestIndividualDelivery', ] diff --git a/src/mailman/mta/verp.py b/src/mailman/mta/verp.py index c3d1d0999..2d436b8cb 100644 --- a/src/mailman/mta/verp.py +++ b/src/mailman/mta/verp.py @@ -17,9 +17,6 @@ """VERP delivery.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'VERPDelivery', 'VERPMixin', diff --git a/src/mailman/options.py b/src/mailman/options.py index 07565f611..93ada95ab 100644 --- a/src/mailman/options.py +++ b/src/mailman/options.py @@ -17,9 +17,6 @@ """Common argument parsing.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Options', 'SingleMailingListOptions', @@ -31,12 +28,11 @@ import os import sys from copy import copy -from optparse import Option, OptionParser, OptionValueError - from mailman.config import config from mailman.core.i18n import _ from mailman.core.initialize import initialize from mailman.version import MAILMAN_VERSION +from optparse import Option, OptionParser, OptionValueError diff --git a/src/mailman/rest/addresses.py b/src/mailman/rest/addresses.py index ce2aa4288..6cca24393 100644 --- a/src/mailman/rest/addresses.py +++ b/src/mailman/rest/addresses.py @@ -17,9 +17,6 @@ """REST for addresses.""" -from __future__ import absolute_import, print_function,unicode_literals - -__metaclass__ = type __all__ = [ 'AllAddresses', 'AnAddress', @@ -29,9 +26,6 @@ __all__ = [ import six -from operator import attrgetter -from zope.component import getUtility - from mailman.interfaces.address import ( ExistingAddressError, InvalidEmailAddressError) from mailman.interfaces.usermanager import IUserManager @@ -42,6 +36,8 @@ from mailman.rest.members import MemberCollection from mailman.rest.preferences import Preferences from mailman.rest.validator import Validator from mailman.utilities.datetime import now +from operator import attrgetter +from zope.component import getUtility diff --git a/src/mailman/rest/configuration.py b/src/mailman/rest/configuration.py index 6d3c85fd8..6cf54a00e 100644 --- a/src/mailman/rest/configuration.py +++ b/src/mailman/rest/configuration.py @@ -17,9 +17,6 @@ """Mailing list configuration via REST API.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ListConfiguration', ] diff --git a/src/mailman/rest/docs/__init__.py b/src/mailman/rest/docs/__init__.py index 2daf8a681..fcd8b41bb 100644 --- a/src/mailman/rest/docs/__init__.py +++ b/src/mailman/rest/docs/__init__.py @@ -17,9 +17,6 @@ """Doctest layer setup.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'layer', ] diff --git a/src/mailman/rest/domains.py b/src/mailman/rest/domains.py index bd221abeb..9bc0edf6a 100644 --- a/src/mailman/rest/domains.py +++ b/src/mailman/rest/domains.py @@ -17,9 +17,6 @@ """REST for domains.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ADomain', 'AllDomains', diff --git a/src/mailman/rest/helpers.py b/src/mailman/rest/helpers.py index 2b79a0e8a..a39d6ceb3 100644 --- a/src/mailman/rest/helpers.py +++ b/src/mailman/rest/helpers.py @@ -17,9 +17,6 @@ """Web service helpers.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'BadRequest', 'ChildError', diff --git a/src/mailman/rest/lists.py b/src/mailman/rest/lists.py index 87aa9f4b5..866c6211f 100644 --- a/src/mailman/rest/lists.py +++ b/src/mailman/rest/lists.py @@ -17,9 +17,6 @@ """REST for mailing lists.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AList', 'AllLists', @@ -33,9 +30,6 @@ __all__ = [ import six from lazr.config import as_boolean -from operator import attrgetter -from zope.component import getUtility - from mailman.app.lifecycle import create_list, remove_list from mailman.config import config from mailman.interfaces.domain import BadDomainSpecificationError @@ -52,6 +46,8 @@ from mailman.rest.helpers import ( from mailman.rest.members import AMember, MemberCollection from mailman.rest.moderation import HeldMessages, SubscriptionRequests from mailman.rest.validator import Validator +from operator import attrgetter +from zope.component import getUtility diff --git a/src/mailman/rest/members.py b/src/mailman/rest/members.py index b63f65658..ceaf54fc2 100644 --- a/src/mailman/rest/members.py +++ b/src/mailman/rest/members.py @@ -17,9 +17,6 @@ """REST for members.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AMember', 'AllMembers', @@ -30,10 +27,6 @@ __all__ = [ import six -from uuid import UUID -from operator import attrgetter -from zope.component import getUtility - from mailman.app.membership import delete_member from mailman.interfaces.address import InvalidEmailAddressError from mailman.interfaces.listmanager import IListManager, NoSuchListError @@ -49,6 +42,9 @@ from mailman.rest.helpers import ( from mailman.rest.preferences import Preferences, ReadOnlyPreferences from mailman.rest.validator import ( Validator, enum_validator, subscriber_validator) +from operator import attrgetter +from uuid import UUID +from zope.component import getUtility diff --git a/src/mailman/rest/moderation.py b/src/mailman/rest/moderation.py index 4373067ec..da182acb7 100644 --- a/src/mailman/rest/moderation.py +++ b/src/mailman/rest/moderation.py @@ -17,9 +17,6 @@ """REST API for Message moderation.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'HeldMessage', 'HeldMessages', diff --git a/src/mailman/rest/preferences.py b/src/mailman/rest/preferences.py index b85388ec9..9eafa8d77 100644 --- a/src/mailman/rest/preferences.py +++ b/src/mailman/rest/preferences.py @@ -17,9 +17,6 @@ """Preferences.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ReadOnlyPreferences', 'Preferences', diff --git a/src/mailman/rest/root.py b/src/mailman/rest/root.py index a82f7cdef..654b230a3 100644 --- a/src/mailman/rest/root.py +++ b/src/mailman/rest/root.py @@ -17,9 +17,6 @@ """The root of the REST API.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Root', ] @@ -28,8 +25,6 @@ __all__ = [ import falcon from base64 import b64decode -from zope.component import getUtility - from mailman.config import config from mailman.core.constants import system_preferences from mailman.core.system import system @@ -43,6 +38,7 @@ from mailman.rest.members import AMember, AllMembers, FindMembers from mailman.rest.preferences import ReadOnlyPreferences from mailman.rest.templates import TemplateFinder from mailman.rest.users import AUser, AllUsers +from zope.component import getUtility diff --git a/src/mailman/rest/templates.py b/src/mailman/rest/templates.py index 44dcdefc5..8d448a704 100644 --- a/src/mailman/rest/templates.py +++ b/src/mailman/rest/templates.py @@ -17,9 +17,6 @@ """Template finder.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TemplateFinder', ] diff --git a/src/mailman/rest/tests/test_addresses.py b/src/mailman/rest/tests/test_addresses.py index 5c70fad97..65c0c1e5a 100644 --- a/src/mailman/rest/tests/test_addresses.py +++ b/src/mailman/rest/tests/test_addresses.py @@ -17,9 +17,6 @@ """REST address tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestAddresses', ] diff --git a/src/mailman/rest/tests/test_configuration.py b/src/mailman/rest/tests/test_configuration.py index 93171ec4b..d013cdce9 100644 --- a/src/mailman/rest/tests/test_configuration.py +++ b/src/mailman/rest/tests/test_configuration.py @@ -17,9 +17,6 @@ """Test list configuration via the REST API.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestConfiguration', ] diff --git a/src/mailman/rest/tests/test_domains.py b/src/mailman/rest/tests/test_domains.py index cda9a9b89..72ba4c003 100644 --- a/src/mailman/rest/tests/test_domains.py +++ b/src/mailman/rest/tests/test_domains.py @@ -17,9 +17,6 @@ """REST domain tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestDomains', ] diff --git a/src/mailman/rest/tests/test_lists.py b/src/mailman/rest/tests/test_lists.py index 23d082fb8..839fd0f58 100644 --- a/src/mailman/rest/tests/test_lists.py +++ b/src/mailman/rest/tests/test_lists.py @@ -17,9 +17,6 @@ """REST list tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestListArchivers', 'TestListPagination', diff --git a/src/mailman/rest/tests/test_membership.py b/src/mailman/rest/tests/test_membership.py index 4beea9090..4ca28626f 100644 --- a/src/mailman/rest/tests/test_membership.py +++ b/src/mailman/rest/tests/test_membership.py @@ -17,9 +17,6 @@ """REST membership tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestMembership', 'TestNonmembership', diff --git a/src/mailman/rest/tests/test_moderation.py b/src/mailman/rest/tests/test_moderation.py index 207123168..2b72b91eb 100644 --- a/src/mailman/rest/tests/test_moderation.py +++ b/src/mailman/rest/tests/test_moderation.py @@ -17,10 +17,8 @@ """REST moderation tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestModeration', ] diff --git a/src/mailman/rest/tests/test_paginate.py b/src/mailman/rest/tests/test_paginate.py index e267100c7..a482c7007 100644 --- a/src/mailman/rest/tests/test_paginate.py +++ b/src/mailman/rest/tests/test_paginate.py @@ -17,9 +17,6 @@ """paginate helper tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestPaginateHelper', ] diff --git a/src/mailman/rest/tests/test_preferences.py b/src/mailman/rest/tests/test_preferences.py index 06e0b035b..6d34d7763 100644 --- a/src/mailman/rest/tests/test_preferences.py +++ b/src/mailman/rest/tests/test_preferences.py @@ -17,9 +17,6 @@ """Test various preference functionality.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestPreferences', ] @@ -36,6 +33,7 @@ from six.moves.urllib_error import HTTPError from zope.component import getUtility + class TestPreferences(unittest.TestCase): """Test various preference functionality.""" diff --git a/src/mailman/rest/tests/test_root.py b/src/mailman/rest/tests/test_root.py index 49877c3ae..5c134159d 100644 --- a/src/mailman/rest/tests/test_root.py +++ b/src/mailman/rest/tests/test_root.py @@ -17,9 +17,6 @@ """REST root object tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestRoot', ] diff --git a/src/mailman/rest/tests/test_users.py b/src/mailman/rest/tests/test_users.py index d4d49889d..b4bd50330 100644 --- a/src/mailman/rest/tests/test_users.py +++ b/src/mailman/rest/tests/test_users.py @@ -17,9 +17,6 @@ """REST user tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestLP1074374', 'TestLogin', diff --git a/src/mailman/rest/users.py b/src/mailman/rest/users.py index a1c46bc52..175c1f76c 100644 --- a/src/mailman/rest/users.py +++ b/src/mailman/rest/users.py @@ -17,21 +17,15 @@ """REST for users.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'AUser', + 'AddressUser', 'AllUsers', 'Login', ] from lazr.config import as_boolean -from passlib.utils import generate_password as generate -from uuid import UUID -from zope.component import getUtility - from mailman.config import config from mailman.core.errors import ( ReadOnlyPATCHRequestError, UnknownPATCHRequestError) @@ -44,8 +38,12 @@ from mailman.rest.helpers import ( path_to) from mailman.rest.preferences import Preferences from mailman.rest.validator import PatchValidator, Validator +from passlib.utils import generate_password as generate +from uuid import UUID +from zope.component import getUtility + # Attributes of a user which can be changed via the REST API. class PasswordEncrypterGetterSetter(GetterSetter): def __init__(self): @@ -73,6 +71,7 @@ CREATION_FIELDS = dict( ) + def create_user(arguments, response): """Create a new user.""" # We can't pass the 'password' argument to the user creation method, so diff --git a/src/mailman/rest/validator.py b/src/mailman/rest/validator.py index c185c6694..017e31847 100644 --- a/src/mailman/rest/validator.py +++ b/src/mailman/rest/validator.py @@ -17,9 +17,6 @@ """REST web form validation.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'PatchValidator', 'Validator', @@ -29,12 +26,11 @@ __all__ = [ ] -from uuid import UUID -from zope.component import getUtility - from mailman.core.errors import ( ReadOnlyPATCHRequestError, UnknownPATCHRequestError) from mailman.interfaces.languages import ILanguageManager +from uuid import UUID +from zope.component import getUtility COMMASPACE = ', ' diff --git a/src/mailman/rest/wsgiapp.py b/src/mailman/rest/wsgiapp.py index 445adf278..ad62244c8 100644 --- a/src/mailman/rest/wsgiapp.py +++ b/src/mailman/rest/wsgiapp.py @@ -17,9 +17,6 @@ """Basic WSGI Application object for REST server.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'make_application', 'make_server', diff --git a/src/mailman/rules/administrivia.py b/src/mailman/rules/administrivia.py index be63b93c8..866463d6c 100644 --- a/src/mailman/rules/administrivia.py +++ b/src/mailman/rules/administrivia.py @@ -17,20 +17,16 @@ """The administrivia rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Administrivia', ] from email.iterators import typed_subpart_iterator -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer # The list of email commands we search for in the Subject header and payload. diff --git a/src/mailman/rules/any.py b/src/mailman/rules/any.py index e5f80fbc4..72f6da873 100644 --- a/src/mailman/rules/any.py +++ b/src/mailman/rules/any.py @@ -17,18 +17,14 @@ """Check if any previous rules have matched.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Any', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/approved.py b/src/mailman/rules/approved.py index 054bb1e3d..5aa66c7df 100644 --- a/src/mailman/rules/approved.py +++ b/src/mailman/rules/approved.py @@ -17,9 +17,6 @@ """Look for moderator pre-approval.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Approved', ] @@ -28,11 +25,10 @@ __all__ = [ import re from email.iterators import typed_subpart_iterator -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer EMPTYSTRING = '' diff --git a/src/mailman/rules/emergency.py b/src/mailman/rules/emergency.py index ba7abe562..a1addcdb7 100644 --- a/src/mailman/rules/emergency.py +++ b/src/mailman/rules/emergency.py @@ -17,18 +17,14 @@ """The emergency hold rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Emergency', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/implicit_dest.py b/src/mailman/rules/implicit_dest.py index 0bc229b15..9d3e6d079 100644 --- a/src/mailman/rules/implicit_dest.py +++ b/src/mailman/rules/implicit_dest.py @@ -17,21 +17,18 @@ """The implicit destination rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ImplicitDestination', ] import re -from email.utils import getaddresses -from zope.interface import implementer +from email.utils import getaddresses from mailman.core.i18n import _ from mailman.interfaces.mailinglist import IAcceptableAliasSet from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/loop.py b/src/mailman/rules/loop.py index 145af8b34..30d7dde59 100644 --- a/src/mailman/rules/loop.py +++ b/src/mailman/rules/loop.py @@ -17,18 +17,14 @@ """Look for a posting loop.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Loop', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/max_recipients.py b/src/mailman/rules/max_recipients.py index 3b1d4f0c5..485368c0b 100644 --- a/src/mailman/rules/max_recipients.py +++ b/src/mailman/rules/max_recipients.py @@ -17,19 +17,15 @@ """The maximum number of recipients rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MaximumRecipients', ] from email.utils import getaddresses -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/max_size.py b/src/mailman/rules/max_size.py index 1e2b46184..4c8b58451 100644 --- a/src/mailman/rules/max_size.py +++ b/src/mailman/rules/max_size.py @@ -17,18 +17,14 @@ """The maximum message size rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MaximumSize', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/moderation.py b/src/mailman/rules/moderation.py index 46ed242fa..5b79677ed 100644 --- a/src/mailman/rules/moderation.py +++ b/src/mailman/rules/moderation.py @@ -17,23 +17,19 @@ """Membership related rules.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'MemberModeration', 'NonmemberModeration', ] -from zope.component import getUtility -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.action import Action from mailman.interfaces.member import MemberRole from mailman.interfaces.rules import IRule from mailman.interfaces.usermanager import IUserManager +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/rules/news_moderation.py b/src/mailman/rules/news_moderation.py index c4372eb80..358368624 100644 --- a/src/mailman/rules/news_moderation.py +++ b/src/mailman/rules/news_moderation.py @@ -17,19 +17,15 @@ """The news moderation rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ModeratedNewsgroup', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.nntp import NewsgroupModeration from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/no_subject.py b/src/mailman/rules/no_subject.py index 8f01f0c15..e66046832 100644 --- a/src/mailman/rules/no_subject.py +++ b/src/mailman/rules/no_subject.py @@ -17,18 +17,14 @@ """The no-Subject header rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'NoSubject', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/rules/suspicious.py b/src/mailman/rules/suspicious.py index 1841ed69e..fbd76b794 100644 --- a/src/mailman/rules/suspicious.py +++ b/src/mailman/rules/suspicious.py @@ -17,9 +17,6 @@ """The historical 'suspicious header' rule.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'SuspiciousHeader', ] @@ -28,10 +25,10 @@ __all__ = [ import re import logging -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer + log = logging.getLogger('mailman.error') diff --git a/src/mailman/rules/tests/test_approved.py b/src/mailman/rules/tests/test_approved.py index 00c556069..83088da55 100644 --- a/src/mailman/rules/tests/test_approved.py +++ b/src/mailman/rules/tests/test_approved.py @@ -17,9 +17,6 @@ """Test the `approved` handler.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestApproved', 'TestApprovedNonASCII', @@ -36,8 +33,7 @@ from mailman.app.lifecycle import create_list from mailman.config import config from mailman.rules import approved from mailman.testing.helpers import ( - configuration, - specialized_message_from_string as mfs) + configuration, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer diff --git a/src/mailman/rules/tests/test_moderation.py b/src/mailman/rules/tests/test_moderation.py index c0c3cf417..2db4e53cc 100644 --- a/src/mailman/rules/tests/test_moderation.py +++ b/src/mailman/rules/tests/test_moderation.py @@ -17,9 +17,6 @@ """Test the `member-moderation` and `nonmember-moderation` rules.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestModeration', ] diff --git a/src/mailman/rules/truth.py b/src/mailman/rules/truth.py index d50b5eae4..0bf3345b7 100644 --- a/src/mailman/rules/truth.py +++ b/src/mailman/rules/truth.py @@ -17,18 +17,14 @@ """A rule which always matches.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Truth', ] -from zope.interface import implementer - from mailman.core.i18n import _ from mailman.interfaces.rules import IRule +from zope.interface import implementer diff --git a/src/mailman/runners/archive.py b/src/mailman/runners/archive.py index b49f5c265..f81f9ee3e 100644 --- a/src/mailman/runners/archive.py +++ b/src/mailman/runners/archive.py @@ -17,9 +17,6 @@ """Archive runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ArchiveRunner', ] @@ -31,7 +28,6 @@ import logging from email.utils import parsedate_tz, mktime_tz from datetime import datetime from lazr.config import as_timedelta - from mailman.config import config from mailman.core.runner import Runner from mailman.interfaces.archiver import ClobberDate diff --git a/src/mailman/runners/bounce.py b/src/mailman/runners/bounce.py index 9312a9158..3a85006fe 100644 --- a/src/mailman/runners/bounce.py +++ b/src/mailman/runners/bounce.py @@ -20,11 +20,10 @@ import logging from flufl.bounce import all_failures, scan_message -from zope.component import getUtility - from mailman.app.bounces import ProbeVERP, StandardVERP, maybe_forward from mailman.core.runner import Runner from mailman.interfaces.bounce import BounceContext, IBounceProcessor +from zope.component import getUtility COMMASPACE = ', ' @@ -33,7 +32,7 @@ log = logging.getLogger('mailman.bounce') elog = logging.getLogger('mailman.error') - + class BounceRunner(Runner): """The bounce runner.""" diff --git a/src/mailman/runners/command.py b/src/mailman/runners/command.py index 7f8c7f470..b0775c4f4 100644 --- a/src/mailman/runners/command.py +++ b/src/mailman/runners/command.py @@ -17,9 +17,6 @@ """-request robot command runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'CommandRunner', 'Results', @@ -37,15 +34,14 @@ import logging from email.errors import HeaderParseError from email.header import decode_header, make_header from email.iterators import typed_subpart_iterator -from zope.component import getUtility -from zope.interface import implementer - from mailman.config import config from mailman.core.i18n import _ from mailman.core.runner import Runner from mailman.email.message import UserNotification from mailman.interfaces.command import ContinueProcessing, IEmailResults from mailman.interfaces.languages import ILanguageManager +from zope.component import getUtility +from zope.interface import implementer NL = '\n' diff --git a/src/mailman/runners/digest.py b/src/mailman/runners/digest.py index 0a13a3c49..52bfb8859 100644 --- a/src/mailman/runners/digest.py +++ b/src/mailman/runners/digest.py @@ -17,9 +17,6 @@ """Digest runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'DigestRunner', ] diff --git a/src/mailman/runners/incoming.py b/src/mailman/runners/incoming.py index d75469a5e..a5d8fbea3 100644 --- a/src/mailman/runners/incoming.py +++ b/src/mailman/runners/incoming.py @@ -26,21 +26,17 @@ prepared for delivery. Rejections, discards, and holds are processed immediately. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'IncomingRunner', ] -from zope.component import getUtility - from mailman.core.chains import process from mailman.core.runner import Runner from mailman.database.transaction import transaction from mailman.interfaces.address import ExistingAddressError from mailman.interfaces.usermanager import IUserManager +from zope.component import getUtility diff --git a/src/mailman/runners/lmtp.py b/src/mailman/runners/lmtp.py index 2a685f18b..85730bb7d 100644 --- a/src/mailman/runners/lmtp.py +++ b/src/mailman/runners/lmtp.py @@ -34,9 +34,6 @@ so that the peer mail server can provide better diagnostics. http://www.faqs.org/rfcs/rfc2033.html """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'LMTPRunner', ] @@ -48,8 +45,6 @@ import logging import asyncore from email.utils import parseaddr -from zope.component import getUtility - from mailman.config import config from mailman.core.runner import Runner from mailman.database.transaction import transactional @@ -57,6 +52,7 @@ from mailman.email.message import Message from mailman.interfaces.listmanager import IListManager from mailman.utilities.datetime import now from mailman.utilities.email import add_message_hash +from zope.component import getUtility elog = logging.getLogger('mailman.error') diff --git a/src/mailman/runners/nntp.py b/src/mailman/runners/nntp.py index d26001a57..7fb16f1b2 100644 --- a/src/mailman/runners/nntp.py +++ b/src/mailman/runners/nntp.py @@ -17,9 +17,6 @@ """NNTP runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'NNTPRunner', ] diff --git a/src/mailman/runners/outgoing.py b/src/mailman/runners/outgoing.py index db0d847c4..9af4e7c11 100644 --- a/src/mailman/runners/outgoing.py +++ b/src/mailman/runners/outgoing.py @@ -17,14 +17,16 @@ """Outgoing runner.""" +__all__ = [ + 'OutgoingRunner', + ] + + import socket import logging from datetime import datetime from lazr.config import as_boolean, as_timedelta -from uuid import UUID -from zope.component import getUtility - from mailman.config import config from mailman.core.runner import Runner from mailman.interfaces.bounce import BounceContext, IBounceProcessor @@ -34,6 +36,8 @@ from mailman.interfaces.pending import IPendings from mailman.interfaces.subscriptions import ISubscriptionService from mailman.utilities.datetime import now from mailman.utilities.modules import find_name +from uuid import UUID +from zope.component import getUtility # This controls how often _do_periodic() will try to deal with deferred diff --git a/src/mailman/runners/pipeline.py b/src/mailman/runners/pipeline.py index 13226c6fc..357863d2e 100644 --- a/src/mailman/runners/pipeline.py +++ b/src/mailman/runners/pipeline.py @@ -22,6 +22,11 @@ through the 'preparation pipeline'. This pipeline adds, deletes and modifies headers, calculates message recipients, and more. """ +__all__ = [ + 'PipelineRunner', + ] + + from mailman.core.pipelines import process from mailman.core.runner import Runner diff --git a/src/mailman/runners/rest.py b/src/mailman/runners/rest.py index 5980e6263..d39a8a6ff 100644 --- a/src/mailman/runners/rest.py +++ b/src/mailman/runners/rest.py @@ -17,9 +17,6 @@ """Start the administrative HTTP server.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'RESTRunner', ] diff --git a/src/mailman/runners/retry.py b/src/mailman/runners/retry.py index b4148ee3a..f4705ba75 100644 --- a/src/mailman/runners/retry.py +++ b/src/mailman/runners/retry.py @@ -17,9 +17,6 @@ """Retry delivery.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'RetryRunner', ] diff --git a/src/mailman/runners/tests/test_archiver.py b/src/mailman/runners/tests/test_archiver.py index 12bdb0edd..9e3d9626c 100644 --- a/src/mailman/runners/tests/test_archiver.py +++ b/src/mailman/runners/tests/test_archiver.py @@ -17,9 +17,6 @@ """Test the archive runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestArchiveRunner', ] @@ -29,19 +26,17 @@ import os import unittest from email import message_from_file -from zope.interface import implementer - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.archiver import IArchiver from mailman.interfaces.mailinglist import IListArchiverSet from mailman.runners.archive import ArchiveRunner from mailman.testing.helpers import ( - configuration, - make_testable_runner, + configuration, make_testable_runner, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer from mailman.utilities.datetime import RFC822_DATE_FMT, factory, now +from zope.interface import implementer diff --git a/src/mailman/runners/tests/test_bounce.py b/src/mailman/runners/tests/test_bounce.py index b296f4476..875437dc2 100644 --- a/src/mailman/runners/tests/test_bounce.py +++ b/src/mailman/runners/tests/test_bounce.py @@ -17,9 +17,6 @@ """Test the bounce runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestBounceRunner', 'TestBounceRunnerBug876774', @@ -29,9 +26,6 @@ __all__ = [ import unittest -from zope.component import getUtility -from zope.interface import implementer - from mailman.app.bounces import send_probe from mailman.app.lifecycle import create_list from mailman.config import config @@ -42,11 +36,11 @@ from mailman.interfaces.styles import IStyle, IStyleManager from mailman.interfaces.usermanager import IUserManager from mailman.runners.bounce import BounceRunner from mailman.testing.helpers import ( - LogFileMark, - get_queue_messages, - make_testable_runner, + LogFileMark, get_queue_messages, make_testable_runner, specialized_message_from_string as message_from_string) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility +from zope.interface import implementer diff --git a/src/mailman/runners/tests/test_confirm.py b/src/mailman/runners/tests/test_confirm.py index d387fcfe6..11514044a 100644 --- a/src/mailman/runners/tests/test_confirm.py +++ b/src/mailman/runners/tests/test_confirm.py @@ -17,9 +17,6 @@ """Test the `confirm` command.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestConfirm', ] @@ -29,8 +26,6 @@ import unittest from datetime import datetime from email.iterators import body_line_iterator -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.database.transaction import transaction @@ -38,10 +33,10 @@ from mailman.interfaces.registrar import IRegistrar from mailman.interfaces.usermanager import IUserManager from mailman.runners.command import CommandRunner from mailman.testing.helpers import ( - get_queue_messages, - make_testable_runner, + get_queue_messages, make_testable_runner, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/runners/tests/test_digest.py b/src/mailman/runners/tests/test_digest.py index 8b19188df..83156f04e 100644 --- a/src/mailman/runners/tests/test_digest.py +++ b/src/mailman/runners/tests/test_digest.py @@ -17,9 +17,6 @@ """Test the digest runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestDigest', 'TestI18nDigest', diff --git a/src/mailman/runners/tests/test_incoming.py b/src/mailman/runners/tests/test_incoming.py index 2d49ae550..77fe2da02 100644 --- a/src/mailman/runners/tests/test_incoming.py +++ b/src/mailman/runners/tests/test_incoming.py @@ -17,9 +17,6 @@ """Test the incoming queue runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestIncoming', ] @@ -32,8 +29,7 @@ from mailman.chains.base import TerminalChainBase from mailman.config import config from mailman.runners.incoming import IncomingRunner from mailman.testing.helpers import ( - get_queue_messages, - make_testable_runner, + get_queue_messages, make_testable_runner, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer diff --git a/src/mailman/runners/tests/test_join.py b/src/mailman/runners/tests/test_join.py index 2aa361254..df24bc06b 100644 --- a/src/mailman/runners/tests/test_join.py +++ b/src/mailman/runners/tests/test_join.py @@ -17,9 +17,6 @@ """Test mailing list joins.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestJoin', 'TestJoinWithDigests', @@ -29,8 +26,6 @@ __all__ = [ import unittest from email.iterators import body_line_iterator -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.member import DeliveryMode @@ -42,6 +37,7 @@ from mailman.testing.helpers import ( get_queue_messages, make_testable_runner, reset_the_world, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility diff --git a/src/mailman/runners/tests/test_lmtp.py b/src/mailman/runners/tests/test_lmtp.py index 41a4f93e0..44b6a0889 100644 --- a/src/mailman/runners/tests/test_lmtp.py +++ b/src/mailman/runners/tests/test_lmtp.py @@ -17,9 +17,6 @@ """Tests for the LMTP server.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestLMTP', ] diff --git a/src/mailman/runners/tests/test_nntp.py b/src/mailman/runners/tests/test_nntp.py index df3ea8c4b..e3218af33 100644 --- a/src/mailman/runners/tests/test_nntp.py +++ b/src/mailman/runners/tests/test_nntp.py @@ -17,9 +17,6 @@ """Test the NNTP runner and related utilities.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestPrepareMessage', 'TestNNTPRunner', @@ -36,10 +33,7 @@ from mailman.config import config from mailman.interfaces.nntp import NewsgroupModeration from mailman.runners import nntp from mailman.testing.helpers import ( - LogFileMark, - configuration, - get_queue_messages, - make_testable_runner, + LogFileMark, configuration, get_queue_messages, make_testable_runner, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer diff --git a/src/mailman/runners/tests/test_outgoing.py b/src/mailman/runners/tests/test_outgoing.py index 68fb75fc3..8f51c4ce2 100644 --- a/src/mailman/runners/tests/test_outgoing.py +++ b/src/mailman/runners/tests/test_outgoing.py @@ -17,10 +17,11 @@ """Test the outgoing runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestOnce', + 'TestSocketError', + 'TestSomeRecipientsFailed', + 'TestVERPSettings', ] @@ -32,8 +33,6 @@ import unittest from contextlib import contextmanager from datetime import datetime, timedelta from lazr.config import as_timedelta -from zope.component import getUtility - from mailman.app.bounces import send_probe from mailman.app.lifecycle import create_list from mailman.config import config @@ -45,12 +44,11 @@ from mailman.interfaces.pending import IPendings from mailman.interfaces.usermanager import IUserManager from mailman.runners.outgoing import OutgoingRunner from mailman.testing.helpers import ( - LogFileMark, - get_queue_messages, - make_testable_runner, + LogFileMark, get_queue_messages, make_testable_runner, specialized_message_from_string as message_from_string) from mailman.testing.layers import ConfigLayer, SMTPLayer from mailman.utilities.datetime import factory, now +from zope.component import getUtility diff --git a/src/mailman/runners/tests/test_owner.py b/src/mailman/runners/tests/test_owner.py index 503f1e18d..15ca07c2e 100644 --- a/src/mailman/runners/tests/test_owner.py +++ b/src/mailman/runners/tests/test_owner.py @@ -22,9 +22,6 @@ # tests. They're not exactly integration tests, but they do touch lots of # parts of the system. -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestEmailToOwner', ] @@ -32,22 +29,19 @@ __all__ = [ import unittest -from operator import itemgetter -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.database.transaction import transaction from mailman.interfaces.member import MemberRole from mailman.interfaces.usermanager import IUserManager from mailman.testing.helpers import ( - TestableMaster, - get_lmtp_client, - make_testable_runner) + TestableMaster, get_lmtp_client, make_testable_runner) from mailman.runners.incoming import IncomingRunner from mailman.runners.outgoing import OutgoingRunner from mailman.runners.pipeline import PipelineRunner from mailman.testing.layers import SMTPLayer +from operator import itemgetter +from zope.component import getUtility diff --git a/src/mailman/runners/tests/test_pipeline.py b/src/mailman/runners/tests/test_pipeline.py index 1eba5cfbf..347bde16b 100644 --- a/src/mailman/runners/tests/test_pipeline.py +++ b/src/mailman/runners/tests/test_pipeline.py @@ -17,9 +17,6 @@ """Test the pipeline runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestPipelineRunner', ] @@ -27,17 +24,15 @@ __all__ = [ import unittest -from zope.interface import implementer - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.handler import IHandler from mailman.interfaces.pipeline import IPipeline from mailman.runners.pipeline import PipelineRunner from mailman.testing.helpers import ( - make_testable_runner, - specialized_message_from_string as mfs) + make_testable_runner, specialized_message_from_string as mfs) from mailman.testing.layers import ConfigLayer +from zope.interface import implementer diff --git a/src/mailman/runners/tests/test_rest.py b/src/mailman/runners/tests/test_rest.py index bbe026ad6..96ca19089 100644 --- a/src/mailman/runners/tests/test_rest.py +++ b/src/mailman/runners/tests/test_rest.py @@ -17,9 +17,6 @@ """Test the REST runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestRESTRunner', ] diff --git a/src/mailman/runners/tests/test_retry.py b/src/mailman/runners/tests/test_retry.py index 15775e5d8..0a0929991 100644 --- a/src/mailman/runners/tests/test_retry.py +++ b/src/mailman/runners/tests/test_retry.py @@ -17,9 +17,6 @@ """Test the retry runner.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestRetryRunner', ] @@ -31,8 +28,7 @@ from mailman.app.lifecycle import create_list from mailman.config import config from mailman.runners.retry import RetryRunner from mailman.testing.helpers import ( - get_queue_messages, - make_testable_runner, + get_queue_messages, make_testable_runner, specialized_message_from_string as message_from_string) from mailman.testing.layers import ConfigLayer diff --git a/src/mailman/runners/virgin.py b/src/mailman/runners/virgin.py index 0f91d61af..8ff45e86e 100644 --- a/src/mailman/runners/virgin.py +++ b/src/mailman/runners/virgin.py @@ -23,6 +23,11 @@ to go through some minimal processing before they can be sent out to the recipient. """ +__all__ = [ + 'VirginRunner', + ] + + from mailman.core.pipelines import process from mailman.core.runner import Runner diff --git a/src/mailman/styles/base.py b/src/mailman/styles/base.py index 0d65bbebb..db4072b5c 100644 --- a/src/mailman/styles/base.py +++ b/src/mailman/styles/base.py @@ -23,9 +23,6 @@ methods in your compositional derived class. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Announcement', 'BasicOperation', @@ -38,7 +35,6 @@ __all__ = [ from datetime import timedelta - from mailman.core.i18n import _ from mailman.interfaces.action import Action, FilterAction from mailman.interfaces.archiver import ArchivePolicy diff --git a/src/mailman/styles/default.py b/src/mailman/styles/default.py index b12999f0e..f7ea3447f 100644 --- a/src/mailman/styles/default.py +++ b/src/mailman/styles/default.py @@ -17,21 +17,17 @@ """Application of list styles to new and existing lists.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'LegacyDefaultStyle', 'LegacyAnnounceOnly', ] -from zope.interface import implementer - from mailman.interfaces.styles import IStyle from mailman.styles.base import ( Announcement, BasicOperation, Bounces, Discussion, Identity, Moderation, Public) +from zope.interface import implementer diff --git a/src/mailman/styles/manager.py b/src/mailman/styles/manager.py index 397902c17..59cbb1471 100644 --- a/src/mailman/styles/manager.py +++ b/src/mailman/styles/manager.py @@ -17,23 +17,19 @@ """Style manager.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'StyleManager', 'handle_ConfigurationUpdatedEvent', ] -from zope.component import getUtility -from zope.interface import implementer -from zope.interface.verify import verifyObject - from mailman.interfaces.configuration import ConfigurationUpdatedEvent from mailman.interfaces.styles import ( DuplicateStyleError, IStyle, IStyleManager) from mailman.utilities.modules import find_components +from zope.component import getUtility +from zope.interface import implementer +from zope.interface.verify import verifyObject diff --git a/src/mailman/styles/tests/test_styles.py b/src/mailman/styles/tests/test_styles.py index 1fb7a8410..8e8d2eb19 100644 --- a/src/mailman/styles/tests/test_styles.py +++ b/src/mailman/styles/tests/test_styles.py @@ -17,9 +17,6 @@ """Test styles.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestStyle', ] @@ -27,13 +24,12 @@ __all__ = [ import unittest -from zope.component import getUtility -from zope.interface import implementer -from zope.interface.exceptions import DoesNotImplement - from mailman.interfaces.styles import ( DuplicateStyleError, IStyle, IStyleManager) from mailman.testing.layers import ConfigLayer +from zope.component import getUtility +from zope.interface import implementer +from zope.interface.exceptions import DoesNotImplement diff --git a/src/mailman/testing/documentation.py b/src/mailman/testing/documentation.py index b8d852fed..e7511fb9b 100644 --- a/src/mailman/testing/documentation.py +++ b/src/mailman/testing/documentation.py @@ -21,9 +21,6 @@ Note that doctest extraction does not currently work for zip file distributions. doctest discovery currently requires file system traversal. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'setup', 'teardown' @@ -31,7 +28,6 @@ __all__ = [ from inspect import isfunction, ismethod - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.testing.helpers import call_api, specialized_message_from_string @@ -145,11 +141,6 @@ def dump_json(url, data=None, method=None, username=None, password=None): def setup(testobj): """Test setup.""" - # Make sure future statements in our doctests are the same as everywhere - # else. - testobj.globs['absolute_import'] = absolute_import - testobj.globs['print_function'] = print_function - testobj.globs['unicode_literals'] = unicode_literals # In general, I don't like adding convenience functions, since I think # doctests should do the imports themselves. It makes for better # documentation that way. However, a few are really useful, or help to diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index 1b8f0d7af..b00534490 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -17,9 +17,6 @@ """Various test helpers.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'LogFileMark', 'TestableMaster', @@ -60,11 +57,6 @@ from contextlib import contextmanager from email import message_from_string from httplib2 import Http from lazr.config import as_timedelta -from six.moves.urllib_error import HTTPError -from six.moves.urllib_parse import urlencode -from zope import event -from zope.component import getUtility - from mailman.bin.master import Loop as Master from mailman.config import config from mailman.database.transaction import transaction @@ -75,6 +67,10 @@ from mailman.interfaces.styles import IStyleManager from mailman.interfaces.usermanager import IUserManager from mailman.runners.digest import DigestRunner from mailman.utilities.mailbox import Mailbox +from six.moves.urllib_error import HTTPError +from six.moves.urllib_parse import urlencode +from zope import event +from zope.component import getUtility NL = '\n' diff --git a/src/mailman/testing/i18n.py b/src/mailman/testing/i18n.py index 933a5ec0f..6718f5dda 100644 --- a/src/mailman/testing/i18n.py +++ b/src/mailman/testing/i18n.py @@ -17,9 +17,6 @@ """Internationalization for the tests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestingStrategy', 'initialize', @@ -29,9 +26,8 @@ __all__ = [ from contextlib import closing from flufl.i18n import registry from gettext import GNUTranslations, NullTranslations -from pkg_resources import resource_stream - from mailman.core.i18n import initialize as core_initialize +from pkg_resources import resource_stream diff --git a/src/mailman/testing/layers.py b/src/mailman/testing/layers.py index 8ec6c307f..d38878160 100644 --- a/src/mailman/testing/layers.py +++ b/src/mailman/testing/layers.py @@ -20,14 +20,10 @@ # XXX 2012-03-23 BAW: Layers really really suck. For example, the # test_owners_get_email() test requires that both the SMTPLayer and LMTPLayer # be set up, but there's apparently no way to do that and make zope.testing -# happy. This causes no tests failures, but it does cause errors at the end -# of the full test run. For now, I'll ignore that, but I do want to -# eventually get rid of the zope.test* dependencies and use something like -# testresources or some such. +# happy. This causes no test failures, but it does cause errors at the end of +# the full test run. For now, I'll ignore that, but I do want to eventually +# get rid of the layers and use something like testresources or some such. -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'ConfigLayer', 'LMTPLayer', @@ -46,10 +42,6 @@ import datetime import tempfile from lazr.config import as_boolean -from pkg_resources import resource_string as resource_bytes -from textwrap import dedent -from zope.component import getUtility - from mailman.config import config from mailman.core import initialize from mailman.core.initialize import INHIBIT_CONFIG_FILE @@ -60,6 +52,9 @@ from mailman.testing.helpers import ( TestableMaster, get_lmtp_client, reset_the_world, wait_for_webservice) from mailman.testing.mta import ConnectionCountingController from mailman.utilities.string import expand +from pkg_resources import resource_string as resource_bytes +from textwrap import dedent +from zope.component import getUtility TEST_TIMEOUT = datetime.timedelta(seconds=5) diff --git a/src/mailman/testing/mta.py b/src/mailman/testing/mta.py index 4dd5bc097..81a6bf1ac 100644 --- a/src/mailman/testing/mta.py +++ b/src/mailman/testing/mta.py @@ -17,9 +17,6 @@ """Fake MTA for testing purposes.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'FakeMTA', ] @@ -29,11 +26,10 @@ import logging from lazr.smtptest.controller import QueueController from lazr.smtptest.server import Channel, QueueServer +from mailman.interfaces.mta import IMailTransportAgentLifecycle from six.moves.queue import Empty, Queue from zope.interface import implementer -from mailman.interfaces.mta import IMailTransportAgentLifecycle - log = logging.getLogger('lazr.smtptest') diff --git a/src/mailman/testing/nose.py b/src/mailman/testing/nose.py index 8d175873c..181048b64 100644 --- a/src/mailman/testing/nose.py +++ b/src/mailman/testing/nose.py @@ -17,9 +17,6 @@ """nose2 test infrastructure.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'NosePlugin', ] @@ -35,6 +32,7 @@ from mailman.testing.documentation import setup, teardown from mailman.testing.layers import ConfigLayer, MockAndMonkeyLayer, SMTPLayer from nose2.events import Plugin + DOT = '.' FLAGS = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF TOPDIR = os.path.dirname(mailman.__file__) diff --git a/src/mailman/tests/test_configfile.py b/src/mailman/tests/test_configfile.py index 22442c767..0807c0648 100644 --- a/src/mailman/tests/test_configfile.py +++ b/src/mailman/tests/test_configfile.py @@ -17,10 +17,10 @@ """Test configuration file searching.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestConfigFileBase', + 'TestConfigFileSearch', + 'TestConfigFileSearchWithChroot', ] @@ -31,7 +31,6 @@ import tempfile import unittest from contextlib import contextmanager - from mailman.core.initialize import search_for_configuration_file @@ -107,6 +106,7 @@ class TestConfigFileBase(unittest.TestCase): return os.path.join(self._root, path) + class TestConfigFileSearch(TestConfigFileBase): """Test various aspects of searching for configuration files. @@ -128,6 +128,7 @@ class TestConfigFileSearch(TestConfigFileBase): self.assertEqual(found, config_file) + class TestConfigFileSearchWithChroot(TestConfigFileBase): """Like `TestConfigFileSearch` but with a special os.path.exists().""" diff --git a/src/mailman/utilities/datetime.py b/src/mailman/utilities/datetime.py index b494e2513..3cea0d0cd 100644 --- a/src/mailman/utilities/datetime.py +++ b/src/mailman/utilities/datetime.py @@ -22,10 +22,6 @@ datetime.datetime.now() and datetime.date.today(). These are better instrumented for testing purposes. """ - -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'DateFactory', 'RFC822_DATE_FMT', diff --git a/src/mailman/utilities/email.py b/src/mailman/utilities/email.py index 0237042c7..bedbd2ae9 100644 --- a/src/mailman/utilities/email.py +++ b/src/mailman/utilities/email.py @@ -17,9 +17,6 @@ """Email helpers.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'add_message_hash', 'split_email', diff --git a/src/mailman/utilities/filesystem.py b/src/mailman/utilities/filesystem.py index f2a5b705b..4ef52cbfa 100644 --- a/src/mailman/utilities/filesystem.py +++ b/src/mailman/utilities/filesystem.py @@ -17,9 +17,6 @@ """Filesystem utilities.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'makedirs', 'umask', diff --git a/src/mailman/utilities/i18n.py b/src/mailman/utilities/i18n.py index e9136837f..16f2fee6b 100644 --- a/src/mailman/utilities/i18n.py +++ b/src/mailman/utilities/i18n.py @@ -17,9 +17,6 @@ """i18n template search and interpolation.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TemplateNotFoundError', 'find', @@ -34,13 +31,12 @@ import sys import errno from itertools import product -from pkg_resources import resource_filename - from mailman.config import config from mailman.core.constants import system_preferences from mailman.core.errors import MailmanException from mailman.core.i18n import _ from mailman.utilities.string import expand, wrap as wrap_text +from pkg_resources import resource_filename diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py index c93080c91..2db5f3ace 100644 --- a/src/mailman/utilities/importer.py +++ b/src/mailman/utilities/importer.py @@ -17,9 +17,6 @@ """Importer routines.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Import21Error', 'import_config_pck', diff --git a/src/mailman/utilities/interact.py b/src/mailman/utilities/interact.py index 8bca9ee40..cdc2b3002 100644 --- a/src/mailman/utilities/interact.py +++ b/src/mailman/utilities/interact.py @@ -17,9 +17,6 @@ """Provide an interactive prompt, mimicking the Python interpreter.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'interact', ] diff --git a/src/mailman/utilities/mailbox.py b/src/mailman/utilities/mailbox.py index 4f085e127..71e083792 100644 --- a/src/mailman/utilities/mailbox.py +++ b/src/mailman/utilities/mailbox.py @@ -15,11 +15,8 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see . -"""Module stuff.""" +"""MMDF helper for digests.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Mailbox', ] diff --git a/src/mailman/utilities/modules.py b/src/mailman/utilities/modules.py index 9ff0e50cd..2a63ac501 100644 --- a/src/mailman/utilities/modules.py +++ b/src/mailman/utilities/modules.py @@ -17,9 +17,6 @@ """Package and module utilities.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'call_name', 'expand_path', diff --git a/src/mailman/utilities/passwords.py b/src/mailman/utilities/passwords.py index 6fb7f08c0..f29482572 100644 --- a/src/mailman/utilities/passwords.py +++ b/src/mailman/utilities/passwords.py @@ -17,19 +17,14 @@ """A wrapper around passlib.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'handle_ConfigurationUpdatedEvent', ] - -from passlib.context import CryptContext - from mailman.config.config import load_external from mailman.interfaces.configuration import ConfigurationUpdatedEvent +from passlib.context import CryptContext diff --git a/src/mailman/utilities/string.py b/src/mailman/utilities/string.py index 5f0ae03c9..6bbf3c6ea 100644 --- a/src/mailman/utilities/string.py +++ b/src/mailman/utilities/string.py @@ -17,9 +17,6 @@ """String utilities.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'expand', 'oneline', diff --git a/src/mailman/utilities/tests/test_email.py b/src/mailman/utilities/tests/test_email.py index 1448fb32b..838d50862 100644 --- a/src/mailman/utilities/tests/test_email.py +++ b/src/mailman/utilities/tests/test_email.py @@ -17,9 +17,6 @@ """Testing functions in the email utilities.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestEmail', ] diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py index 09d2f351c..192e08df5 100644 --- a/src/mailman/utilities/tests/test_import.py +++ b/src/mailman/utilities/tests/test_import.py @@ -17,12 +17,14 @@ """Tests for config.pck imports.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestArchiveImport', 'TestBasicImport', + 'TestConvertToURI', + 'TestFilterActionImport', + 'TestMemberActionImport', + 'TestPreferencesImport', + 'TestRosterImport', ] @@ -33,10 +35,6 @@ import unittest from datetime import timedelta, datetime from enum import Enum -from pkg_resources import resource_filename -from six.moves.cPickle import load -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.handlers.decorate import decorate @@ -55,6 +53,9 @@ from mailman.testing.layers import ConfigLayer from mailman.utilities.filesystem import makedirs from mailman.utilities.importer import import_config_pck, Import21Error from mailman.utilities.string import expand +from pkg_resources import resource_filename +from six.moves.cPickle import load +from zope.component import getUtility diff --git a/src/mailman/utilities/tests/test_passwords.py b/src/mailman/utilities/tests/test_passwords.py index 0dd49cb85..b11a7654b 100644 --- a/src/mailman/utilities/tests/test_passwords.py +++ b/src/mailman/utilities/tests/test_passwords.py @@ -17,9 +17,6 @@ """Testing the password utility.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'TestPasswords', ] diff --git a/src/mailman/utilities/tests/test_templates.py b/src/mailman/utilities/tests/test_templates.py index 6507bf8e5..b59d2aa1c 100644 --- a/src/mailman/utilities/tests/test_templates.py +++ b/src/mailman/utilities/tests/test_templates.py @@ -17,10 +17,10 @@ """Testing i18n template search and interpolation.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestFind', + 'TestMake', + 'TestSearchOrder', ] @@ -29,14 +29,13 @@ import shutil import tempfile import unittest -from pkg_resources import resource_filename -from zope.component import getUtility - from mailman.app.lifecycle import create_list from mailman.config import config from mailman.interfaces.languages import ILanguageManager from mailman.testing.layers import ConfigLayer from mailman.utilities.i18n import TemplateNotFoundError, find, make, search +from pkg_resources import resource_filename +from zope.component import getUtility @@ -191,14 +190,14 @@ class TestFind(unittest.TestCase): with open(path, 'w') as fp: fp.write(text) self.xxsite = os.path.join( - self.var_dir, 'templates', 'site', 'xx', 'site.txt') + self.var_dir, 'templates', 'site', 'xx', 'site.txt') write('Site template', self.xxsite) - self.xxdomain = os.path.join( - self.var_dir, 'templates', + self.xxdomain = os.path.join( + self.var_dir, 'templates', 'domains', 'example.com', 'xx', 'domain.txt') write('Domain template', self.xxdomain) self.xxlist = os.path.join( - self.var_dir, 'templates', + self.var_dir, 'templates', 'lists', 'test@example.com', 'xx', 'list.txt') write('List template', self.xxlist) diff --git a/src/mailman/utilities/tests/test_wrap.py b/src/mailman/utilities/tests/test_wrap.py index eca6f93be..b9feeed92 100644 --- a/src/mailman/utilities/tests/test_wrap.py +++ b/src/mailman/utilities/tests/test_wrap.py @@ -17,10 +17,8 @@ """Test text wrapping.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ + 'TestWrap', ] diff --git a/src/mailman/utilities/uid.py b/src/mailman/utilities/uid.py index 4fe862868..0b41b63c2 100644 --- a/src/mailman/utilities/uid.py +++ b/src/mailman/utilities/uid.py @@ -21,9 +21,6 @@ Use these functions to create unique ids rather than inlining calls to hashlib and whatnot. These are better instrumented for testing purposes. """ -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'UniqueIDFactory', 'factory', @@ -35,7 +32,6 @@ import uuid import errno from flufl.lock import Lock - from mailman.config import config from mailman.model.uid import UID from mailman.testing import layers -- cgit v1.2.3-70-g09d2