--- a/libpurple/purple-url-handler Mon Dec 21 21:51:27 2015 -0600
+++ b/libpurple/purple-url-handler Wed Dec 23 22:13:29 2015 -0600
@@ -1,19 +1,22 @@
+from __future__ import print_function
+ from urllib.parse import unquote_plus + from urllib import unquote_plus obj = bus.get_object("im.pidgin.purple.PurpleService",
"/im/pidgin/purple/PurpleObject")
-except dbus.DBusException, e:
+except dbus.DBusException as e: if e._dbus_error_name == "org.freedesktop.DBus.Error.ServiceUnknown":
- print "Error: no libpurple-powered client is running. Try starting Pidgin or Finch."
+ print("Error: no libpurple-powered client is running. Try starting Pidgin or Finch.") purple = dbus.Interface(obj, "im.pidgin.purple.PurpleInterface")
@@ -59,7 +62,7 @@
- print "No matching account found."
+ print("No matching account found.") def bring_account_online(account):
@@ -122,16 +125,16 @@
match = re.match(r"^aim:([^?]*)(\?(.*))", uri)
- print "Invalid aim URI: %s" % uri
+ print("Invalid aim URI: %s" % uri) - command = urllib.unquote_plus(match.group(1))
+ command = unquote_plus(match.group(1)) paramstring = match.group(3)
for param in paramstring.split("&"):
key, value = extendlist(param.split("=", 1), 2, "")
- params[key] = urllib.unquote_plus(value)
+ params[key] = unquote_plus(value) accountname = params.get("account", "")
screenname = params.get("screenname", "")
@@ -148,10 +151,10 @@
match = re.match(r"^gg:(.*)", uri)
- print "Invalid gg URI: %s" % uri
+ print("Invalid gg URI: %s" % uri) - screenname = urllib.unquote_plus(match.group(1))
+ screenname = unquote_plus(match.group(1)) account = findaccount(protocol)
goim(account, screenname)
@@ -159,16 +162,16 @@
match = re.match(r"^icq:([^?]*)(\?(.*))", uri)
- print "Invalid icq URI: %s" % uri
+ print("Invalid icq URI: %s" % uri) - command = urllib.unquote_plus(match.group(1))
+ command = unquote_plus(match.group(1)) paramstring = match.group(3)
for param in paramstring.split("&"):
key, value = extendlist(param.split("=", 1), 2, "")
- params[key] = urllib.unquote_plus(value)
+ params[key] = unquote_plus(value) accountname = params.get("account", "")
screenname = params.get("screenname", "")
@@ -185,10 +188,10 @@
match = re.match(r"^irc:(//([^/]*))?/?([^?]*)(\?(.*))?", uri)
- print "Invalid irc URI: %s" % uri
+ print("Invalid irc URI: %s" % uri) - server = urllib.unquote_plus(match.group(2) or "")
+ server = unquote_plus(match.group(2) or "") target = match.group(3) or ""
query = match.group(5) or ""
@@ -197,14 +200,14 @@
for modifier in target.split(",")[1:]:
modifiers[modifier] = True
- isnick = modifiers.has_key("isnick")
+ isnick = True if "isnick" in modifiers else False paramstring = match.group(5)
for param in paramstring.split("&"):
key, value = extendlist(param.split("=", 1), 2, "")
- params[key] = urllib.unquote_plus(value)
+ params[key] = unquote_plus(value) def correct_server(account):
username = cpurple.PurpleAccountGetUsername(account)
@@ -214,9 +217,9 @@
- goim(account, urllib.unquote_plus(target.split(",")[0]), params.get("msg"))
+ goim(account, unquote_plus(target.split(",")[0]), params.get("msg")) - channel = urllib.unquote_plus(target.split(",")[0])
+ channel = unquote_plus(target.split(",")[0]) gochat(account, {"server": server, "channel": channel, "password": params.get("key", "")}, params.get("msg"))
@@ -225,16 +228,16 @@
match = re.match(r"^msnim:([^?]*)(\?(.*))", uri)
- print "Invalid msnim URI: %s" % uri
+ print("Invalid msnim URI: %s" % uri) - command = urllib.unquote_plus(match.group(1))
+ command = unquote_plus(match.group(1)) paramstring = match.group(3)
for param in paramstring.split("&"):
key, value = extendlist(param.split("=", 1), 2, "")
- params[key] = urllib.unquote_plus(value)
+ params[key] = unquote_plus(value) screenname = params.get("contact", "")
account = findaccount(protocol)
@@ -248,10 +251,10 @@
match = re.match(r"^sip:(.*)", uri)
- print "Invalid sip URI: %s" % uri
+ print("Invalid sip URI: %s" % uri) - screenname = urllib.unquote_plus(match.group(1))
+ screenname = unquote_plus(match.group(1)) account = findaccount(protocol)
goim(account, screenname)
@@ -259,20 +262,20 @@
match = re.match(r"^xmpp:(//([^/?#]*)/?)?([^?#]*)(\?([^;#]*)(;([^#]*))?)?(#(.*))?", uri)
- print "Invalid xmpp URI: %s" % uri
+ print("Invalid xmpp URI: %s" % uri) - accountname = urllib.unquote_plus(tmp)
+ accountname = unquote_plus(tmp) - screenname = urllib.unquote_plus(match.group(3))
+ screenname = unquote_plus(match.group(3)) - command = urllib.unquote_plus(tmp)
+ command = unquote_plus(tmp) @@ -281,7 +284,7 @@
for param in paramstring.split(";"):
key, value = extendlist(param.split("=", 1), 2, "")
- params[key] = urllib.unquote_plus(value)
+ params[key] = unquote_plus(value) account = findaccount(protocol, accountname)
@@ -299,16 +302,16 @@
match = re.match(r"^gtalk:([^?]*)(\?(.*))", uri)
- print "Invalid gtalk URI: %s" % uri
+ print("Invalid gtalk URI: %s" % uri) - command = urllib.unquote_plus(match.group(1))
+ command = unquote_plus(match.group(1)) paramstring = match.group(3)
for param in paramstring.split("&"):
key, value = extendlist(param.split("=", 1), 2, "")
- params[key] = urllib.unquote_plus(value)
+ params[key] = unquote_plus(value) accountname = params.get("from_jid", "")
jid = params.get("jid", "")
@@ -324,17 +327,17 @@
match = re.match(r"^ymsgr:([^?]*)(\?([^&]*)(&(.*))?)", uri)
- print "Invalid ymsgr URI: %s" % uri
+ print("Invalid ymsgr URI: %s" % uri) - command = urllib.unquote_plus(match.group(1))
- screenname = urllib.unquote_plus(match.group(3))
+ command = unquote_plus(match.group(1)) + screenname = unquote_plus(match.group(3)) paramstring = match.group(5)
for param in paramstring.split("&"):
key, value = extendlist(param.split("=", 1), 2, "")
- params[key] = urllib.unquote_plus(value)
+ params[key] = unquote_plus(value) account = findaccount(protocol)
@@ -348,8 +351,8 @@
if len(argv) != 2 or argv[1] == "--help" or argv[1] == "-h":
- print "Usage: %s URI" % argv[0]
- print "Example: %s \"xmpp:romeo@montague.net?message\"" % argv[0]
+ print("Usage: %s URI" % argv[0]) + print("Example: %s \"xmpp:romeo@montague.net?message\"" % argv[0]) @@ -379,9 +382,9 @@
- print "Unknown protocol: %s" % type
- except dbus.DBusException, e:
- print "Error: %s" % (e.message)
+ print("Unknown protocol: %s" % type) + except dbus.DBusException as e: + print("Error: %s" % e.message) if __name__ == "__main__":