ezKit 3.0.2__tar.gz → 3.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ezkit-3.0.2/ezKit.egg-info → ezkit-3.0.3}/PKG-INFO +1 -1
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit/utils.py +37 -1
- {ezkit-3.0.2 → ezkit-3.0.3/ezKit.egg-info}/PKG-INFO +1 -1
- {ezkit-3.0.2 → ezkit-3.0.3}/setup.py +1 -1
- {ezkit-3.0.2 → ezkit-3.0.3}/LICENSE +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/MANIFEST.in +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/README.md +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit/__init__.py +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit/database.py +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit/sendemail.py +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit.egg-info/SOURCES.txt +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit.egg-info/dependency_links.txt +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit.egg-info/requires.txt +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/ezKit.egg-info/top_level.txt +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/pyproject.toml +0 -0
- {ezkit-3.0.2 → ezkit-3.0.3}/setup.cfg +0 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""Utils Library"""
|
|
2
2
|
|
|
3
|
+
import time
|
|
4
|
+
from functools import wraps
|
|
3
5
|
from os import environ
|
|
4
6
|
from pathlib import Path
|
|
5
|
-
from typing import Any
|
|
7
|
+
from typing import Any, Callable, ParamSpec, TypeVar
|
|
6
8
|
|
|
7
9
|
from loguru import logger
|
|
8
10
|
|
|
@@ -59,6 +61,40 @@ def isTrue(target: object, typeClass: Any) -> bool:
|
|
|
59
61
|
# --------------------------------------------------------------------------------------------------
|
|
60
62
|
|
|
61
63
|
|
|
64
|
+
P = ParamSpec("P")
|
|
65
|
+
R = TypeVar("R")
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def retry_decorator(times: int = 3, delay: float = 1.0):
|
|
69
|
+
"""重试装饰器"""
|
|
70
|
+
|
|
71
|
+
def decorator(func: Callable[P, R]) -> Callable[P, R | bool]:
|
|
72
|
+
@wraps(func)
|
|
73
|
+
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R | bool:
|
|
74
|
+
max_times = max(1, times)
|
|
75
|
+
for attempt in range(max_times):
|
|
76
|
+
try:
|
|
77
|
+
return func(*args, **kwargs)
|
|
78
|
+
except Exception as e:
|
|
79
|
+
if DEBUG:
|
|
80
|
+
logger.exception(e)
|
|
81
|
+
else:
|
|
82
|
+
logger.error(e)
|
|
83
|
+
|
|
84
|
+
if attempt < (max_times - 1):
|
|
85
|
+
time.sleep(delay)
|
|
86
|
+
else:
|
|
87
|
+
return False
|
|
88
|
+
return False
|
|
89
|
+
|
|
90
|
+
return wrapper
|
|
91
|
+
|
|
92
|
+
return decorator
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
# --------------------------------------------------------------------------------------------------
|
|
96
|
+
|
|
97
|
+
|
|
62
98
|
def check_path_type(path_object: str | Path, path_type: str) -> bool:
|
|
63
99
|
"""检查路径类型"""
|
|
64
100
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|