From: Anders Kaseorg Date: Tue, 30 Jun 2009 21:47:37 +0000 (-0400) Subject: Display 5 lines instead of 255 chars, and truncate with […]. X-Git-Url: https://snippets.scripts.mit.edu/gitweb.cgi/Scripts/git/.git/commitdiff_plain/08cf6d42387038e822e2b3d55c815f9a2f0ee52b Display 5 lines instead of 255 chars, and truncate with […]. Signed-off-by: Anders Kaseorg --- 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):