Loading csst_common/pipeline.py +8 −5 Original line number Diff line number Diff line Loading @@ -266,18 +266,21 @@ class Message: def __repr__(self): return f"< Message [{self.file_path}] >" def write(self, dlist): def write(self, dlist: list[dict]): """Write messages to file.""" with open(self.file_path, "w+") as f: for d in dlist: f.write(self.dict2msg(d) + "\n") @staticmethod def dict2msg(d): def dict2msg(d: dict): """Convert `dict` to JSON format string.""" m = json.dumps(d).replace(" ", "") return m @staticmethod def msg2dict(m): def msg2dict(m: str): """Convert JSON format string to `dict`.""" d = json.loads(m) return d Loading Loading @@ -322,8 +325,8 @@ class Timestamp: with open(self.file_path, "w") as file: file.truncate(0) def touch(self): """Write a time stamp.""" def record(self): """Record a time stamp.""" with open(self.file_path, "a+") as f: f.write(f"{Time.now().isot}+00:00\n") Loading Loading
csst_common/pipeline.py +8 −5 Original line number Diff line number Diff line Loading @@ -266,18 +266,21 @@ class Message: def __repr__(self): return f"< Message [{self.file_path}] >" def write(self, dlist): def write(self, dlist: list[dict]): """Write messages to file.""" with open(self.file_path, "w+") as f: for d in dlist: f.write(self.dict2msg(d) + "\n") @staticmethod def dict2msg(d): def dict2msg(d: dict): """Convert `dict` to JSON format string.""" m = json.dumps(d).replace(" ", "") return m @staticmethod def msg2dict(m): def msg2dict(m: str): """Convert JSON format string to `dict`.""" d = json.loads(m) return d Loading Loading @@ -322,8 +325,8 @@ class Timestamp: with open(self.file_path, "w") as file: file.truncate(0) def touch(self): """Write a time stamp.""" def record(self): """Record a time stamp.""" with open(self.file_path, "a+") as f: f.write(f"{Time.now().isot}+00:00\n") Loading