[PatchDiscussion] applied: strip some bottom-quoting from mailins
[email protected] (zwiki-repo)
| Newsgroups | gmane.comp.web.zope.zwiki |
|---|---|
| Message-ID | <20080213103155.6A63F7800D__17781.3683673323$1202900182$gmane$org@mail.joyful.com> |
Fri Feb 8 19:59:36 PST 2008 Simon Michael <[email protected]> * strip some bottom-quoting from mailins M ./Extensions/mailin.py -5 +6 M ./Extensions/mailin_tests.py -3 +47 Fri Feb 8 19:59:36 PST 2008 Simon Michael <[email protected]> * strip some bottom-quoting from mailins diff -rN -u old-ZWiki/Extensions/mailin.py new-ZWiki/Extensions/mailin.py --- old-ZWiki/Extensions/mailin.py 2008-02-13 02:31:54.000000000 -0800 +++ new-ZWiki/Extensions/mailin.py 2008-02-13 02:31:54.000000000 -0800 @@ -281,13 +281,9 @@ """ # strip trailing newlines that seem to get added in transit body = re.sub(r'(?s)\n+$',r'\n',body) + body = stripBottomQuoted(body) # strip Bob's signature body = self.stripSignature(body) - # strip TBC (typical bloody citations) - #body = re.sub( - # r'(?si)----- ?message d\'origine.*',r'',body) - #body = re.sub( - # r'(?si)----- ?original message.*',r'',body) return body def stripSignature(self,body): @@ -510,6 +506,11 @@ # break # return folder +def stripBottomQuoted(body): + origmsg = '(Original Message|message d\'origine)' # XXX i18n.. ? + body = re.sub(r'(?smi)^-+ ?%s ?-+$.*' % origmsg, '', body) + return body + def mailin(self, msg): """ diff -rN -u old-ZWiki/Extensions/mailin_tests.py new-ZWiki/Extensions/mailin_tests.py --- old-ZWiki/Extensions/mailin_tests.py 2008-02-13 02:31:54.000000000 -0800 +++ new-ZWiki/Extensions/mailin_tests.py 2008-02-13 02:31:54.000000000 -0800 @@ -47,9 +47,48 @@ __str__ = __call__ -TESTMSG = str(TestMessage()) +TESTMSG = """\ +From: sender +To: recipient +Date: date +Subject: subject -TESTDARCSMSG = """\ +mailin comment + + +""" + +BOTTOMQUOTEDMSG = """\ +From: sender +To: recipient +Date: date +Subject: subject + +mailin comment + +-----Original Message----- +From: someone +Sent: ... +To: ... +Subject: blah blah blah + +blah BLAH +""" + +BOTTOMQUOTEDMSG2 = """\ +From: sender +To: recipient +Date: date +Subject: subject + +mailin comment + +On Jan 14, 2008 10:28 AM, Someone <someone@here> wrote: +> +> BLAH BLAH +""" + +DARCSMSG = """\ To: [email protected] From: [email protected] Subject: darcs patch: rename changes_rss to edits_rss @@ -350,7 +389,7 @@ def testMailinDarcsPatch(self): p = self.p p.subscribe(TESTSENDER) - mailin.mailin(p,TESTDARCSMSG) + mailin.mailin(p,DARCSMSG) self.assertEqual(1, p.commentCount()) self.assert_('rename changes_rss to edits_rss' in p.text()) # keeps a darcs patch part as well as first plain text part @@ -418,3 +457,8 @@ -- blah''') + def testStripBottomQuoted(self): + def linecount(s): return len(s.split('\n')) + # re bug.. should be 7 lines + self.assertEqual(linecount(mailin.stripBottomQuoted(BOTTOMQUOTEDMSG)),8) + #self.assertEqual(linecount(mailin.stripBottomQuoted(BOTTOMQUOTEDMSG2)),8) -- forwarded from http://zwiki.org/PatchDiscussion#[email protected]