annotate sat_frontends/jp/cmd_bookmarks.py @ 3849:bc24ce903835

plugin XEP-0060: handle priority in `addManagedNode`: Priority lets order the callback list when an event is received. This is important in some use case, notably when a plugin needs to check the former item before it is deleted from cache or updated. rel 370
author Goffi <goffi@goffi.org>
date Thu, 14 Jul 2022 12:55:30 +0200
parents 04283582966f
children 524856bd7b19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
1 #!/usr/bin/env python3
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
3
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # jp: a SAT command line tool
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
6
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
11
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
16
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
19
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
20 from . import base
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from sat.core.i18n import _
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
22 from sat_frontends.jp.constants import Const as C
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
23
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
24 __commands__ = ["Bookmarks"]
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
25
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
26 STORAGE_LOCATIONS = ("local", "private", "pubsub")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
27 TYPES = ("muc", "url")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
28
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
29
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
30 class BookmarksCommon(base.CommandBase):
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
31 """Class used to group common options of bookmarks subcommands"""
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
32
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
33 def add_parser_options(self, location_default="all"):
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
34 self.parser.add_argument(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
35 "-l",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
36 "--location",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
37 type=str,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
38 choices=(location_default,) + STORAGE_LOCATIONS,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
39 default=location_default,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
40 help=_("storage location (default: %(default)s)"),
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
41 )
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
42 self.parser.add_argument(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
43 "-t",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
44 "--type",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
45 type=str,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
46 choices=TYPES,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
47 default=TYPES[0],
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
48 help=_("bookmarks type (default: %(default)s)"),
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
49 )
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
50
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
51
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
52 class BookmarksList(BookmarksCommon):
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
53 def __init__(self, host):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
54 super(BookmarksList, self).__init__(host, "list", help=_("list bookmarks"))
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
55
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
56 async def start(self):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
57 try:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
58 data = await self.host.bridge.bookmarksList(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
59 self.args.type, self.args.location, self.host.profile
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
60 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
61 except Exception as e:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
62 self.disp(f"can't get bookmarks list: {e}", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
63 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
64
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
65 mess = []
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
66 for location in STORAGE_LOCATIONS:
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
67 if not data[location]:
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
68 continue
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
69 loc_mess = []
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
70 loc_mess.append(f"{location}:")
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
71 book_mess = []
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
72 for book_link, book_data in list(data[location].items()):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
73 name = book_data.get("name")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
74 autojoin = book_data.get("autojoin", "false") == "true"
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
75 nick = book_data.get("nick")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
76 book_mess.append(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
77 "\t%s[%s%s]%s"
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
78 % (
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
79 (name + " ") if name else "",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
80 book_link,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
81 " (%s)" % nick if nick else "",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
82 " (*)" if autojoin else "",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
83 )
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
84 )
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
85 loc_mess.append("\n".join(book_mess))
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
86 mess.append("\n".join(loc_mess))
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
87
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
88 print("\n\n".join(mess))
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
89 self.host.quit()
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
90
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
91
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
92 class BookmarksRemove(BookmarksCommon):
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
93 def __init__(self, host):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
94 super(BookmarksRemove, self).__init__(host, "remove", help=_("remove a bookmark"))
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
95
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
96 def add_parser_options(self):
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
97 super(BookmarksRemove, self).add_parser_options()
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
98 self.parser.add_argument(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
99 "bookmark", help=_("jid (for muc bookmark) or url of to remove")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
100 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
101 self.parser.add_argument(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
102 "-f",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
103 "--force",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
104 action="store_true",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
105 help=_("delete bookmark without confirmation"),
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
106 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
107
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
108 async def start(self):
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
109 if not self.args.force:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
110 await self.host.confirmOrQuit(_("Are you sure to delete this bookmark?"))
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
111
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
112 try:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
113 await self.host.bridge.bookmarksRemove(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
114 self.args.type, self.args.bookmark, self.args.location, self.host.profile
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
115 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
116 except Exception as e:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
117 self.disp(_("can't delete bookmark: {e}").format(e=e), error=True)
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
118 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
119 else:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
120 self.disp(_("bookmark deleted"))
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
121 self.host.quit()
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
122
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
123
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
124 class BookmarksAdd(BookmarksCommon):
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
125 def __init__(self, host):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
126 super(BookmarksAdd, self).__init__(host, "add", help=_("add a bookmark"))
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
127
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
128 def add_parser_options(self):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
129 super(BookmarksAdd, self).add_parser_options(location_default="auto")
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
130 self.parser.add_argument(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
131 "bookmark", help=_("jid (for muc bookmark) or url of to remove")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
132 )
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
133 self.parser.add_argument("-n", "--name", help=_("bookmark name"))
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
134 muc_group = self.parser.add_argument_group(_("MUC specific options"))
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
135 muc_group.add_argument("-N", "--nick", help=_("nickname"))
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
136 muc_group.add_argument(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
137 "-a",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
138 "--autojoin",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
139 action="store_true",
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
140 help=_("join room on profile connection"),
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
141 )
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
142
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
143 async def start(self):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
144 if self.args.type == "url" and (self.args.autojoin or self.args.nick is not None):
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
145 self.parser.error(_("You can't use --autojoin or --nick with --type url"))
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
146 data = {}
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
147 if self.args.autojoin:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
148 data["autojoin"] = "true"
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
149 if self.args.nick is not None:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
150 data["nick"] = self.args.nick
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
151 if self.args.name is not None:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
152 data["name"] = self.args.name
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
153 try:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
154 await self.host.bridge.bookmarksAdd(
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
155 self.args.type,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
156 self.args.bookmark,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
157 data,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
158 self.args.location,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
159 self.host.profile,
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
160 )
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
161 except Exception as e:
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
162 self.disp(f"can't add bookmark: {e}", error=True)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
163 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
164 else:
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
165 self.disp(_("bookmark successfully added"))
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
166 self.host.quit()
986
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
167
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
168
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
169 class Bookmarks(base.CommandBase):
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
170 subcommands = (BookmarksList, BookmarksRemove, BookmarksAdd)
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
171
224cafc67324 jp: added bookmarks subcommands
Goffi <goffi@goffi.org>
parents:
diff changeset
172 def __init__(self, host):
3568
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
173 super(Bookmarks, self).__init__(
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
174 host, "bookmarks", use_profile=False, help=_("manage bookmarks")
04283582966f core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
175 )