Commit 3fbc6ea2 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

add File class

parent 6c54c164
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -14,5 +14,6 @@ from .pipeline import Pipeline
from .ccds import CCDS
from .dfs import DFS
from .decorator import parameterized_module_decorator
from .file import File

__version__ = "0.0.2"

csst_common/file.py

0 → 100644
+13 −0
Original line number Diff line number Diff line
import os


class File:
    def __init__(self, file_path: str = "/path/to/file.fits"):
        self.file_path = file_path
        self.file_path_prefix, self.file_path_ext = os.path.splitext(file_path)

    def switch_extension(self, ext="wht.fits") -> str:
        if ext.startswith("."):
            return self.file_path_prefix + ext
        else:
            return self.file_path_prefix + "_" + ext