def convert_command(self, command): """ Convert old command to new format. """ if command.startswith(BookmarksCommands.PROTOCOL_SCRIPT): # check ShellCommands return self.convert_macro(command) elif command.startswith(BookmarksCommands.PROTOCOL_MACRO): return command elif command.startswith(".uno"): if command.startswith(".uno:Open"): parts = command.split("?", 1) if len(parts) == 2: queries = [i.split("=") for i in parts[1].split("&")] d = {} d["type"] = "document" for key, value in queries: if key == self.commands.QUERY_NAME_URL: d["path"] = value return self.commands.generate_command(d) elif command.find("?") >= 0: parts = command.split("?", 1) if len(parts) == 2: queries = [i.split("=") for i in parts[1].split("&")] q = bk_urlencode(dict(queries)) return parts[0] + q return command
def bk_urlencode(qs): return bk_urlencode(qs)