summaryrefslogtreecommitdiff
path: root/src/mailman/runners
diff options
context:
space:
mode:
authorBarry Warsaw2014-04-28 11:23:35 -0400
committerBarry Warsaw2014-04-28 11:23:35 -0400
commitd4d71f71f08d6d440b17482eecc5472dcfe6cbae (patch)
tree71f08b3d60f698883294eaa6d1bf366a095da011 /src/mailman/runners
parent7536530dcd8d6303c0a869e8c9c2cb2517b9b018 (diff)
downloadmailman-d4d71f71f08d6d440b17482eecc5472dcfe6cbae.tar.gz
mailman-d4d71f71f08d6d440b17482eecc5472dcfe6cbae.tar.zst
mailman-d4d71f71f08d6d440b17482eecc5472dcfe6cbae.zip
Use print functions consistently through, and update all __future__ imports to
reflect this. Also, mock out sys.stderr on some tests so that their nose2 output is quieter. A few other minor coding style consistencies.
Diffstat (limited to 'src/mailman/runners')
-rw-r--r--src/mailman/runners/digest.py58
-rw-r--r--src/mailman/runners/docs/command.rst14
-rw-r--r--src/mailman/runners/docs/digester.rst10
-rw-r--r--src/mailman/runners/docs/incoming.rst28
-rw-r--r--src/mailman/runners/docs/lmtp.rst4
-rw-r--r--src/mailman/runners/docs/nntp.rst2
-rw-r--r--src/mailman/runners/docs/outgoing.rst4
-rw-r--r--src/mailman/runners/rest.py2
-rw-r--r--src/mailman/runners/retry.py2
-rw-r--r--src/mailman/runners/tests/test_outgoing.py2
-rw-r--r--src/mailman/runners/tests/test_retry.py2
11 files changed, 64 insertions, 64 deletions
diff --git a/src/mailman/runners/digest.py b/src/mailman/runners/digest.py
index b48dfba13..f2c888275 100644
--- a/src/mailman/runners/digest.py
+++ b/src/mailman/runners/digest.py
@@ -17,7 +17,7 @@
"""Digest runner."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
@@ -95,7 +95,7 @@ class Digester:
mlist.fqdn_listname, mlist.digest_header_uri))
self._header = ''
self._toc = StringIO()
- print >> self._toc, _("Today's Topics:\n")
+ print(_("Today's Topics:\n"), file=self._toc)
def add_to_toc(self, msg, count):
"""Add a message to the table of contents."""
@@ -127,10 +127,10 @@ class Digester:
first = True
for line in lines:
if first:
- print >> self._toc, ' ', line
+ print(' ', line, file=self._toc)
first = False
else:
- print >> self._toc, ' ', line.lstrip()
+ print(' ', line.lstrip(), file=self._toc)
def add_message(self, msg, count):
"""Add the message to the digest."""
@@ -225,12 +225,12 @@ class RFC1153Digester(Digester):
self._separator70 = '-' * 70
self._separator30 = '-' * 30
self._text = StringIO()
- print >> self._text, self._masthead
- print >> self._text
+ print(self._masthead, file=self._text)
+ print(file=self._text)
# Add the optional digest header.
if mlist.digest_header_uri is not None:
- print >> self._text, self._header
- print >> self._text
+ print(self._header, file=self._text)
+ print(file=self._text)
# Calculate the set of headers we're to keep in the RFC1153 digest.
self._keepers = set(config.digests.plain_digest_keep_headers.split())
@@ -239,24 +239,24 @@ class RFC1153Digester(Digester):
def add_toc(self, count):
"""Add the table of contents."""
- print >> self._text, self._toc.getvalue()
- print >> self._text
- print >> self._text, self._separator70
- print >> self._text
+ print(self._toc.getvalue(), file=self._text)
+ print(file=self._text)
+ print(self._separator70, file=self._text)
+ print(file=self._text)
def add_message(self, msg, count):
"""Add the message to the digest."""
if count > 1:
- print >> self._text, self._separator30
- print >> self._text
+ print(self._separator30, file=self._text)
+ print(file=self._text)
# Each message section contains a few headers.
for header in config.digests.plain_digest_keep_headers.split():
if header in msg:
value = oneline(msg[header], in_unicode=True)
value = wrap('{0}: {1}'.format(header, value))
value = '\n\t'.join(value.split('\n'))
- print >> self._text, value
- print >> self._text
+ print(value, file=self._text)
+ print(file=self._text)
# Add the payload. If the decoded payload is empty, this may be a
# multipart message. In that case, just stringify it.
payload = msg.get_payload(decode=True)
@@ -267,9 +267,9 @@ class RFC1153Digester(Digester):
except (LookupError, TypeError):
# Unknown or empty charset.
payload = unicode(payload, 'us-ascii', 'replace')
- print >> self._text, payload
+ print(payload, file=self._text)
if not payload.endswith('\n'):
- print >> self._text
+ print(file=self._text)
def finish(self):
"""Finish up the digest, producing the email-ready copy."""
@@ -286,18 +286,18 @@ class RFC1153Digester(Digester):
# MAS: There is no real place for the digest_footer in an RFC 1153
# compliant digest, so add it as an additional message with
# Subject: Digest Footer
- print >> self._text, self._separator30
- print >> self._text
- print >> self._text, 'Subject: ' + _('Digest Footer')
- print >> self._text
- print >> self._text, footer_text
- print >> self._text
- print >> self._text, self._separator30
- print >> self._text
+ print(self._separator30, file=self._text)
+ print(file=self._text)
+ print('Subject: ' + _('Digest Footer'), file=self._text)
+ print(file=self._text)
+ print(footer_text, file=self._text)
+ print(file=self._text)
+ print(self._separator30, file=self._text)
+ print(file=self._text)
# Add the sign-off.
sign_off = _('End of ') + self._digest_id
- print >> self._text, sign_off
- print >> self._text, '*' * len(sign_off)
+ print(sign_off, file=self._text)
+ print('*' * len(sign_off), file=self._text)
# If the digest message can't be encoded by the list character set,
# fall back to utf-8.
text = self._text.getvalue()
@@ -325,7 +325,7 @@ class DigestRunner(Runner):
rfc1153_digest = RFC1153Digester(mlist, volume, digest_number)
# Cruise through all the messages in the mailbox, first building
# the table of contents and accumulating Subject: headers and
- # authors. The question really is whether it's better from a
+ # authors. The question really is whether it's better from a1
# performance and memory footprint to go through the mailbox once
# and cache the messages in a list, or to cruise through the
# mailbox twice. We'll do the latter, but it's a complete guess.
diff --git a/src/mailman/runners/docs/command.rst b/src/mailman/runners/docs/command.rst
index 43682056b..a7a4da8ed 100644
--- a/src/mailman/runners/docs/command.rst
+++ b/src/mailman/runners/docs/command.rst
@@ -41,7 +41,7 @@ And now the response is in the ``virgin`` queue.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: The results of your email commands
From: test-bounces@example.com
To: aperson@example.com
@@ -91,7 +91,7 @@ message is plain text.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: The results of your email commands
From: test-bounces@example.com
To: bperson@example.com
@@ -144,7 +144,7 @@ address, and the other is the results of his email command.
>>> registrar = getUtility(IRegistrar)
>>> for item in messages:
... subject = item.msg['subject']
- ... print 'Subject:', subject
+ ... print('Subject:', subject)
... if 'confirm' in str(subject):
... token = str(subject).split()[1].strip()
... status = registrar.confirm(token)
@@ -171,7 +171,7 @@ Similarly, to leave a mailing list, the user need only email the ``-leave`` or
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: The results of your email commands
From: test-bounces@example.com
To: dperson@example.com
@@ -206,7 +206,7 @@ The ``-confirm`` address is also available as an implicit command.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: The results of your email commands
From: test-bounces@example.com
To: dperson@example.com
@@ -250,7 +250,7 @@ looked at by the command queue.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: The results of your email commands
...
<BLANKLINE>
@@ -282,7 +282,7 @@ The ``stop`` command is an alias for ``end``.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: The results of your email commands
...
<BLANKLINE>
diff --git a/src/mailman/runners/docs/digester.rst b/src/mailman/runners/docs/digester.rst
index 96e8739e3..cd0fba67c 100644
--- a/src/mailman/runners/docs/digester.rst
+++ b/src/mailman/runners/docs/digester.rst
@@ -48,7 +48,7 @@ messages to put in the digest.
The marker message is empty.
- >>> print entry.msg.as_string()
+ >>> print(entry.msg.as_string())
But the message metadata has a reference to the digest file.
::
@@ -97,7 +97,7 @@ The MIME digest is a multipart, and the RFC 1153 digest is the other one.
The MIME digest has lots of good stuff, all contained in the multipart.
- >>> print mime.msg.as_string()
+ >>> print(mime.msg.as_string())
Content-Type: multipart/mixed; boundary="===============...=="
MIME-Version: 1.0
From: test-request@example.com
@@ -199,7 +199,7 @@ The MIME digest has lots of good stuff, all contained in the multipart.
The RFC 1153 contains the digest in a single plain text message.
- >>> print rfc1153.msg.as_string()
+ >>> print(rfc1153.msg.as_string())
From: test-request@example.com
Subject: Test Digest, Vol 1, Issue 1
To: test@example.com
@@ -342,7 +342,7 @@ One of which is the MIME digest and the other of which is the RFC 1153 digest.
You can see that the digests contain a mix of French and Japanese.
- >>> print mime.msg.as_string()
+ >>> print(mime.msg.as_string())
Content-Type: multipart/mixed; boundary="===============...=="
MIME-Version: 1.0
From: test-request@example.com
@@ -411,7 +411,7 @@ You can see that the digests contain a mix of French and Japanese.
The RFC 1153 digest will be encoded in UTF-8 since it contains a mixture of
French and Japanese characters.
- >>> print rfc1153.msg.as_string()
+ >>> print(rfc1153.msg.as_string())
From: test-request@example.com
Subject: Groupe Test, Vol 1, Parution 2
To: test@example.com
diff --git a/src/mailman/runners/docs/incoming.rst b/src/mailman/runners/docs/incoming.rst
index 8830031e6..0ae3336ca 100644
--- a/src/mailman/runners/docs/incoming.rst
+++ b/src/mailman/runners/docs/incoming.rst
@@ -12,7 +12,7 @@ posted to the mailing list. This chain is processed with the message
eventually ending up in one of the four disposition states described above.
>>> mlist = create_list('test@example.com')
- >>> print mlist.posting_chain
+ >>> print(mlist.posting_chain)
default-posting-chain
@@ -43,11 +43,11 @@ While configurable, the *sender addresses* by default are those named in the
>>> from zope.component import getUtility
>>> from mailman.interfaces.usermanager import IUserManager
>>> user_manager = getUtility(IUserManager)
- >>> print user_manager.get_address('xperson@example.com')
+ >>> print(user_manager.get_address('xperson@example.com'))
None
- >>> print user_manager.get_address('yperson@example.com')
+ >>> print(user_manager.get_address('yperson@example.com'))
None
- >>> print user_manager.get_address('zperson@example.com')
+ >>> print(user_manager.get_address('zperson@example.com'))
None
Inject the message into the incoming queue, similar to the way the upstream
@@ -69,10 +69,10 @@ not linked to a user and are unverified.
>>> for localpart in ('xperson', 'yperson', 'zperson'):
... email = '{0}@example.com'.format(localpart)
... address = user_manager.get_address(email)
- ... print '{0}; verified? {1}; user? {2}'.format(
- ... address.email,
- ... ('No' if address.verified_on is None else 'Yes'),
- ... user_manager.get_user(email))
+ ... print('{0}; verified? {1}; user? {2}'.format(
+ ... address.email,
+ ... ('No' if address.verified_on is None else 'Yes'),
+ ... user_manager.get_user(email)))
xperson@example.com; verified? No; user? None
yperson@example.com; verified? No; user? None
zperson@example.com; verified? No; user? None
@@ -116,7 +116,7 @@ Now the message is in the pipeline queue.
>>> messages = get_queue_messages('pipeline')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
From: aperson@example.com
To: test@example.com
Subject: My first post
@@ -146,11 +146,11 @@ pipeline queue.
>>> from mailman.interfaces.chain import ChainEvent
>>> def on_chain(event):
... if isinstance(event, ChainEvent):
- ... print event
- ... print event.chain
- ... print 'From: {0}\nTo: {1}\nMessage-ID: {2}'.format(
+ ... print(event)
+ ... print(event.chain)
+ ... print('From: {0}\nTo: {1}\nMessage-ID: {2}'.format(
... event.msg['from'], event.msg['to'],
- ... event.msg['message-id'])
+ ... event.msg['message-id']))
>>> mlist.emergency = True
@@ -234,7 +234,7 @@ to the original sender.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: My first post
From: test-owner@example.com
To: aperson@example.com
diff --git a/src/mailman/runners/docs/lmtp.rst b/src/mailman/runners/docs/lmtp.rst
index 3ce145907..c2227581f 100644
--- a/src/mailman/runners/docs/lmtp.rst
+++ b/src/mailman/runners/docs/lmtp.rst
@@ -71,7 +71,7 @@ queue.
>>> messages = get_queue_messages('in')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
From: anne.person@example.com
To: mylist@example.com
Subject: An interesting message
@@ -134,7 +134,7 @@ command queue for processing.
>>> messages = get_queue_messages('command')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
From: anne.person@example.com
To: mylist-request@example.com
Subject: Help
diff --git a/src/mailman/runners/docs/nntp.rst b/src/mailman/runners/docs/nntp.rst
index 31c7210cf..372fa5744 100644
--- a/src/mailman/runners/docs/nntp.rst
+++ b/src/mailman/runners/docs/nntp.rst
@@ -45,7 +45,7 @@ The message gets copied to the NNTP queue for preparation and posting.
The message was successfully posted the NNTP server.
- >>> print nntpd.get_message().as_string()
+ >>> print(nntpd.get_message().as_string())
From: aperson@example.com
To: test@example.com
Newsgroups: comp.lang.python
diff --git a/src/mailman/runners/docs/outgoing.rst b/src/mailman/runners/docs/outgoing.rst
index d8963ae00..a3220e423 100644
--- a/src/mailman/runners/docs/outgoing.rst
+++ b/src/mailman/runners/docs/outgoing.rst
@@ -74,7 +74,7 @@ Every recipient got the same copy of the message.
>>> len(messages)
1
- >>> print messages[0].as_string()
+ >>> print(messages[0].as_string())
From: aperson@example.com
To: test@example.com
Subject: My first post
@@ -119,7 +119,7 @@ recipients.
>>> from operator import itemgetter
>>> def show_headers(messages):
... for message in sorted(messages, key=itemgetter('x-rcptto')):
- ... print message['X-RcptTo'], message['X-MailFrom']
+ ... print(message['X-RcptTo'], message['X-MailFrom'])
>>> show_headers(messages)
aperson@example.com test-bounces@example.com
diff --git a/src/mailman/runners/rest.py b/src/mailman/runners/rest.py
index fb21bf534..5980e6263 100644
--- a/src/mailman/runners/rest.py
+++ b/src/mailman/runners/rest.py
@@ -17,7 +17,7 @@
"""Start the administrative HTTP server."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
diff --git a/src/mailman/runners/retry.py b/src/mailman/runners/retry.py
index 41220b989..b4148ee3a 100644
--- a/src/mailman/runners/retry.py
+++ b/src/mailman/runners/retry.py
@@ -17,7 +17,7 @@
"""Retry delivery."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
diff --git a/src/mailman/runners/tests/test_outgoing.py b/src/mailman/runners/tests/test_outgoing.py
index feff2799a..62f6776b1 100644
--- a/src/mailman/runners/tests/test_outgoing.py
+++ b/src/mailman/runners/tests/test_outgoing.py
@@ -17,7 +17,7 @@
"""Test the outgoing runner."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [
diff --git a/src/mailman/runners/tests/test_retry.py b/src/mailman/runners/tests/test_retry.py
index e4f021e45..28289bc05 100644
--- a/src/mailman/runners/tests/test_retry.py
+++ b/src/mailman/runners/tests/test_retry.py
@@ -17,7 +17,7 @@
"""Test the retry runner."""
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
__all__ = [