Mercurial > libervia-backend
comparison frontends/src/jp/cmd_bookmarks.py @ 1864:96ba685162f6
jp: all commands now use the new start method and set need_loop in __init__ when needed
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 29 Feb 2016 16:52:51 +0100 |
parents | d17772b0fe22 |
children | 3e168cde7a7d |
comparison
equal
deleted
inserted
replaced
1863:b2ddd7f5dcdf | 1864:96ba685162f6 |
---|---|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 # GNU Affero General Public License for more details. | 15 # GNU Affero General Public License for more details. |
16 | 16 |
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | |
20 from logging import debug, info, error, warning | |
21 | 19 |
22 import base | 20 import base |
23 from sat.core.i18n import _ | 21 from sat.core.i18n import _ |
24 | 22 |
25 __commands__ = ["Bookmarks"] | 23 __commands__ = ["Bookmarks"] |
41 class BookmarksList(BookmarksCommon): | 39 class BookmarksList(BookmarksCommon): |
42 | 40 |
43 def __init__(self, host): | 41 def __init__(self, host): |
44 super(BookmarksList, self).__init__(host, 'list', help=_('list bookmarks')) | 42 super(BookmarksList, self).__init__(host, 'list', help=_('list bookmarks')) |
45 | 43 |
46 def connected(self): | 44 def start(self): |
47 super(BookmarksList, self).connected() | |
48 data = self.host.bridge.bookmarksList(self.args.type, self.args.location, self.host.profile) | 45 data = self.host.bridge.bookmarksList(self.args.type, self.args.location, self.host.profile) |
49 mess = [] | 46 mess = [] |
50 for location in STORAGE_LOCATIONS: | 47 for location in STORAGE_LOCATIONS: |
51 if not data[location]: | 48 if not data[location]: |
52 continue | 49 continue |
66 | 63 |
67 print u'\n\n'.join(mess) | 64 print u'\n\n'.join(mess) |
68 | 65 |
69 | 66 |
70 class BookmarksRemove(BookmarksCommon): | 67 class BookmarksRemove(BookmarksCommon): |
71 need_loop = True | |
72 | 68 |
73 def __init__(self, host): | 69 def __init__(self, host): |
74 super(BookmarksRemove, self).__init__(host, 'remove', help=_('remove a bookmark')) | 70 super(BookmarksRemove, self).__init__(host, 'remove', help=_('remove a bookmark')) |
71 self.need_loop = True | |
75 | 72 |
76 def add_parser_options(self): | 73 def add_parser_options(self): |
77 super(BookmarksRemove, self).add_parser_options() | 74 super(BookmarksRemove, self).add_parser_options() |
78 self.parser.add_argument('bookmark', type=base.unicode_decoder, help=_('jid (for muc bookmark) or url of to remove')) | 75 self.parser.add_argument('bookmark', type=base.unicode_decoder, help=_('jid (for muc bookmark) or url of to remove')) |
79 | 76 |
80 def connected(self): | 77 def start(self): |
81 super(BookmarksRemove, self).connected() | |
82 self.host.bridge.bookmarksRemove(self.args.type, self.args.bookmark, self.args.location, self.host.profile, callback = lambda: self.host.quit(), errback=self._errback) | 78 self.host.bridge.bookmarksRemove(self.args.type, self.args.bookmark, self.args.location, self.host.profile, callback = lambda: self.host.quit(), errback=self._errback) |
83 | 79 |
84 | 80 |
85 class BookmarksAdd(BookmarksCommon): | 81 class BookmarksAdd(BookmarksCommon): |
86 | 82 |
87 def __init__(self, host): | 83 def __init__(self, host): |
88 super(BookmarksAdd, self).__init__(host, 'add', help=_('add a bookmark')) | 84 super(BookmarksAdd, self).__init__(host, 'add', help=_('add a bookmark')) |
85 self.need_loop = True | |
89 | 86 |
90 def add_parser_options(self): | 87 def add_parser_options(self): |
91 super(BookmarksAdd, self).add_parser_options(location_default='auto') | 88 super(BookmarksAdd, self).add_parser_options(location_default='auto') |
92 self.parser.add_argument('bookmark', type=base.unicode_decoder, help=_('jid (for muc bookmark) or url of to remove')) | 89 self.parser.add_argument('bookmark', type=base.unicode_decoder, help=_('jid (for muc bookmark) or url of to remove')) |
93 self.parser.add_argument('-n', '--name', type=base.unicode_decoder, help=_("bookmark name")) | 90 self.parser.add_argument('-n', '--name', type=base.unicode_decoder, help=_("bookmark name")) |
94 muc_group = self.parser.add_argument_group(_('MUC specific options')) | 91 muc_group = self.parser.add_argument_group(_('MUC specific options')) |
95 muc_group.add_argument('-N', '--nick', type=base.unicode_decoder, help=_('nickname')) | 92 muc_group.add_argument('-N', '--nick', type=base.unicode_decoder, help=_('nickname')) |
96 muc_group.add_argument('-a', '--autojoin', action='store_true', help=_('join room on profile connection')) | 93 muc_group.add_argument('-a', '--autojoin', action='store_true', help=_('join room on profile connection')) |
97 | 94 |
98 def connected(self): | 95 def start(self): |
99 self.need_loop = True | |
100 super(BookmarksAdd, self).connected() | |
101 if self.args.type == 'url' and (self.args.autojoin or self.args.nick is not None): | 96 if self.args.type == 'url' and (self.args.autojoin or self.args.nick is not None): |
102 # XXX: Argparse doesn't seem to manage this case, any better way ? | 97 # XXX: Argparse doesn't seem to manage this case, any better way ? |
103 print _(u"You can't use --autojoin or --nick with --type url") | 98 print _(u"You can't use --autojoin or --nick with --type url") |
104 self.host.quit(1) | 99 self.host.quit(1) |
105 data = {} | 100 data = {} |