From 9fa37e4b37fa1effc9ac447ea8d9cc1116acac65 Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Thu, 20 Oct 2022 14:04:15 +0800 Subject: [PATCH] added FileRecorder.Record --- csst_common/file_recorder.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/csst_common/file_recorder.py b/csst_common/file_recorder.py index 5442a80..b171ef4 100644 --- a/csst_common/file_recorder.py +++ b/csst_common/file_recorder.py @@ -2,7 +2,6 @@ from collections import namedtuple from astropy import table import os - File = namedtuple( "FileRecord", ["filepath", "db", "comment", "existence"] @@ -52,8 +51,12 @@ class FileRecorder(list): test002.txt True Test file 2 False """ - def __init__(self): - super(FileRecorder, self).__init__() + def __init__(self, *args, **kwargs): + super(FileRecorder, self).__init__(*args, **kwargs) + + @staticmethod + def Record(filepath: str = "", db: bool = False, comment: str = ""): + return File(filepath=filepath, db=db, comment=comment, existence=os.path.exists(filepath)) def add_record(self, filepath: str = "", db: bool = False, comment: str = ""): existence = os.path.exists(filepath) -- GitLab