summaryrefslogtreecommitdiff
path: root/src/mailman/app/docs
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/app/docs
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/app/docs')
-rw-r--r--src/mailman/app/docs/bounces.rst4
-rw-r--r--src/mailman/app/docs/chains.rst36
-rw-r--r--src/mailman/app/docs/hooks.rst18
-rw-r--r--src/mailman/app/docs/lifecycle.rst6
-rw-r--r--src/mailman/app/docs/message.rst8
-rw-r--r--src/mailman/app/docs/moderator.rst46
-rw-r--r--src/mailman/app/docs/pipelines.rst10
-rw-r--r--src/mailman/app/docs/subscriptions.rst4
-rw-r--r--src/mailman/app/docs/system.rst2
9 files changed, 67 insertions, 67 deletions
diff --git a/src/mailman/app/docs/bounces.rst b/src/mailman/app/docs/bounces.rst
index 31d2e51d2..127a05ef6 100644
--- a/src/mailman/app/docs/bounces.rst
+++ b/src/mailman/app/docs/bounces.rst
@@ -34,7 +34,7 @@ to the original message author.
>>> items = get_queue_messages('virgin')
>>> len(items)
1
- >>> print items[0].msg.as_string()
+ >>> print(items[0].msg.as_string())
Subject: Something important
From: text-owner@example.com
To: aperson@example.com
@@ -72,7 +72,7 @@ passed in as an instance of a ``RejectMessage`` exception.
>>> items = get_queue_messages('virgin')
>>> len(items)
1
- >>> print items[0].msg.as_string()
+ >>> print(items[0].msg.as_string())
Subject: Something important
From: text-owner@example.com
To: aperson@example.com
diff --git a/src/mailman/app/docs/chains.rst b/src/mailman/app/docs/chains.rst
index 7975d23fe..1feecbd68 100644
--- a/src/mailman/app/docs/chains.rst
+++ b/src/mailman/app/docs/chains.rst
@@ -17,9 +17,9 @@ The `discard` chain simply throws the message away.
::
>>> chain = config.chains['discard']
- >>> print chain.name
+ >>> print(chain.name)
discard
- >>> print chain.description
+ >>> print(chain.description)
Discard a message and stop processing.
>>> mlist = create_list('test@example.com')
@@ -33,8 +33,8 @@ The `discard` chain simply throws the message away.
... """)
>>> def print_msgid(event):
- ... print '{0}: {1}'.format(
- ... event.chain.name.upper(), event.msg.get('message-id', 'n/a'))
+ ... print('{0}: {1}'.format(
+ ... event.chain.name.upper(), event.msg.get('message-id', 'n/a')))
>>> from mailman.core.chains import process
>>> from mailman.testing.helpers import event_subscribers
@@ -52,9 +52,9 @@ this action.
::
>>> chain = config.chains['reject']
- >>> print chain.name
+ >>> print(chain.name)
reject
- >>> print chain.description
+ >>> print(chain.description)
Reject/bounce a message and stop processing.
>>> with event_subscribers(print_msgid):
@@ -67,7 +67,7 @@ The bounce message is now sitting in the `virgin` queue.
>>> qfiles = get_queue_messages('virgin')
>>> len(qfiles)
1
- >>> print qfiles[0].msg.as_string()
+ >>> print(qfiles[0].msg.as_string())
Subject: My first post
From: test-owner@example.com
To: aperson@example.com
@@ -95,9 +95,9 @@ and depending on the list's settings, sends a notification to both the
original sender and the list moderators. ::
>>> chain = config.chains['hold']
- >>> print chain.name
+ >>> print(chain.name)
hold
- >>> print chain.description
+ >>> print(chain.description)
Hold a message and stop processing.
>>> with event_subscribers(print_msgid):
@@ -120,7 +120,7 @@ is addressed to the original sender.
This one is addressed to the list moderators.
- >>> print messages[0].as_string()
+ >>> print(messages[0].as_string())
Subject: test@example.com post from aperson@example.com requires approval
From: test-owner@example.com
To: test-owner@example.com
@@ -173,7 +173,7 @@ This one is addressed to the list moderators.
This message is addressed to the sender of the message.
- >>> print messages[1].as_string()
+ >>> print(messages[1].as_string())
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
@@ -235,7 +235,7 @@ The message itself is held in the message store.
>>> msg = getUtility(IMessageStore).get_message_by_id(
... rdata['_mod_message_id'])
- >>> print msg.as_string()
+ >>> print(msg.as_string())
From: aperson@example.com
To: test@example.com
Subject: My first post
@@ -254,9 +254,9 @@ processed and sent on to the list membership.
::
>>> chain = config.chains['accept']
- >>> print chain.name
+ >>> print(chain.name)
accept
- >>> print chain.description
+ >>> print(chain.description)
Accept a message.
>>> with event_subscribers(print_msgid):
@@ -266,7 +266,7 @@ processed and sent on to the list membership.
>>> qfiles = get_queue_messages('pipeline')
>>> len(qfiles)
1
- >>> print qfiles[0].msg.as_string()
+ >>> print(qfiles[0].msg.as_string())
From: aperson@example.com
To: test@example.com
Subject: My first post
@@ -290,9 +290,9 @@ other input chain is defined for a mailing list. It runs through the default
rules.
>>> chain = config.chains['default-posting-chain']
- >>> print chain.name
+ >>> print(chain.name)
default-posting-chain
- >>> print chain.description
+ >>> print(chain.description)
The built-in moderation chain.
Once the sender is a member of the mailing list, the previously created
@@ -310,7 +310,7 @@ This message will end up in the `pipeline` queue.
>>> qfiles = get_queue_messages('pipeline')
>>> len(qfiles)
1
- >>> print qfiles[0].msg.as_string()
+ >>> print(qfiles[0].msg.as_string())
From: aperson@example.com
To: test@example.com
Subject: My first post
diff --git a/src/mailman/app/docs/hooks.rst b/src/mailman/app/docs/hooks.rst
index a29c7ee10..ca33f55fe 100644
--- a/src/mailman/app/docs/hooks.rst
+++ b/src/mailman/app/docs/hooks.rst
@@ -14,7 +14,7 @@ Hooks name an importable callable so it must be accessible on ``sys.path``.
>>> hook_path = os.path.join(config_directory, 'hooks.py')
>>> with open(hook_path, 'w') as fp:
- ... print >> fp, """\
+ ... print("""\
... counter = 1
... def pre_hook():
... global counter
@@ -25,7 +25,7 @@ Hooks name an importable callable so it must be accessible on ``sys.path``.
... global counter
... print 'post-hook:', counter
... counter += 1
- ... """
+ ... """, file=fp)
>>> fp.close()
@@ -36,13 +36,13 @@ We can set the pre-hook in the configuration file.
>>> config_path = os.path.join(config_directory, 'hooks.cfg')
>>> with open(config_path, 'w') as fp:
- ... print >> fp, """\
+ ... print("""\
... [meta]
... extends: test.cfg
...
... [mailman]
... pre_hook: hooks.pre_hook
- ... """
+ ... """, file=fp)
The hooks are run in the second and third steps of initialization. However,
we can't run those initialization steps in process, so call a command line
@@ -61,7 +61,7 @@ script that will produce no output to force the hooks to run.
... stdout=subprocess.PIPE, stderr=subprocess.PIPE)
... stdout, stderr = proc.communicate()
... assert proc.returncode == 0, stderr
- ... print stdout
+ ... print(stdout)
>>> call()
pre-hook: 1
@@ -77,13 +77,13 @@ We can set the post-hook in the configuration file.
::
>>> with open(config_path, 'w') as fp:
- ... print >> fp, """\
+ ... print("""\
... [meta]
... extends: test.cfg
...
... [mailman]
... post_hook: hooks.post_hook
- ... """
+ ... """, file=fp)
>>> call()
post-hook: 1
@@ -99,14 +99,14 @@ We can set the pre- and post-hooks in the configuration file.
::
>>> with open(config_path, 'w') as fp:
- ... print >> fp, """\
+ ... print("""\
... [meta]
... extends: test.cfg
...
... [mailman]
... pre_hook: hooks.pre_hook
... post_hook: hooks.post_hook
- ... """
+ ... """, file=fp)
>>> call()
pre-hook: 1
diff --git a/src/mailman/app/docs/lifecycle.rst b/src/mailman/app/docs/lifecycle.rst
index ee7185373..f059806af 100644
--- a/src/mailman/app/docs/lifecycle.rst
+++ b/src/mailman/app/docs/lifecycle.rst
@@ -52,7 +52,7 @@ However, all addresses are linked to users.
>>> user_manager = getUtility(IUserManager)
>>> for address in owners:
... user = user_manager.get_user(address)
- ... print int(user.user_id.int), list(user.addresses)[0]
+ ... print(int(user.user_id.int), list(user.addresses)[0])
1 aperson@example.com
2 bperson@example.com
3 cperson@example.com
@@ -64,7 +64,7 @@ the system, they won't be created again.
>>> bee = create_list('bee@example.com', owners)
>>> from operator import attrgetter
>>> for user in sorted(bee.owners.users, key=attrgetter('user_id')):
- ... print int(user.user_id.int), list(user.addresses)[0]
+ ... print(int(user.user_id.int), list(user.addresses)[0])
1 aperson@example.com
2 bperson@example.com
3 cperson@example.com
@@ -82,7 +82,7 @@ artifacts.
>>> remove_list(bee)
>>> from mailman.interfaces.listmanager import IListManager
- >>> print getUtility(IListManager).get('bee@example.com')
+ >>> print(getUtility(IListManager).get('bee@example.com'))
None
We should now be able to completely recreate the mailing list.
diff --git a/src/mailman/app/docs/message.rst b/src/mailman/app/docs/message.rst
index 3c3fd8ea8..658bf4e30 100644
--- a/src/mailman/app/docs/message.rst
+++ b/src/mailman/app/docs/message.rst
@@ -32,7 +32,7 @@ The message will end up in the `virgin` queue.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
@@ -59,7 +59,7 @@ Again, the message will end up in the `virgin` queue but with the original
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg['precedence']
+ >>> print(messages[0].msg['precedence'])
list
Sometimes we want to send the message without a `Precedence:` header such as
@@ -74,7 +74,7 @@ Again, the message will end up in the `virgin` queue but without the
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg['precedence']
+ >>> print(messages[0].msg['precedence'])
None
However, if the message already has a `Precedence:` header, setting the
@@ -85,5 +85,5 @@ However, if the message already has a `Precedence:` header, setting the
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg['precedence']
+ >>> print(messages[0].msg['precedence'])
junk
diff --git a/src/mailman/app/docs/moderator.rst b/src/mailman/app/docs/moderator.rst
index ec48f6e88..ee9df8eb5 100644
--- a/src/mailman/app/docs/moderator.rst
+++ b/src/mailman/app/docs/moderator.rst
@@ -84,13 +84,13 @@ The most trivial is to simply defer a decision for now.
This leaves the message in the requests database.
>>> key, data = requests.get_request(1)
- >>> print key
+ >>> print(key)
<aardvark>
The moderator can also discard the message.
>>> handle_message(mlist, 1, Action.discard)
- >>> print requests.get_request(1)
+ >>> print(requests.get_request(1))
None
The message can be rejected, which bounces the message back to the original
@@ -100,7 +100,7 @@ sender.
The message is no longer available in the requests database.
- >>> print requests.get_request(2)
+ >>> print(requests.get_request(2))
None
And there is one message in the *virgin* queue - the rejection notice.
@@ -109,7 +109,7 @@ And there is one message in the *virgin* queue - the rejection notice.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: Request to mailing list "A Test List" rejected
@@ -135,7 +135,7 @@ And there is one message in the *virgin* queue - the rejection notice.
The bounce gets sent to the original sender.
>>> for recipient in sorted(messages[0].msgdata['recipients']):
- ... print recipient
+ ... print(recipient)
bart@example.org
Or the message can be approved.
@@ -158,7 +158,7 @@ however the message metadata indicates that the message has been approved.
>>> messages = get_queue_messages('pipeline')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
From: cris@example.org
To: ant@example.com
Subject: Something important
@@ -195,7 +195,7 @@ a copy to be preserve, which skips deleting the message from the storage.
>>> from mailman.interfaces.messages import IMessageStore
>>> from zope.component import getUtility
>>> message_store = getUtility(IMessageStore)
- >>> print message_store.get_message_by_id('<dolphin>')['message-id']
+ >>> print(message_store.get_message_by_id('<dolphin>')['message-id'])
<dolphin>
Orthogonal to preservation, the message can also be forwarded to another
@@ -221,14 +221,14 @@ The forwarded message is in the virgin queue, destined for the moderator.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
Subject: Forward of moderated message
From: ant-bounces@example.com
To: zack@example.com
...
>>> for recipient in sorted(messages[0].msgdata['recipients']):
- ... print recipient
+ ... print(recipient)
zack@example.com
@@ -264,7 +264,7 @@ simply defer a decision for now.
The held subscription can also be discarded.
>>> handle_subscription(mlist, 2, Action.discard)
- >>> print requests.get_request(2)
+ >>> print(requests.get_request(2))
None
Gwen tries to subscribe to the mailing list, but...
@@ -283,7 +283,7 @@ Gwen tries to subscribe to the mailing list, but...
...and she receives a rejection notice.
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: Request to mailing list "A Test List" rejected
@@ -315,7 +315,7 @@ The moderators accept the subscription request.
And now Herb is a member of the mailing list.
- >>> print mlist.members.get_member('herb@example.org').address
+ >>> print(mlist.members.get_member('herb@example.org').address)
Herb Person <herb@example.org>
@@ -335,14 +335,14 @@ As with subscription requests, the unsubscription request can be deferred.
>>> from mailman.app.moderator import handle_unsubscription
>>> handle_unsubscription(mlist, 2, Action.defer)
- >>> print mlist.members.get_member('herb@example.org').address
+ >>> print(mlist.members.get_member('herb@example.org').address)
Herb Person <herb@example.org>
The held unsubscription can also be discarded, and the member will remain
subscribed.
>>> handle_unsubscription(mlist, 2, Action.discard)
- >>> print mlist.members.get_member('herb@example.org').address
+ >>> print(mlist.members.get_member('herb@example.org').address)
Herb Person <herb@example.org>
The request can be rejected, in which case a message is sent to the member,
@@ -351,7 +351,7 @@ and the person remains a member of the mailing list.
>>> hold_unsubscription(mlist, 'herb@example.org')
2
>>> handle_unsubscription(mlist, 2, Action.reject, 'No can do')
- >>> print mlist.members.get_member('herb@example.org').address
+ >>> print(mlist.members.get_member('herb@example.org').address)
Herb Person <herb@example.org>
Herb gets a rejection notice.
@@ -361,7 +361,7 @@ Herb gets a rejection notice.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: Request to mailing list "A Test List" rejected
@@ -385,7 +385,7 @@ the mailing list.
2
>>> mlist.send_goodbye_message = False
>>> handle_unsubscription(mlist, 2, Action.accept)
- >>> print mlist.members.get_member('herb@example.org')
+ >>> print(mlist.members.get_member('herb@example.org'))
None
@@ -412,7 +412,7 @@ There's now a message in the virgin queue, destined for the list owner.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: New subscription request to A Test List from iris@example.org
@@ -434,7 +434,7 @@ Jeff is a member of the mailing list, and chooses to unsubscribe.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: New unsubscription request from A Test List by jeff@example.org
@@ -461,7 +461,7 @@ receive a membership change notice.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: A Test List subscription notification
@@ -480,7 +480,7 @@ get a notification.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: A Test List unsubscription notification
@@ -505,7 +505,7 @@ can get a welcome message.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: Welcome to the "A Test List" mailing list
@@ -529,7 +529,7 @@ goodbye message.
>>> messages = get_queue_messages('virgin')
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
MIME-Version: 1.0
...
Subject: You have been unsubscribed from the A Test List mailing list
diff --git a/src/mailman/app/docs/pipelines.rst b/src/mailman/app/docs/pipelines.rst
index 96d9d232a..5aaf7cf62 100644
--- a/src/mailman/app/docs/pipelines.rst
+++ b/src/mailman/app/docs/pipelines.rst
@@ -9,7 +9,7 @@ handlers, each of which is applied in turn. Unlike rules and chains, there is
no way to stop a pipeline from processing the message once it's started.
>>> mlist = create_list('test@example.com')
- >>> print mlist.posting_pipeline
+ >>> print(mlist.posting_pipeline)
default-posting-pipeline
>>> from mailman.core.pipelines import process
@@ -34,7 +34,7 @@ Messages hit the pipeline after they've been accepted for posting.
The message has been modified with additional headers, footer decorations,
etc.
- >>> print msg.as_string()
+ >>> print(msg.as_string())
From: aperson@example.com
To: test@example.com
Message-ID: <first>
@@ -73,7 +73,7 @@ processing queues.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
From: aperson@example.com
To: test@example.com
Message-ID: <first>
@@ -110,7 +110,7 @@ delivered to end recipients.
>>> len(messages)
1
- >>> print messages[0].msg.as_string()
+ >>> print(messages[0].msg.as_string())
From: aperson@example.com
To: test@example.com
Message-ID: <first>
@@ -141,7 +141,7 @@ There's now one message in the digest mailbox, getting ready to be sent.
>>> sum(1 for mboxmsg in digest)
1
- >>> print list(digest)[0].as_string()
+ >>> print(list(digest)[0].as_string())
From: aperson@example.com
To: test@example.com
Message-ID: <first>
diff --git a/src/mailman/app/docs/subscriptions.rst b/src/mailman/app/docs/subscriptions.rst
index dd8298cb3..8c3d8b28d 100644
--- a/src/mailman/app/docs/subscriptions.rst
+++ b/src/mailman/app/docs/subscriptions.rst
@@ -18,7 +18,7 @@ membership role. At first, there are no memberships.
>>> sum(1 for member in service)
0
>>> from uuid import UUID
- >>> print service.get_member(UUID(int=801))
+ >>> print(service.get_member(UUID(int=801)))
None
@@ -60,7 +60,7 @@ And all the subscribed members can now be displayed.
as MemberRole.member>]
>>> sum(1 for member in service)
3
- >>> print service.get_member(UUID(int=3))
+ >>> print(service.get_member(UUID(int=3)))
<Member: anne <anne@example.com> on test@example.com as MemberRole.owner>
New members can also be added by providing an existing user id instead of an
diff --git a/src/mailman/app/docs/system.rst b/src/mailman/app/docs/system.rst
index 844db9ee6..a7d2285d3 100644
--- a/src/mailman/app/docs/system.rst
+++ b/src/mailman/app/docs/system.rst
@@ -15,7 +15,7 @@ implements the ``ISystem`` interface.
The Mailman version is also available via the ``system`` object.
- >>> print system.mailman_version
+ >>> print(system.mailman_version)
GNU Mailman ...
The Python version running underneath is also available via the ``system``