diff -up gwibber-867bzr/gwibber/microblog/dispatcher.py.kitchen gwibber-867bzr/gwibber/microblog/dispatcher.py --- gwibber-867bzr/gwibber/microblog/dispatcher.py.kitchen 2010-09-24 10:02:19.271184999 -0400 +++ gwibber-867bzr/gwibber/microblog/dispatcher.py 2010-09-24 10:02:19.281184999 -0400 @@ -8,6 +8,7 @@ import qaiku, friendfeed, digg, buzz, pi import foursquare, gowalla import sqlite3, mx.DateTime, re, uuid import urlshorter, storage, network, util, config +from kitchen.text.converters import to_unicode from util import log from util import resources @@ -86,9 +87,9 @@ def perform_operation((account, opname, if message_data is not None: for m in message_data: if "mid" in m: - m["id"] = uuid.uuid1().hex - m["operation"] = opname - m["stream"] = stream + m["id"] = to_unicode(uuid.uuid1().hex) + m["operation"] = to_unicode(opname) + m["stream"] = to_unicode(stream) m["transient"] = transient m["rtl"] = util.isRTL(re.sub(text_cleaner, "", m["text"].decode('utf-8'))) diff -up gwibber-867bzr/gwibber/microblog/gowalla.py.kitchen gwibber-867bzr/gwibber/microblog/gowalla.py --- gwibber-867bzr/gwibber/microblog/gowalla.py.kitchen 2010-09-24 10:06:11.229185000 -0400 +++ gwibber-867bzr/gwibber/microblog/gowalla.py 2010-09-24 10:11:18.173185001 -0400 @@ -26,6 +26,7 @@ import network, json, util, htmllib, re from util import log from util import exceptions from gettext import lgettext as _ +from kitchen.text.converters import to_unicode log.logger.name = "Gowalla" PROTOCOL_INFO = { @@ -60,47 +61,47 @@ class Client: def _message(self, data): m = {}; - m["mid"] = str(data["user"]["first_name"]) + str(data["user"]["last_name"]) - m["service"] = "gowalla" + m["mid"] = to_unicode(str(data["user"]["first_name"]) + str(data["user"]["last_name"])) + m["service"] = u"gowalla" m["account"] = self.account["id"] m["time"] = util.parsetime(data["created_at"]) - messagetext = "" - text = "" + messagetext = u"" + text = u"" if data.has_key("spot"): if data.has_key("message"): messagetext += data["message"] + "

" text += data["message"] + "\n" - m["url"] = "" % data["spot"]["url"] - m["url"] = "http://gowalla.com%s" % data["spot"]["url"] - img = "
" % data["spot"]["image_url"] + m["url"] = to_unicode("" % data["spot"]["url"]) + m["url"] = to_unicode("http://gowalla.com%s" % data["spot"]["url"]) + img = to_unicode("
" % data["spot"]["image_url"]) messagetext += img + "Checked in at " + data["spot"]["name"] + "" text += "Checked in at " + data["spot"]["name"] else: if data.has_key("message"): - messagetext += data["message"] + "

" - text += data["message"] + "\n" + messagetext += to_unicode(data["message"] + "

") + text += to_unicode(data["message"] + "\n") else: - text= "Checked in off the grid" - shouttext= "
Checked in off the grid" + text= u"Checked in off the grid" + shouttext= u"
Checked in off the grid" m["text"] = text - m["content"] = messagetext + "
" - m["html"] = messagetext + "
" + m["content"] = to_unicode(messagetext + "
") + m["html"] = to_unicode(messagetext + "
") m["sender"] = {} - m["sender"]["image"] = data["user"]["image_url"] - m["sender"]["url"] = "http://gowalla.com%s" % data["user"]["url"] - fullname = "" + m["sender"]["image"] = to_unicode(data["user"]["image_url"]) + m["sender"]["url"] = to_unicode("http://gowalla.com%s" % data["user"]["url"]) + fullname = u"" if data["user"].has_key("first_name"): - fullname += data["user"]["first_name"] + " " + fullname += data["user"]["first_name"] + u" " if data["user"].has_key("last_name"): fullname += data["user"]["last_name"] m["sender"]["name"] = fullname m["sender"]["nick"] = fullname - m["source"] = "
Gowalla" + m["source"] = u"Gowalla" return m diff -up gwibber-867bzr/gwibber/microblog/identica.py.kitchen gwibber-867bzr/gwibber/microblog/identica.py --- gwibber-867bzr/gwibber/microblog/identica.py.kitchen 2010-09-23 09:42:12.000000000 -0400 +++ gwibber-867bzr/gwibber/microblog/identica.py 2010-09-24 10:02:19.282184999 -0400 @@ -2,6 +2,7 @@ import re, network, util from util import log from util import exceptions from gettext import lgettext as _ +from kitchen.text.converters import to_unicode log.logger.name = "Identi.ca" PROTOCOL_INFO = { @@ -53,28 +54,28 @@ class Client: def _common(self, data): m = {} try: - m["mid"] = str(data["id"]) - m["service"] = "identica" + m["mid"] = to_unicode(str(data["id"])) + m["service"] = u"identica" m["account"] = self.account["id"] m["time"] = util.parsetime(data["created_at"]) - m["source"] = data.get("source", False) - m["text"] = data["text"] + m["source"] = to_unicode(data.get("source", False)) + m["text"] = to_unicode(data["text"]) m["to_me"] = ("@%s" % self.account["username"]) in data["text"] - m["html"] = util.linkify(m["text"], + m["html"] = to_unicode(util.linkify(m["text"], ((util.PARSE_HASH, '#\\1' % URL_PREFIX), - (util.PARSE_NICK, '@\\1' % URL_PREFIX))) + (util.PARSE_NICK, '@\\1' % URL_PREFIX)))) - m["content"] = util.linkify(m["text"], + m["content"] = to_unicode(util.linkify(m["text"], ((util.PARSE_HASH, '#\\1' % m["account"]), - (util.PARSE_NICK, '@\\1' % m["account"]))) + (util.PARSE_NICK, '@\\1' % m["account"])))) images = [] if data.get("attachments", 0): for a in data["attachments"]: mime = a.get("mimetype", "") if mime and mime.startswith("image") and a.get("url", 0): - images.append({"src": a["url"], "url": a["url"]}) + images.append({"src": to_unicode(a["url"]), "url": to_unicode(a["url"])}) images.extend(util.imgpreview(m["text"])) @@ -91,33 +92,33 @@ class Client: if data.get("in_reply_to_status_id", 0) and data.get("in_reply_to_screen_name", 0): m["reply"] = {} m["reply"]["id"] = data["in_reply_to_status_id"] - m["reply"]["nick"] = data["in_reply_to_screen_name"] - m["reply"]["url"] = "/".join((URL_PREFIX, "notice", str(m["reply"]["id"]))) + m["reply"]["nick"] = to_unicode(data["in_reply_to_screen_name"]) + m["reply"]["url"] = to_unicode("/".join((URL_PREFIX, "notice", str(m["reply"]["id"])))) user = data.get("user", data.get("sender", 0)) m["sender"] = {} - m["sender"]["name"] = user["name"] - m["sender"]["nick"] = user["screen_name"] + m["sender"]["name"] = to_unicode(user["name"]) + m["sender"]["nick"] = to_unicode(user["screen_name"]) m["sender"]["id"] = user["id"] - m["sender"]["location"] = user["location"] + m["sender"]["location"] = to_unicode(user["location"]) m["sender"]["followers"] = user["followers_count"] - m["sender"]["image"] = user["profile_image_url"] - m["sender"]["url"] = "/".join((URL_PREFIX, m["sender"]["nick"])) + m["sender"]["image"] = to_unicode(user["profile_image_url"]) + m["sender"]["url"] = to_unicode("/".join((URL_PREFIX, m["sender"]["nick"]))) m["sender"]["is_me"] = m["sender"]["nick"] == self.account["username"] - m["url"] = "/".join((URL_PREFIX, "notice", m["mid"])) + m["url"] = to_unicode("/".join((URL_PREFIX, "notice", m["mid"]))) return m def _private(self, data): m = self._message(data) m["private"] = True m["recipient"] = {} - m["recipient"]["name"] = data["recipient"]["name"] - m["recipient"]["nick"] = data["recipient"]["screen_name"] + m["recipient"]["name"] = to_unicode(data["recipient"]["name"]) + m["recipient"]["nick"] = to_unicode(data["recipient"]["screen_name"]) m["recipient"]["id"] = data["recipient"]["id"] - m["recipient"]["image"] = data["recipient"]["profile_image_url"] - m["recipient"]["location"] = data["recipient"]["location"] - m["recipient"]["url"] = "/".join((URL_PREFIX, m["recipient"]["nick"])) + m["recipient"]["image"] = to_unicode(data["recipient"]["profile_image_url"]) + m["recipient"]["location"] = to_unicode(data["recipient"]["location"]) + m["recipient"]["url"] = to_unicode("/".join((URL_PREFIX, m["recipient"]["nick"]))) m["recipient"]["is_me"] = m["recipient"]["nick"].lower() == self.account["username"].lower() return m @@ -127,14 +128,14 @@ class Client: if data["to_user_id"]: m["reply"] = {} m["reply"]["id"] = data["to_user_id"] - m["reply"]["nick"] = data["to_user"] + m["reply"]["nick"] = to_unicode(data["to_user"]) m["sender"] = {} - m["sender"]["nick"] = data["from_user"] + m["sender"]["nick"] = to_unicode(data["from_user"]) m["sender"]["id"] = data["from_user_id"] - m["sender"]["image"] = data["profile_image_url"] - m["sender"]["url"] = "/".join((URL_PREFIX, m["sender"]["nick"])) - m["url"] = "/".join((URL_PREFIX, "notice", str(m["mid"]))) + m["sender"]["image"] = to_unicode(data["profile_image_url"]) + m["sender"]["url"] = to_unicode("/".join((URL_PREFIX, m["sender"]["nick"]))) + m["url"] = to_unicode("/".join((URL_PREFIX, "notice", str(m["mid"])))) return m def _get(self, path, parse="message", post=False, single=False, **args): diff -up gwibber-867bzr/gwibber/microblog/twitter.py.kitchen gwibber-867bzr/gwibber/microblog/twitter.py --- gwibber-867bzr/gwibber/microblog/twitter.py.kitchen 2010-09-23 09:42:12.000000000 -0400 +++ gwibber-867bzr/gwibber/microblog/twitter.py 2010-09-24 10:02:19.284184999 -0400 @@ -3,6 +3,7 @@ import gnomekeyring from oauth import oauth from util import log, exceptions from gettext import lgettext as _ +from kitchen.text.converters import to_unicode log.logger.name = "Twitter" PROTOCOL_INFO = { @@ -72,19 +73,19 @@ class Client: m = {}; try: m["mid"] = str(data["id"]) - m["service"] = "twitter" + m["service"] = u"twitter" m["account"] = self.account["id"] m["time"] = util.parsetime(data["created_at"]) - m["text"] = unescape(data["text"]) + m["text"] = to_unicode(unescape(data["text"])) m["to_me"] = ("@%s" % self.account["username"]) in data["text"] - m["html"] = util.linkify(data["text"], + m["html"] = to_unicode(util.linkify(data["text"], ((util.PARSE_HASH, '#\\1' % URL_PREFIX), - (util.PARSE_NICK, '@\\1' % URL_PREFIX)), escape=False) + (util.PARSE_NICK, '@\\1' % URL_PREFIX)), escape=False)) - m["content"] = util.linkify(data["text"], + m["content"] = to_unicode(util.linkify(data["text"], ((util.PARSE_HASH, '#\\1' % m["account"]), - (util.PARSE_NICK, '@\\1' % m["account"])), escape=False) + (util.PARSE_NICK, '@\\1' % m["account"])), escape=False)) images = util.imgpreview(m["text"]) if images: @@ -96,13 +97,13 @@ class Client: def _user(self, user): return { - "name": user["name"], - "nick": user["screen_name"], + "name": to_unicode(user["name"]), + "nick": to_unicode(user["screen_name"]), "id": user["id"], - "location": user["location"], + "location": to_unicode(user["location"]), "followers": user.get("followers", None), - "image": user["profile_image_url"], - "url": "/".join((URL_PREFIX, user["screen_name"])), + "image": to_unicode(user["profile_image_url"]), + "url": to_unicode("/".join((URL_PREFIX, user["screen_name"]))), "is_me": user["screen_name"] == self.account["username"], } @@ -116,11 +117,11 @@ class Client: if "in_reply_to_status_id" in data and data["in_reply_to_status_id"]: m["reply"] = {} m["reply"]["id"] = data["in_reply_to_status_id"] - m["reply"]["nick"] = data["in_reply_to_screen_name"] - m["reply"]["url"] = "/".join((URL_PREFIX, m["reply"]["nick"], "statuses", str(m["reply"]["id"]))) + m["reply"]["nick"] = to_unicode(data["in_reply_to_screen_name"]) + m["reply"]["url"] = to_unicode("/".join((URL_PREFIX, m["reply"]["nick"], "statuses", str(m["reply"]["id"])))) m["sender"] = self._user(data["user"] if "user" in data else data["sender"]) - m["url"] = "/".join((m["sender"]["url"], "statuses", str(m["mid"]))) + m["url"] = to_unicode("/".join((m["sender"]["url"], "statuses", str(m["mid"])))) return m @@ -129,12 +130,12 @@ class Client: m["private"] = True m["recipient"] = {} - m["recipient"]["name"] = data["recipient"]["name"] - m["recipient"]["nick"] = data["recipient"]["screen_name"] + m["recipient"]["name"] = to_unicode(data["recipient"]["name"]) + m["recipient"]["nick"] = to_unicode(data["recipient"]["screen_name"]) m["recipient"]["id"] = data["recipient"]["id"] - m["recipient"]["image"] = data["recipient"]["profile_image_url"] - m["recipient"]["location"] = data["recipient"]["location"] - m["recipient"]["url"] = "/".join((URL_PREFIX, m["recipient"]["nick"])) + m["recipient"]["image"] = to_unicode(data["recipient"]["profile_image_url"]) + m["recipient"]["location"] = to_unicode(data["recipient"]["location"]) + m["recipient"]["url"] = to_unicode("/".join((URL_PREFIX, m["recipient"]["nick"]))) m["recipient"]["is_me"] = m["recipient"]["nick"] == self.account["username"] return m @@ -145,37 +146,37 @@ class Client: if data["to_user_id"]: m["reply"] = {} m["reply"]["id"] = data["to_user_id"] - m["reply"]["nick"] = data["to_user"] + m["reply"]["nick"] = to_unicode(data["to_user"]) m["sender"] = {} - m["sender"]["nick"] = data["from_user"] + m["sender"]["nick"] = to_unicode(data["from_user"]) m["sender"]["id"] = data["from_user_id"] - m["sender"]["image"] = data["profile_image_url"] - m["sender"]["url"] = "/".join((URL_PREFIX, m["sender"]["nick"])) + m["sender"]["image"] = to_unicode(data["profile_image_url"]) + m["sender"]["url"] = to_unicode("/".join((URL_PREFIX, m["sender"]["nick"]))) m["sender"]["is_me"] = m["sender"]["nick"] == self.account["username"] - m["url"] = "/".join((m["sender"]["url"], "statuses", str(m["mid"]))) + m["url"] = to_unicode("/".join((m["sender"]["url"], "statuses", str(m["mid"])))) return m def _list(self, data): return { "mid": data["id"], - "service": "twitter", + "service": u"twitter", "account": self.account["id"], "time": 0, - "text": data["description"], - "html": data["description"], - "content": data["description"], - "url": "/".join((URL_PREFIX, data["uri"])), - "sender": self._user(data["user"]), - "name": data["name"], - "nick": data["slug"], + "text": to_unicode(data["description"]), + "html": to_unicode(data["description"]), + "content": to_unicode(data["description"]), + "url": to_unicode("/".join((URL_PREFIX, data["uri"]))), + "sender": to_unicode(self._user(data["user"])), + "name": to_unicode(data["name"]), + "nick": to_unicode(data["slug"]), "key": data["slug"], - "full": data["full_name"], - "uri": data["uri"], + "full": to_unicode(data["full_name"]), + "uri": to_unicode(data["uri"]), "mode": data["mode"], "members": data["member_count"], "followers": data["subscriber_count"], - "kind": "list", + "kind": u"list", } def _get(self, path, parse="message", post=False, single=False, **args):