Commit e49ef6f6 authored by Wei Shoulin's avatar Wei Shoulin
Browse files

utils

parent c79c0d5e
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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment