diff --git a/csst_dfs_client/common/utils.py b/csst_dfs_client/common/utils.py new file mode 100644 index 0000000000000000000000000000000000000000..b30a8bca6a1a51275997ad21cc1946ba328b6f25 --- /dev/null +++ b/csst_dfs_client/common/utils.py @@ -0,0 +1,16 @@ +from datetime import datetime +import re + +def is_valid_filename(file_name: str) -> bool: + pattern = r'^.*\..*$' + if re.match(pattern, file_name): + return True + else: + raise False + +def is_valid_datetime_format(date_str: str, format='%Y-%m-%d %H:%M:%S') -> bool: + try: + datetime.strptime(date_str, format) + return True + except ValueError: + raise ValueError(f"Incorrect data format, should be {format}") \ No newline at end of file