From 2dd3007b8502a4fdb93228850d147b93cf8cb97d Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Tue, 15 Feb 2011 23:15:26 +0100 Subject: Do str.encode() when calling irc.msg(). --- gitnoti.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'gitnoti.py') diff --git a/gitnoti.py b/gitnoti.py index da7b11c..8114741 100755 --- a/gitnoti.py +++ b/gitnoti.py @@ -88,9 +88,9 @@ def repo_commit_msg(repo, branch, commits): reponame, ('/'+branch) if branch else '', commit.hexsha[:7], - commit.committer.name if commit.author.name.encode('utf8', 'replace') == commit.committer.name else '%s/%s' % (commit.committer.name, commit.author.name.encode('utf8', 'replace')), + commit.committer.name if commit.author.name == commit.committer.name else '%s/%s' % (commit.committer.name, commit.author.name), stat, - commit.summary.encode('utf8', 'replace') + commit.summary ) if options.url: @@ -106,7 +106,7 @@ def repo_commit_msg(repo, branch, commits): short_url = None if short_url: - url = short_url.encode('utf-8', 'replace') + url = short_url msg += url return msg @@ -326,7 +326,7 @@ class Bot(irc.IRCClient): return msg = repo_commit_msg(repo, branch, commits) - self.msg(target, msg) + self.msg(target, msg.encode('utf-8')) elif cmd == 'branches': if not len(messagelist) == 3: self.msg(target, 'Usage: %s branches REPO' % self.nickname) @@ -337,7 +337,8 @@ class Bot(irc.IRCClient): return reponame = os.path.splitext(os.path.basename(repo.working_dir))[0] - self.msg(target, '\002%s\002 has branches %s' % (reponame, ', '.join(sorted(['\002%s\002' % h.name for h in repo.heads])))) + msg = '\002%s\002 has branches %s' % (reponame, ', '.join(['\002%s\002' % h.name for h in repo.heads])) + self.msg(target, msg.encode('utf-8')) elif cmd == 'tags': if not len(messagelist) == 3: self.msg(target, 'Usage: %s tags REPO' % self.nickname) @@ -349,9 +350,10 @@ class Bot(irc.IRCClient): reponame = os.path.splitext(os.path.basename(repo.working_dir))[0] if not len(repo.tags): - self.msg(target, '\002%s\002 has no tags.' % reponame) + msg = '\002%s\002 has no tags.' % reponame else: - self.msg(target, '\002%s\002 has tags %s' % (reponame, ', '.join(sorted(['\002%s\002' % t.name for t in repo.tags])))) + msg = '\002%s\002 has tags %s' % (reponame, ', '.join(['\002%s\002' % t.name for t in repo.tags])) + self.msg(target, msg.encode('utf-8')) class BotFactory(protocol.ReconnectingClientFactory): protocol = Bot -- cgit v1.2.3