# HG changeset patch # User Goffi # Date 1627506075 -7200 # Node ID 5f65f4e9f8cbb082ca978be667c5ac770826ed10 # Parent 31628770a15a942796fc9a4f171bcde8d8844d1a plugin XEP-0060: getItems extra is now serialised dict diff -r 31628770a15a -r 5f65f4e9f8cb sat/plugins/plugin_misc_lists.py --- a/sat/plugins/plugin_misc_lists.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat/plugins/plugin_misc_lists.py Wed Jul 28 23:01:15 2021 +0200 @@ -219,7 +219,7 @@ host.bridge.addMethod( "listGet", ".plugin", - in_sign="ssiassa{ss}s", + in_sign="ssiassss", out_sign="s", method=lambda service, node, max_items, items_ids, sub_id, extra, profile_key: self._s._get( diff -r 31628770a15a -r 5f65f4e9f8cb sat/plugins/plugin_misc_merge_requests.py --- a/sat/plugins/plugin_misc_merge_requests.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat/plugins/plugin_misc_merge_requests.py Wed Jul 28 23:01:15 2021 +0200 @@ -77,7 +77,7 @@ self._handlers_list = [] # handlers sorted by priority self._type_handlers = {} # data type => handler map host.bridge.addMethod("mergeRequestsGet", ".plugin", - in_sign='ssiassa{ss}s', out_sign='s', + in_sign='ssiassss', out_sign='s', method=self._get, async_=True ) @@ -149,11 +149,10 @@ }) def _get(self, service='', node='', max_items=10, item_ids=None, sub_id=None, - extra_dict=None, profile_key=C.PROF_KEY_NONE): - if extra_dict and 'parse' in extra_dict: - extra_dict['parse'] = C.bool(extra_dict['parse']) + extra="", profile_key=C.PROF_KEY_NONE): + extra = data_format.deserialise(extra) client, service, node, max_items, extra, sub_id = self._s.prepareBridgeGet( - service, node, max_items, sub_id, extra_dict, profile_key) + service, node, max_items, sub_id, extra, profile_key) d = self.get(client, service, node or None, max_items, item_ids, sub_id or None, extra.rsm_request, extra.extra) d.addCallback(self.serialise) diff -r 31628770a15a -r 5f65f4e9f8cb sat/plugins/plugin_xep_0060.py --- a/sat/plugins/plugin_xep_0060.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat/plugins/plugin_xep_0060.py Wed Jul 28 23:01:15 2021 +0200 @@ -197,7 +197,7 @@ host.bridge.addMethod( "psItemsGet", ".plugin", - in_sign="ssiassa{ss}s", + in_sign="ssiassss", out_sign="s", method=self._getItems, async_=True, @@ -284,7 +284,7 @@ host.bridge.addMethod( "psGetFromMany", ".plugin", - in_sign="a(ss)ia{ss}s", + in_sign="a(ss)iss", out_sign="s", method=self._getFromMany, ) @@ -613,7 +613,7 @@ return data_format.serialise(metadata) def _getItems(self, service="", node="", max_items=10, item_ids=None, sub_id=None, - extra_dict=None, profile_key=C.PROF_KEY_NONE): + extra="", profile_key=C.PROF_KEY_NONE): """Get items from pubsub node @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit @@ -621,7 +621,7 @@ client = self.host.getClient(profile_key) service = jid.JID(service) if service else None max_items = None if max_items == C.NO_LIMIT else max_items - extra = self.parseExtra(extra_dict) + extra = self.parseExtra(data_format.deserialise(extra)) d = defer.ensureDeferred(self.getItems( client, service, @@ -1439,13 +1439,13 @@ return d def _getFromMany( - self, node_data, max_item=10, extra_dict=None, profile_key=C.PROF_KEY_NONE + self, node_data, max_item=10, extra="", profile_key=C.PROF_KEY_NONE ): """ @param max_item(int): maximum number of item to get, C.NO_LIMIT for no limit """ max_item = None if max_item == C.NO_LIMIT else max_item - extra = self.parseExtra(extra_dict) + extra = self.parseExtra(data_format.deserialise(extra)) return self.getFromMany( [(jid.JID(service), str(node)) for service, node in node_data], max_item, diff -r 31628770a15a -r 5f65f4e9f8cb sat/plugins/plugin_xep_0277.py --- a/sat/plugins/plugin_xep_0277.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat/plugins/plugin_xep_0277.py Wed Jul 28 23:01:15 2021 +0200 @@ -118,7 +118,7 @@ host.bridge.addMethod( "mbGet", ".plugin", - in_sign="ssiasa{ss}s", + in_sign="ssiasss", out_sign="s", method=self._mbGet, async_=True, @@ -931,7 +931,7 @@ metadata['items'] = items return data_format.serialise(metadata) - def _mbGet(self, service="", node="", max_items=10, item_ids=None, extra_dict=None, + def _mbGet(self, service="", node="", max_items=10, item_ids=None, extra="", profile_key=C.PROF_KEY_NONE): """ @param max_items(int): maximum number of item to get, C.NO_LIMIT for no limit @@ -940,7 +940,7 @@ client = self.host.getClient(profile_key) service = jid.JID(service) if service else None max_items = None if max_items == C.NO_LIMIT else max_items - extra = self._p.parseExtra(extra_dict) + extra = self._p.parseExtra(data_format.deserialise(extra)) d = defer.ensureDeferred( self.mbGet(client, service, node or None, max_items, item_ids, extra.rsm_request, extra.extra) diff -r 31628770a15a -r 5f65f4e9f8cb sat/plugins/plugin_xep_0346.py --- a/sat/plugins/plugin_xep_0346.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat/plugins/plugin_xep_0346.py Wed Jul 28 23:01:15 2021 +0200 @@ -118,7 +118,7 @@ host.bridge.addMethod( "psItemsFormGet", ".plugin", - in_sign="ssssiassa{ss}s", + in_sign="ssssiassss", out_sign="(asa{ss})", method=self._getDataFormItems, async_=True, @@ -302,7 +302,7 @@ return xml_tools.dataForm2dataDict(schema_form) def _getDataFormItems(self, form_ns="", service="", node="", schema="", max_items=10, - item_ids=None, sub_id=None, extra_dict=None, + item_ids=None, sub_id=None, extra="", profile_key=C.PROF_KEY_NONE): client = self.host.getClient(profile_key) service = jid.JID(service) if service else None @@ -313,7 +313,7 @@ else: schema = None max_items = None if max_items == C.NO_LIMIT else max_items - extra = self._p.parseExtra(extra_dict) + extra = self._p.parseExtra(data_format.deserialise(extra)) d = defer.ensureDeferred( self.getDataFormItems( client, @@ -553,7 +553,7 @@ ## Helper methods ## - def prepareBridgeGet(self, service, node, max_items, sub_id, extra_dict, profile_key): + def prepareBridgeGet(self, service, node, max_items, sub_id, extra, profile_key): """Parse arguments received from bridge *Get methods and return higher level data @return (tuple): (client, service, node, max_items, extra, sub_id) usable for @@ -566,12 +566,12 @@ max_items = None if max_items == C.NO_LIMIT else max_items if not sub_id: sub_id = None - extra = self._p.parseExtra(extra_dict) + extra = self._p.parseExtra(extra) return client, service, node, max_items, extra, sub_id def _get(self, service="", node="", max_items=10, item_ids=None, sub_id=None, - extra=None, default_node=None, form_ns=None, filters=None, + extra="", default_node=None, form_ns=None, filters=None, profile_key=C.PROF_KEY_NONE): """Bridge method to retrieve data from node with schema @@ -583,8 +583,7 @@ """ if filters is None: filters = {} - if extra is None: - extra = {} + extra = data_format.deserialise(extra) # XXX: Q&D way to get list for labels when displaying them, but text when we # have to modify them if C.bool(extra.get("labels_as_list", C.BOOL_FALSE)): diff -r 31628770a15a -r 5f65f4e9f8cb sat_frontends/jp/base.py --- a/sat_frontends/jp/base.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat_frontends/jp/base.py Wed Jul 28 23:01:15 2021 +0200 @@ -41,6 +41,7 @@ from sat.tools.common import uri from sat.tools.common import date_utils from sat.tools.common import utils +from sat.tools.common import data_format from sat.tools.common.ansi import ANSI as A from sat.core import exceptions import sat_frontends.jp @@ -1189,11 +1190,11 @@ _('trying to use output when use_output has not been set')) return self.host.output(output_type, self.args.output, self.extra_outputs, data) - def getPubsubExtra(self, extra=None): + def getPubsubExtra(self, extra: Optional[dict] = None) -> str: """Helper method to compute extra data from pubsub arguments - @param extra(None, dict): base extra dict, or None to generate a new one - @return (dict): dict which can be used directly in the bridge for pubsub + @param extra: base extra dict, or None to generate a new one + @return: dict which can be used directly in the bridge for pubsub """ if extra is None: extra = {} @@ -1234,7 +1235,7 @@ else: if order_by is not None: extra[C.KEY_ORDER_BY] = self.args.order_by - return extra + return data_format.serialise(extra) def add_parser_options(self): try: diff -r 31628770a15a -r 5f65f4e9f8cb sat_frontends/jp/cmd_blog.py --- a/sat_frontends/jp/cmd_blog.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat_frontends/jp/cmd_blog.py Wed Jul 28 23:01:15 2021 +0200 @@ -600,7 +600,9 @@ items = [item] if item else [] mb_data = data_format.deserialise( - await self.host.bridge.mbGet(service, node, 1, items, {}, self.profile) + await self.host.bridge.mbGet( + service, node, 1, items, data_format.serialise({}), self.profile + ) ) item = mb_data["items"][0] diff -r 31628770a15a -r 5f65f4e9f8cb sat_frontends/jp/cmd_merge_request.py --- a/sat_frontends/jp/cmd_merge_request.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat_frontends/jp/cmd_merge_request.py Wed Jul 28 23:01:15 2021 +0200 @@ -139,7 +139,7 @@ self.args.max, self.args.items, "", - extra, + data_format.serialise(extra), self.profile, ) ) diff -r 31628770a15a -r 5f65f4e9f8cb sat_frontends/jp/cmd_pubsub.py --- a/sat_frontends/jp/cmd_pubsub.py Wed Jul 28 22:15:31 2021 +0200 +++ b/sat_frontends/jp/cmd_pubsub.py Wed Jul 28 23:01:15 2021 +0200 @@ -955,7 +955,7 @@ items = [item] if item else [] ps_result = data_format.deserialise( await self.host.bridge.psItemsGet( - service, node, 1, items, "", {}, self.profile + service, node, 1, items, "", data_format.serialise({}), self.profile ) ) item_raw = ps_result["items"][0] @@ -1687,7 +1687,7 @@ self.args.rsm_max, self.args.items, "", - extra, + data_format.serialise(extra), self.profile, ) )