From: Anders Kaseorg Date: Fri, 18 Dec 2009 00:52:01 +0000 (-0500) Subject: TracZephyrPlugin: Smarter quoted text regex. X-Git-Url: https://snippets.scripts.mit.edu/gitweb.cgi/Scripts/git/.git/commitdiff_plain/99f25bfd883c4fabc145618937662b6abecf321d TracZephyrPlugin: Smarter quoted text regex. Some mail clients quote an empty line as ‘>’ instead of ‘> ’. Also check that at least one of the quoted lines is nonempty. Signed-off-by: Anders Kaseorg --- diff --git a/TracZephyrPlugin/ZephyrPlugin.py b/TracZephyrPlugin/ZephyrPlugin.py index 45584ae..679d019 100644 --- a/TracZephyrPlugin/ZephyrPlugin.py +++ b/TracZephyrPlugin/ZephyrPlugin.py @@ -7,6 +7,8 @@ import re import textwrap import shlex +quoted_re = re.compile('^(?:> ?\n)*> .+\n(?:>(?: .*)?\n)*', re.MULTILINE) + class ZephyrPlugin(Component): implements(ITicketChangeListener) @@ -26,7 +28,7 @@ class ZephyrPlugin(Component): p.wait() def format_text(self, text): - text = re.sub(re.compile('^(?:> .*\n)+', re.MULTILINE), u'> […]\n', text) + text = re.sub(quoted_re, u'> […]\n', text) lines = textwrap.fill(text).split('\n') if len(lines) > 5: lines = lines[:5] + [u'[…]']