diff options
author | bwarsaw <> | 2005-12-30 18:50:08 +0000 |
---|---|---|
committer | bwarsaw <> | 2005-12-30 18:50:08 +0000 |
commit | d44c2c9f011075a7f6b6ffebe22ec3f17dda3a26 (patch) | |
tree | 6199ed049dba0f377f628b9c57a08b1ff9c3f500 /Mailman/Handlers | |
parent | 11ba661517e7606f5f38a8be87f68b32bff0afd4 (diff) | |
download | mailman2-d44c2c9f011075a7f6b6ffebe22ec3f17dda3a26.tar.gz mailman2-d44c2c9f011075a7f6b6ffebe22ec3f17dda3a26.tar.xz mailman2-d44c2c9f011075a7f6b6ffebe22ec3f17dda3a26.zip |
A cleansing pass, almost entirely cosmetic. Such things as whitespace
normalization, removal of tabs, copyright year updates to changed files,
docstring and comment fixes, and usage of True/False. I also made a pass
through the NEWS file.
One import was reordered, and after this commit I will move the mmdsr.readme
file to README.mmdsr.
From my perspective, after that we're ready to go.
I will port these changes forward to the trunk.
Diffstat (limited to 'Mailman/Handlers')
-rw-r--r-- | Mailman/Handlers/Approve.py | 35 | ||||
-rw-r--r-- | Mailman/Handlers/Cleanse.py | 3 | ||||
-rw-r--r-- | Mailman/Handlers/CookHeaders.py | 24 | ||||
-rw-r--r-- | Mailman/Handlers/Decorate.py | 3 | ||||
-rw-r--r-- | Mailman/Handlers/MimeDel.py | 4 | ||||
-rw-r--r-- | Mailman/Handlers/SMTPDirect.py | 13 | ||||
-rw-r--r-- | Mailman/Handlers/Scrubber.py | 11 | ||||
-rw-r--r-- | Mailman/Handlers/SpamDetect.py | 14 | ||||
-rw-r--r-- | Mailman/Handlers/ToArchive.py | 11 | ||||
-rw-r--r-- | Mailman/Handlers/ToDigest.py | 22 |
10 files changed, 73 insertions, 67 deletions
diff --git a/Mailman/Handlers/Approve.py b/Mailman/Handlers/Approve.py index 42b15e97..1ffd4388 100644 --- a/Mailman/Handlers/Approve.py +++ b/Mailman/Handlers/Approve.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Determine whether the message is approved for delivery. @@ -81,22 +82,22 @@ def process(mlist, msg, msgdata): part.set_payload(NL.join(lines)) stripped = True if stripped: - # MAS: Bug 1181161 - Now try all the text parts in case - # it's multipart/alternative with the approved line in - # HTML or other text part. We make a pattern from the - # approved line and delete it from all text/* parts in - # which we find it. It would be better to just iterate - # forward, but email compatability for pre Python 2.2 - # returns a list, not a true iterator. - # This will process all the multipart/alternative parts - # in the message as well as all other text parts. We - # shouldn't find the pattern outside the mp/a parts, but - # if we do, it is probably best to delete it anyway as it - # does contain the password. - # Make a pattern to delete. We can't just delete a line - # because line of HTML or other fancy text may include - # additional message text. This pattern works with HTML. - # It may not work with rtf or whatever else is possible. + # MAS: Bug 1181161 - Now try all the text parts in case it's + # multipart/alternative with the approved line in HTML or other + # text part. We make a pattern from the Approved line and delete + # it from all text/* parts in which we find it. It would be + # better to just iterate forward, but email compatability for pre + # Python 2.2 returns a list, not a true iterator. + # + # This will process all the multipart/alternative parts in the + # message as well as all other text parts. We shouldn't find the + # pattern outside the mp/a parts, but if we do, it is probably + # best to delete it anyway as it does contain the password. + # + # Make a pattern to delete. We can't just delete a line because + # line of HTML or other fancy text may include additional message + # text. This pattern works with HTML. It may not work with rtf + # or whatever else is possible. pattern = name + ':(\s| )*' + re.escape(passwd) for part in typed_subpart_iterator(msg, 'text'): if part is not None and part.get_payload() is not None: diff --git a/Mailman/Handlers/Cleanse.py b/Mailman/Handlers/Cleanse.py index b6e839bd..ea5a7fbf 100644 --- a/Mailman/Handlers/Cleanse.py +++ b/Mailman/Handlers/Cleanse.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Cleanse certain headers from all messages.""" diff --git a/Mailman/Handlers/CookHeaders.py b/Mailman/Handlers/CookHeaders.py index eee5991e..8fd1d064 100644 --- a/Mailman/Handlers/CookHeaders.py +++ b/Mailman/Handlers/CookHeaders.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Cook a message's Subject header.""" @@ -247,16 +248,16 @@ def prefix_subject(mlist, msg, msgdata): if len(lines) > 1 and lines[1] and lines[1][0] in ' \t': ws = lines[1][0] msgdata['origsubj'] = 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). + # 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 eveolved 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. + # 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 = unicode(subject, cset) # If the subject_prefix contains '%d', it is replaced with the # mailing list sequential number. Sequential number format allows @@ -316,7 +317,7 @@ def prefix_subject(mlist, msg, msgdata): else: h = uheader(mlist, prefix, 'Subject', continuation_ws=ws) h.append(recolon) - # TK: Subject is concatnated and unicode string. + # TK: Subject is concatenated and unicode string. subject = subject.encode(cset, 'replace') h.append(subject, cset) del msg['subject'] @@ -325,6 +326,7 @@ def prefix_subject(mlist, msg, msgdata): ss.append(subject, cset) msgdata['stripped_subject'] = ss + def ch_oneline(s): # Decode header string in one line and convert into single charset diff --git a/Mailman/Handlers/Decorate.py b/Mailman/Handlers/Decorate.py index 03266fae..a5df4010 100644 --- a/Mailman/Handlers/Decorate.py +++ b/Mailman/Handlers/Decorate.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Decorate a message by sticking the header and footer around it.""" diff --git a/Mailman/Handlers/MimeDel.py b/Mailman/Handlers/MimeDel.py index cf4ca6e8..906b12c3 100644 --- a/Mailman/Handlers/MimeDel.py +++ b/Mailman/Handlers/MimeDel.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """MIME-stripping filter for Mailman. @@ -90,7 +91,6 @@ def process(mlist, msg, msgdata): # headers. For now we'll move the subpart's payload into the outer part, # and then copy over its Content-Type: and Content-Transfer-Encoding: # headers (any others?). - # TK: Make this configurable from Gui/ContentFilter.py. if mlist.collapse_alternatives: collapse_multipart_alternatives(msg) if ctype == 'multipart/alternative': diff --git a/Mailman/Handlers/SMTPDirect.py b/Mailman/Handlers/SMTPDirect.py index 0d93073d..72b587e9 100644 --- a/Mailman/Handlers/SMTPDirect.py +++ b/Mailman/Handlers/SMTPDirect.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Local SMTP direct drop-off. @@ -135,11 +136,11 @@ def process(mlist, msg, msgdata): t0 = time.time() # Open the initial connection origrecips = msgdata['recips'] - # MAS: get the message sender now for logging. If we're using 'sender' - # and not 'from', bulkdeliver changes it for bounce processing. - # If we're VERPing, it doesn't matter because bulkdeliver is working - # on a copy, but otherwise msg gets changed. If the list is anonymous, - # the original sender is long gone, but Cleanse.py has logged it. + # MAS: get the message sender now for logging. If we're using 'sender' + # and not 'from', bulkdeliver changes it for bounce processing. If we're + # VERPing, it doesn't matter because bulkdeliver is working on a copy, but + # otherwise msg gets changed. If the list is anonymous, the original + # sender is long gone, but Cleanse.py has logged it. origsender = msgdata.get('original_sender', msg.get_sender()) # `undelivered' is a copy of chunks that we pop from to do deliveries. # This seems like a good tradeoff between robustness and resource diff --git a/Mailman/Handlers/Scrubber.py b/Mailman/Handlers/Scrubber.py index edaa47d2..a0c4896c 100644 --- a/Mailman/Handlers/Scrubber.py +++ b/Mailman/Handlers/Scrubber.py @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Cleanse a message for archiving.""" @@ -162,9 +163,9 @@ def calculate_attachments_dir(mlist, msg, msgdata): def replace_payload_by_text(msg, text, charset): - # TK: This is a common function in replacing the attachment and - # the main message by a text (scrubbing). Plus a flag indicating - # it has been scrubbed. + # TK: This is a common function in replacing the attachment and the main + # message by a text (scrubbing). Also, add a flag indicating it has been + # scrubbed. del msg['content-type'] del msg['content-transfer-encoding'] msg.set_payload(text, charset) @@ -218,7 +219,7 @@ Url: %(url)s raise DiscardMessage replace_payload_by_text(part, _('HTML attachment scrubbed and removed'), - # Adding charset arg and removing content-tpe + # Adding charset arg and removing content-type # sets content-type to text/plain lcset) elif sanitize == 2: diff --git a/Mailman/Handlers/SpamDetect.py b/Mailman/Handlers/SpamDetect.py index b5f9d0b6..79dc40dc 100644 --- a/Mailman/Handlers/SpamDetect.py +++ b/Mailman/Handlers/SpamDetect.py @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2004 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2005 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Do more detailed spam detection. @@ -67,7 +68,7 @@ class Tee: def write(self, s): self._outfp_a.write(s) self._outfp_b.write(s) - + # Class to capture the headers separate from the message body class HeaderGenerator(Generator): @@ -91,10 +92,9 @@ class HeaderGenerator(Generator): def process(mlist, msg, msgdata): - # Don't check if the message has been approved OR it is generated - # internally for administration because holding '-owner' notification - # may cause infinite loop of checking. (Actually, it is stopped - # elsewhere.) + # Don't check for spam if the message has been approved or it is generated + # internally for administration because holding '-owner' notification may + # cause infinite loop of checking. (Actually, it is stopped elsewhere.) if msgdata.get('approved') or msg.get('x-list-administrivia'): return # First do site hard coded header spam checks diff --git a/Mailman/Handlers/ToArchive.py b/Mailman/Handlers/ToArchive.py index 59bf680f..6deb0958 100644 --- a/Mailman/Handlers/ToArchive.py +++ b/Mailman/Handlers/ToArchive.py @@ -1,18 +1,19 @@ -# Copyright (C) 1998,1999,2000,2001,2002 by the Free Software Foundation, Inc. +# Copyright (C) 1998-2005 by the Free Software Foundation, Inc. # # This program 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 2 # of the License, or (at your option) any later version. -# +# # This program 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 this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Add the message to the archives.""" diff --git a/Mailman/Handlers/ToDigest.py b/Mailman/Handlers/ToDigest.py index b0f948ac..e796a874 100644 --- a/Mailman/Handlers/ToDigest.py +++ b/Mailman/Handlers/ToDigest.py @@ -12,10 +12,10 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. -"""Add the message to the list's current digest and possibly send it. -""" +"""Add the message to the list's current digest and possibly send it.""" # Messages are accumulated to a Unix mailbox compatible file containing all # the messages destined for the digest. This file must be parsable by the @@ -90,19 +90,17 @@ def process(mlist, msg, msgdata): # This is a bit of a kludge to get the mbox file moved to the digest # queue directory. try: - # Let's close in try - except here because a error in send_digest - # can stop regular delivery silently. Unsuccessful digest - # delivery should be tried again by cron and the site - # administrator will be notified of any error explicitly by the - # cron error message. + # Enclose in try/except here because a error in send_digest() can + # silently stop regular delivery. Unsuccessful digest delivery + # should be tried again by cron and the site administrator will be + # notified of any error explicitly by the cron error message. mboxfp.seek(0) send_digests(mlist, mboxfp) os.unlink(mboxfile) except Exception, errmsg: - # I know bare except is prohibited in mailman coding but we can't - # forcast what new exception can occur here. + # Bare except is generally prohibited in Mailman, but we can't + # forecast what exceptions can occur here. syslog('error', 'send_digests() failed: %s', errmsg) - pass mboxfp.close() @@ -341,7 +339,7 @@ def send_i18n_digests(mlist, mboxfp): else: # If decoded payload is empty, this may be multipart message. # -- just stringfy it. - payload = msg.get_payload(decode=True)\ + payload = msg.get_payload(decode=True) \ or msg.as_string().split('\n\n',1)[1] mcset = msg.get_content_charset('') if mcset and mcset <> lcset and mcset <> lcset_out: |