comparison sat_frontends/jp/base.py @ 3586:5f65f4e9f8cb

plugin XEP-0060: getItems extra is now serialised dict
author Goffi <goffi@goffi.org>
date Wed, 28 Jul 2021 23:01:15 +0200
parents 04283582966f
children 1709f0a78f50
comparison
equal deleted inserted replaced
3585:31628770a15a 3586:5f65f4e9f8cb
39 from sat.tools import config 39 from sat.tools import config
40 from sat.tools.common import dynamic_import 40 from sat.tools.common import dynamic_import
41 from sat.tools.common import uri 41 from sat.tools.common import uri
42 from sat.tools.common import date_utils 42 from sat.tools.common import date_utils
43 from sat.tools.common import utils 43 from sat.tools.common import utils
44 from sat.tools.common import data_format
44 from sat.tools.common.ansi import ANSI as A 45 from sat.tools.common.ansi import ANSI as A
45 from sat.core import exceptions 46 from sat.core import exceptions
46 import sat_frontends.jp 47 import sat_frontends.jp
47 from sat_frontends.jp.loops import QuitException, getJPLoop 48 from sat_frontends.jp.loops import QuitException, getJPLoop
48 from sat_frontends.jp.constants import Const as C 49 from sat_frontends.jp.constants import Const as C
1187 except AttributeError: 1188 except AttributeError:
1188 raise exceptions.InternalError( 1189 raise exceptions.InternalError(
1189 _('trying to use output when use_output has not been set')) 1190 _('trying to use output when use_output has not been set'))
1190 return self.host.output(output_type, self.args.output, self.extra_outputs, data) 1191 return self.host.output(output_type, self.args.output, self.extra_outputs, data)
1191 1192
1192 def getPubsubExtra(self, extra=None): 1193 def getPubsubExtra(self, extra: Optional[dict] = None) -> str:
1193 """Helper method to compute extra data from pubsub arguments 1194 """Helper method to compute extra data from pubsub arguments
1194 1195
1195 @param extra(None, dict): base extra dict, or None to generate a new one 1196 @param extra: base extra dict, or None to generate a new one
1196 @return (dict): dict which can be used directly in the bridge for pubsub 1197 @return: dict which can be used directly in the bridge for pubsub
1197 """ 1198 """
1198 if extra is None: 1199 if extra is None:
1199 extra = {} 1200 extra = {}
1200 else: 1201 else:
1201 intersection = {C.KEY_ORDER_BY}.intersection(list(extra.keys())) 1202 intersection = {C.KEY_ORDER_BY}.intersection(list(extra.keys()))
1232 except AttributeError: 1233 except AttributeError:
1233 pass 1234 pass
1234 else: 1235 else:
1235 if order_by is not None: 1236 if order_by is not None:
1236 extra[C.KEY_ORDER_BY] = self.args.order_by 1237 extra[C.KEY_ORDER_BY] = self.args.order_by
1237 return extra 1238 return data_format.serialise(extra)
1238 1239
1239 def add_parser_options(self): 1240 def add_parser_options(self):
1240 try: 1241 try:
1241 subcommands = self.subcommands 1242 subcommands = self.subcommands
1242 except AttributeError: 1243 except AttributeError: