From 1251b42e50e35ec9a785f66fbc77e06fae0e9a85 Mon Sep 17 00:00:00 2001 From: Neil Date: Sun, 11 Nov 2012 12:32:48 +0200 Subject: [PATCH 1/1] Add template and colour info --- irkerhook.py | 65 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 59 insertions(+), 6 deletions(-) diff --git a/irkerhook.py b/irkerhook.py index 208c0d8..99a9d39 100644 --- a/irkerhook.py +++ b/irkerhook.py @@ -37,14 +37,21 @@ class IrkerSender(object): def _format(self): fields = { + 'project': self.project(), 'committer': self.revision.committer, - 'message': self.revision.get_summary(), - 'revision': '%d' % self.revno, - 'url': self.url() + 'repo': '', + 'rev': '%d' % self.revno, + 'files': '', + 'logmsg': self.revision.get_summary(), + 'url': self.url(), } - text = '' - #for name, value in fields.items(): - # text = text.replace('$%s' % name, value) + for name, value in self.colours(): + fields[name] = value + text = ('%(bold)s%(project)s:%(reset)s ' + '%(green)s%(committer)s%(reset)s ' + '%(repo)s * %(bold)s%(rev)s%(reset)s / ' + ' %(bold)s%(files)s%(reset)s: %(logmsg)s ' + '%(brown)s%(url)s%(reset)s' % fields) return text def body(self): @@ -94,6 +101,52 @@ class IrkerSender(object): url = self.branch.base return url + def colours(self): + colour_style = self.config.get('irker_colors') + colours = { + 'bold': '', + 'green': '', + 'blue': '', + 'red': '', + 'yellow': '', + 'brown': '', + 'magenta': '', + 'cyan': '', + 'reset': '', + } + # Vaues taken from irker's irkerhook.py + if colour_style == 'ANSI': + colours = { + 'bold': '\x1b[1m' + 'green': '\x1b[1;32m' + 'blue': '\x1b[1;34m' + 'red': '\x1b[1;31m' + 'yellow': '\x1b[1;33m' + 'brown': '\x1b[33m' + 'magenta': '\x1b[35m' + 'cyan': '\x1b[36m' + 'reset': '\x1b[0m' + } + elif colour_style == 'mIRC': + colours = { + 'bold': '\x02' + 'green': '\x0303' + 'blue': '\x0302' + 'red': '\x0305' + 'yellow': '\x0307' + 'brown': '\x0305' + 'magenta': '\x0306' + 'cyan': '\x0310' + 'reset': '\x0F' + } + return colours + + def project(self): + projet = self.config.get('irker_project') + if project is None: + project = 'No Project name set' + return project + def send(self): """Send the info to irkerd. """ -- 2.34.1