diff sat_frontends/jp/cmd_blog.py @ 3715:b9718216a1c0 0.9

merge bookmark 0.9
author Goffi <goffi@goffi.org>
date Wed, 01 Dec 2021 16:13:31 +0100
parents 9ca19b317293
children a6dfd3db372b
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_blog.py	Tue Nov 30 23:31:09 2021 +0100
+++ b/sat_frontends/jp/cmd_blog.py	Wed Dec 01 16:13:31 2021 +0100
@@ -22,7 +22,6 @@
 import sys
 import os.path
 import os
-import time
 import tempfile
 import subprocess
 import asyncio
@@ -251,7 +250,7 @@
             "get",
             use_verbose=True,
             use_pubsub=True,
-            pubsub_flags={C.MULTI_ITEMS},
+            pubsub_flags={C.MULTI_ITEMS, C.CACHE},
             use_output=C.OUTPUT_COMPLEX,
             extra_outputs=extra_outputs,
             help=_("get blog item(s)"),
@@ -290,10 +289,10 @@
         return ", ".join(tags)
 
     def format_updated(self, item, keys):
-        return self.format_time(item["updated"])
+        return common.format_time(item["updated"])
 
     def format_published(self, item, keys):
-        return self.format_time(item["published"])
+        return common.format_time(item["published"])
 
     def format_url(self, item, keys):
         return uri.buildXMPPUri(
@@ -372,15 +371,6 @@
             if idx < len(items) - 1:
                 print("")
 
-    def format_time(self, timestamp):
-        """return formatted date for timestamp
-
-        @param timestamp(str,int,float): unix timestamp
-        @return (unicode): formatted date
-        """
-        fmt = "%d/%m/%Y %H:%M:%S"
-        return time.strftime(fmt, time.localtime(float(timestamp)))
-
     def fancy_output(self, data):
         """display blog is a nice to read way
 
@@ -413,10 +403,10 @@
             if author:
                 meta.append(A.color(A.FG_YELLOW, author))
             if published:
-                meta.append(A.color(A.FG_YELLOW, "on ", self.format_time(published)))
+                meta.append(A.color(A.FG_YELLOW, "on ", common.format_time(published)))
             if updated != published:
                 meta.append(
-                    A.color(A.FG_YELLOW, "(updated on ", self.format_time(updated), ")")
+                    A.color(A.FG_YELLOW, "(updated on ", common.format_time(updated), ")")
                 )
             print((" ".join(meta)))
             if tags:
@@ -600,7 +590,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]