feat(base): 优化环境变量配置
This commit is contained in:
@@ -6,8 +6,11 @@
|
||||
# @Desc :
|
||||
import asyncio
|
||||
import functools
|
||||
from datetime import datetime
|
||||
from typing import Callable
|
||||
|
||||
from config import settings
|
||||
|
||||
|
||||
def async_retry(max_retries: int = 3, exceptions: tuple = (Exception,)):
|
||||
"""
|
||||
@@ -32,3 +35,25 @@ def async_retry(max_retries: int = 3, exceptions: tuple = (Exception,)):
|
||||
return wrapper
|
||||
|
||||
return decorator
|
||||
|
||||
|
||||
def generate_keyname(name: str, use_today: bool = False) -> str:
|
||||
"""生成统一键名前缀"""
|
||||
if name.startswith(settings.PREFIX) is False:
|
||||
names = [settings.PREFIX, name]
|
||||
if use_today:
|
||||
today = datetime.now().strftime('%Y%m%d')
|
||||
names.insert(1, today)
|
||||
|
||||
return ':'.join(names)
|
||||
else:
|
||||
return name
|
||||
|
||||
|
||||
def check_picture_for_empty(picture: dict, or_: bool = False) -> bool:
|
||||
"""检查图片是否为空"""
|
||||
results = [
|
||||
picture.get('front_picture') is None,
|
||||
picture.get('reverse_picture') is None
|
||||
]
|
||||
return any(results) if or_ else all(results)
|
||||
|
||||
Reference in New Issue
Block a user