Mark Sapiro wrote: > >The attached Quoting.py ...
This time, it's really attached (renamed Quoting.py.txt to get through content filtering) -- Mark Sapiro <m...@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
# Copyright (C) 2010 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. """Determine whether this message has excessive quoting. This modules tests some messages for excessive quoting. It is pretty simplistic. It looks only at the first text/plain message part if any, thus it totally misses any HTML only messages if they pass content filtering. Also, this doesn't address the problem of a "me too" post with an "original message" (often an entire digest) included without lines prefixed by quoting characters. It should come after MimeDel in the pipeline. RATIO and QRE should be list settings. """ import re from Mailman import i18n from Mailman import Errors from Mailman.Handlers.Hold import hold_for_approval # re for quoted line QRE = re.compile('^\s*[>:|]') # re for blank lines BLRE = re.compile('^\s*$') # Ratio of quoted to unquoted lines considered excessive RATIO = 1.0 def _(s): return s class ExcessiveQuoting(Errors.HoldMessage): reason = _('Message has excessive quoting') rejection = _( 'Your message has too high a ratio of quoted text to original text.') # And reset the translator _ = i18n._ def process(mlist, msg, msgdata): if msgdata.get('approved'): return part = None if msg.is_multipart(): for part in msg.walk(): if part.get_content_type() == 'text/plain': break else: part = msg if not part or part.get_content_type() <> 'text/plain': return # We now have the text/plain message or the first text/plain part payload = part.get_payload(decode=True) uql = ql = 0.0 for line in payload.splitlines(): if QRE.match(line): ql += 1.0 elif not BLRE.match(line): uql += 1.0 if uql == 0.0 or ql / uql >= RATIO: hold_for_approval(mlist, msg, msgdata, ExcessiveQuoting)
------------------------------------------------------ Mailman-Users mailing list Mailman-Users@python.org http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://wiki.list.org/x/AgA3 Security Policy: http://wiki.list.org/x/QIA9 Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/ Unsubscribe: http://mail.python.org/mailman/options/mailman-users/archive%40jab.org