changeset 2910:b2f323237fce

jp, plugin merge-requests: used u'' as default for item id in pubsub arguments + fixed some required arguments: u"" is now used as defaut item id instead of node, as it needs to be serialised anyway. This is temporary solution, as empty string can be used for item id (not forbidden by XEP-0060), but for now this is not handled correctly in jp/SàT (see https://bugs.goffi.org/bugs/view/289). Correct solution will probably need to use a special key in extra to mark empty string in id. Added/removed some required values for node or item when it made sense.
author Goffi <goffi@goffi.org>
date Sun, 14 Apr 2019 08:21:51 +0200
parents 90146552cde5
children cd391ea847cb
files sat/plugins/plugin_misc_merge_requests.py sat_frontends/jp/base.py sat_frontends/jp/cmd_blog.py sat_frontends/jp/cmd_event.py sat_frontends/jp/cmd_pubsub.py
diffstat 5 files changed, 9 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_misc_merge_requests.py	Sun Apr 14 08:21:51 2019 +0200
+++ b/sat/plugins/plugin_misc_merge_requests.py	Sun Apr 14 08:21:51 2019 +0200
@@ -194,8 +194,8 @@
              extra=None, profile_key=C.PROF_KEY_NONE):
         client, service, node, schema, item_id, extra = self._s.prepareBridgeSet(
             service, node, schema, item_id, extra, profile_key)
-        d = self.set(client, service, node, repository, method, values, schema, item_id,
-                     extra, deserialise=True)
+        d = self.set(client, service, node, repository, method, values, schema,
+                     item_id or None, extra, deserialise=True)
         d.addCallback(lambda ret: ret or u'')
         return d
 
--- a/sat_frontends/jp/base.py	Sun Apr 14 08:21:51 2019 +0200
+++ b/sat_frontends/jp/base.py	Sun Apr 14 08:21:51 2019 +0200
@@ -367,7 +367,8 @@
                 default = defaults.pop(u'item', _(u'last item'))
                 if default is not None:
                     item_help += _(u" (DEFAULT: {default})".format(default=default))
-            pubsub_group.add_argument("-i", "--item", type=unicode_decoder, help=item_help)
+            pubsub_group.add_argument("-i", "--item", type=unicode_decoder, default=u'',
+                                      help=item_help)
             pubsub_group.add_argument("-L", "--last-item", action='store_true', help=_(u'retrieve last item'))
         elif flags.multi_items:
             # mutiple items, this activate several features: max-items, RSM, MAM
--- a/sat_frontends/jp/cmd_blog.py	Sun Apr 14 08:21:51 2019 +0200
+++ b/sat_frontends/jp/cmd_blog.py	Sun Apr 14 08:21:51 2019 +0200
@@ -183,7 +183,7 @@
         self.pubsub_item = self.args.item
         mb_data = {}
         self.setMbDataFromArgs(mb_data)
-        if self.pubsub_item is not None:
+        if self.pubsub_item:
             mb_data["id"] = self.pubsub_item
         content = codecs.getreader("utf-8")(sys.stdin).read()
         self.setMbDataContent(content, mb_data)
@@ -541,7 +541,7 @@
     def publish(self, content, mb_data):
         self.setMbDataContent(content, mb_data)
 
-        if self.pubsub_item is not None:
+        if self.pubsub_item:
             mb_data["id"] = self.pubsub_item
 
         mb_data = data_format.serialise(mb_data)
--- a/sat_frontends/jp/cmd_event.py	Sun Apr 14 08:21:51 2019 +0200
+++ b/sat_frontends/jp/cmd_event.py	Sun Apr 14 08:21:51 2019 +0200
@@ -43,7 +43,7 @@
             "get",
             use_output=C.OUTPUT_DICT,
             use_pubsub=True,
-            pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
+            pubsub_flags={C.SINGLE_ITEM},
             use_verbose=True,
             help=_(u"get event data"),
         )
@@ -125,7 +125,6 @@
             host,
             "create",
             use_pubsub=True,
-            pubsub_flags={C.NODE},
             help=_("create or replace event"),
         )
         EventBase.__init__(self)
--- a/sat_frontends/jp/cmd_pubsub.py	Sun Apr 14 08:21:51 2019 +0200
+++ b/sat_frontends/jp/cmd_pubsub.py	Sun Apr 14 08:21:51 2019 +0200
@@ -896,7 +896,7 @@
             host,
             "delete",
             use_pubsub=True,
-            pubsub_flags={C.NODE, C.SINGLE_ITEM},
+            pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
             help=_(u"delete an item"),
         )
         self.need_loop = True
@@ -980,7 +980,7 @@
                 error=True,
             )
             self.host.quit(1)
-        items = [item] if item is not None else []
+        items = [item] if item else []
         item_raw = self.host.bridge.psItemsGet(
             service, node, 1, items, "", {}, self.profile
         )[0][0]