From e49ef6f6f8efab6c047e51e0a6bc9e2adf7add9e Mon Sep 17 00:00:00 2001 From: shoulinwei Date: Sun, 29 Dec 2024 16:14:50 +0800 Subject: [PATCH] utils --- csst_dfs_client/common/utils.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 csst_dfs_client/common/utils.py diff --git a/csst_dfs_client/common/utils.py b/csst_dfs_client/common/utils.py new file mode 100644 index 0000000..b30a8bc --- /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 -- GitLab