From 1adf8b26cdecc94c236ad2e40966d6c89b36995b Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Thu, 5 Jul 2012 03:16:50 -0400 Subject: [PATCH] Some more fixes, mainly unicode-related. --- earwigbot/commands/editcount.py | 2 +- earwigbot/commands/langcode.py | 6 +++--- earwigbot/commands/trout.py | 2 +- earwigbot/irc/connection.py | 2 +- earwigbot/wiki/page.py | 6 +++--- earwigbot/wiki/user.py | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/earwigbot/commands/editcount.py b/earwigbot/commands/editcount.py index 288b656..856e982 100644 --- a/earwigbot/commands/editcount.py +++ b/earwigbot/commands/editcount.py @@ -48,7 +48,7 @@ class Editcount(Command): self.reply(data, msg.format(name)) return - safe = quote_plus(user.name) + safe = quote_plus(user.name.encode("utf8")) url = "http://toolserver.org/~tparis/pcount/index.php?name={0}&lang={1}&wiki={2}" fullurl = url.format(safe, site.lang, site.project) msg = "\x0302{0}\x0301 has {1} edits ({2})." diff --git a/earwigbot/commands/langcode.py b/earwigbot/commands/langcode.py index 7c13225..967d8df 100644 --- a/earwigbot/commands/langcode.py +++ b/earwigbot/commands/langcode.py @@ -43,12 +43,12 @@ class Langcode(Command): for site in matrix.itervalues(): if site["code"] == code: - name = site["name"] + name = site["name"].encode("utf8") if name != site["localname"]: - name += " ({0})".format(site["localname"]) + name += " ({0})".format(site["localname"].encode("utf8")) sites = ", ".join([s["url"] for s in site["site"]]) msg = "\x0302{0}\x0301 is {1} ({2})".format(code, name, sites) self.reply(data, msg) return - self.reply(data, "site \x0302{0}\x0301 not found.".format(code)) + self.reply(data, "language \x0302{0}\x0301 not found.".format(code)) diff --git a/earwigbot/commands/trout.py b/earwigbot/commands/trout.py index 6449d62..d4ab14e 100644 --- a/earwigbot/commands/trout.py +++ b/earwigbot/commands/trout.py @@ -42,7 +42,7 @@ class Trout(Command): target = " ".join(data.args) or data.nick normal = normalize("NFKD", target.decode("utf8")).lower() if normal in self.exceptions: - self.reply(data, self.exceptions["normal"]) + self.reply(data, self.exceptions[normal]) else: msg = "slaps {0} around a bit with a large {1}." self.action(data.chan, msg.format(target, animal)) diff --git a/earwigbot/irc/connection.py b/earwigbot/irc/connection.py index ed8e099..75d6399 100644 --- a/earwigbot/irc/connection.py +++ b/earwigbot/irc/connection.py @@ -156,7 +156,7 @@ class IRCConnection(object): def ping(self, target): """Ping another entity on the server.""" - msg = "PING {0} {0}".format(target) + msg = "PING {0}".format(target) self._send(msg) def pong(self, target): diff --git a/earwigbot/wiki/page.py b/earwigbot/wiki/page.py index 3ada7ec..d3b839d 100644 --- a/earwigbot/wiki/page.py +++ b/earwigbot/wiki/page.py @@ -149,7 +149,7 @@ class Page(CopyrightMixIn): contains "[") it will always be invalid, and cannot be edited. """ if self._exists == self.PAGE_INVALID: - e = "Page '{0}' is invalid.".format(self._title) + e = u"Page '{0}' is invalid.".format(self._title) raise exceptions.InvalidPageError(e) def _assert_existence(self): @@ -161,7 +161,7 @@ class Page(CopyrightMixIn): """ self._assert_validity() if self._exists == self.PAGE_MISSING: - e = "Page '{0}' does not exist.".format(self._title) + e = u"Page '{0}' does not exist.".format(self._title) raise exceptions.PageNotFoundError(e) def _load(self): @@ -581,7 +581,7 @@ class Page(CopyrightMixIn): """ if self._namespace < 0: ns = self._site.namespace_id_to_name(self._namespace) - e = "Pages in the {0} namespace can't have talk pages.".format(ns) + e = u"Pages in the {0} namespace can't have talk pages.".format(ns) raise exceptions.InvalidPageError(e) if self._is_talkpage: diff --git a/earwigbot/wiki/user.py b/earwigbot/wiki/user.py index 9256a52..9762824 100644 --- a/earwigbot/wiki/user.py +++ b/earwigbot/wiki/user.py @@ -96,7 +96,7 @@ class User(object): if not hasattr(self, attr): self._load_attributes() if not self._exists: - e = "User '{0}' does not exist.".format(self._name) + e = u"User '{0}' does not exist.".format(self._name) raise UserNotFoundError(e) return getattr(self, attr)