From a39acbc0ee92966bd49b5af5c95949093a6bad5f Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Sat, 30 Dec 2023 12:42:45 +0800 Subject: [PATCH] add Message.preview() --- csst_common/pipeline.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/csst_common/pipeline.py b/csst_common/pipeline.py index 6f66955..3b763af 100644 --- a/csst_common/pipeline.py +++ b/csst_common/pipeline.py @@ -289,6 +289,13 @@ class Message: for d in dlist: f.write(self.dict2msg(d) + "\n") + def preview(self, dlist: list[dict]) -> str: + """Preview messages.""" + s = "" + for d in dlist: + s += self.dict2msg(d) + "\n" + print(s) + @staticmethod def dict2msg(d: dict): """Convert `dict` to JSON format string.""" -- GitLab