From 5b03f95cf2bf910acd815b4840b1e3d3769e9d02 Mon Sep 17 00:00:00 2001 From: BO ZHANG Date: Thu, 14 Dec 2023 10:59:56 +0800 Subject: [PATCH] tweaks --- csst_common/file.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/csst_common/file.py b/csst_common/file.py index 6727cfc..009e1f4 100644 --- a/csst_common/file.py +++ b/csst_common/file.py @@ -11,18 +11,14 @@ class File: self.new_dir = new_dir if new_dir is not None else self.dirname def replace_ext( - self, new_ext: str = "wht.fits", new_dir: Optional[str] = None + self, new_ext: Optional[str] = "img.fits", new_dir: Optional[str] = None ) -> str: if new_dir is None: new_dir = self.new_dir + if new_ext is None: + new_ext = self.ext if new_ext.startswith("."): - return os.path.join( - new_dir if new_dir is not None else self.dirname, - self.prefix + new_ext, - ) + return os.path.join(new_dir, self.prefix + new_ext) else: - return os.path.join( - new_dir if new_dir is not None else self.dirname, - self.prefix + "_" + new_ext, - ) + return os.path.join(new_dir, self.prefix + "_" + new_ext) -- GitLab