]> sipb.mit.edu Git - snippets/.git/blobdiff - TracZephyrPlugin/ZephyrPlugin.py
Remove sipbmp3-itunes.bak, now that /mit/snippets supports submodules.
[snippets/.git] / TracZephyrPlugin / ZephyrPlugin.py
index fe46914b486df5c0421e11671329332672f55ddf..45584ae80bda02ead02c4e558a8a877b46eb34c2 100644 (file)
@@ -1,6 +1,9 @@
+# -*- coding: utf-8 -*-
+
 from trac.core import *
 from trac.ticket import ITicketChangeListener
 import subprocess
+import re
 import textwrap
 import shlex
 
@@ -11,7 +14,7 @@ class ZephyrPlugin(Component):
         zclass = self.config.get('ZephyrPlugin', 'class')
         if zclass == '':
             return
-        command = shlex.split(self.config.get('ZephyrPlugin', 'command'))
+        command = shlex.split(self.config.get('ZephyrPlugin', 'command').encode('utf-8'))
         if not command:
             command = ['zwrite', '-q', '-l', '-d']
         p = subprocess.Popen(command +
@@ -23,6 +26,7 @@ class ZephyrPlugin(Component):
         p.wait()
 
     def format_text(self, text):
+        text = re.sub(re.compile('^(?:> .*\n)+', re.MULTILINE), u'> […]\n', text)
         lines = textwrap.fill(text).split('\n')
         if len(lines) > 5:
             lines = lines[:5] + [u'[…]']
@@ -35,7 +39,7 @@ class ZephyrPlugin(Component):
         self.zwrite(ticket.id, message)
     
     def ticket_changed(self, ticket, comment, author, old_values):
-        message = ''
+        message = "(%s)\n" % ticket['summary']
         for field in ticket.fields:
             name = field['name']
             if name not in old_values: