From 08cf6d42387038e822e2b3d55c815f9a2f0ee52b Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 30 Jun 2009 17:47:37 -0400 Subject: [PATCH] =?utf8?q?Display=205=20lines=20instead=20of=20255=20chars?= =?utf8?q?,=20and=20truncate=20with=20[=E2=80=A6].?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders Kaseorg --- TracZephyrPlugin/ZephyrPlugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/TracZephyrPlugin/ZephyrPlugin.py b/TracZephyrPlugin/ZephyrPlugin.py index 0f40125..88fc2e1 100644 --- a/TracZephyrPlugin/ZephyrPlugin.py +++ b/TracZephyrPlugin/ZephyrPlugin.py @@ -21,11 +21,17 @@ class ZephyrPlugin(Component): p.stdin.write(message.replace('@', '@@').encode('utf-8', 'replace')) p.stdin.close() p.wait() + + def format_text(self, text): + lines = textwrap.fill(text).split('\n') + if len(lines) > 5: + lines = lines[:5] + [u'[…]'] + return '\n'.join(lines) def ticket_created(self, ticket): message = "%s filed a new ticket:\n%s\n\n%s" % (ticket['reporter'], ticket['summary'], - textwrap.fill(ticket['description'][:255])) + self.format_text(ticket['description'])) self.zwrite(ticket.id, message) def ticket_changed(self, ticket, comment, author, old_values): -- 2.45.0