ezKit 2.0.6__tar.gz → 2.0.8__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-2.0.6/ezKit.egg-info → ezkit-2.0.8}/PKG-INFO +1 -1
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit/utils.py +34 -1
- {ezkit-2.0.6 → ezkit-2.0.8/ezKit.egg-info}/PKG-INFO +1 -1
- {ezkit-2.0.6 → ezkit-2.0.8}/setup.py +1 -1
- {ezkit-2.0.6 → ezkit-2.0.8}/LICENSE +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/MANIFEST.in +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/README.md +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit/__init__.py +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit/database.py +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit/http.py +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit/redix.py +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit/stock.py +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit.egg-info/SOURCES.txt +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit.egg-info/dependency_links.txt +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit.egg-info/requires.txt +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/ezKit.egg-info/top_level.txt +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/pyproject.toml +0 -0
- {ezkit-2.0.6 → ezkit-2.0.8}/setup.cfg +0 -0
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
import re
|
|
4
4
|
import tomllib
|
|
5
5
|
|
|
6
|
+
from collections.abc import Callable, Iterable
|
|
7
|
+
from datetime import datetime, timezone
|
|
6
8
|
from os import environ
|
|
7
|
-
from typing import Iterable
|
|
8
9
|
|
|
9
10
|
from loguru import logger
|
|
10
11
|
|
|
@@ -48,6 +49,21 @@ def load_toml_file(file: str) -> dict:
|
|
|
48
49
|
# --------------------------------------------------------------------------------------------------
|
|
49
50
|
|
|
50
51
|
|
|
52
|
+
def map_filter(func: Callable, iterable: Iterable) -> list:
|
|
53
|
+
"""对 iterable 执行 func, 并保留为 True 的返回值"""
|
|
54
|
+
try:
|
|
55
|
+
return [x for x in map(func, iterable) if x]
|
|
56
|
+
except Exception as e:
|
|
57
|
+
if DEBUG:
|
|
58
|
+
logger.exception(e)
|
|
59
|
+
else:
|
|
60
|
+
logger.error(e)
|
|
61
|
+
return []
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# --------------------------------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
|
|
51
67
|
def check_dict_values_incorrect(
|
|
52
68
|
data: dict[str, object],
|
|
53
69
|
errors: object | Iterable[object] | None = None,
|
|
@@ -143,3 +159,20 @@ def check_dict_values_incorrect(
|
|
|
143
159
|
logger.error(e)
|
|
144
160
|
|
|
145
161
|
return False
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# --------------------------------------------------------------------------------------------------
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def timestamp_to_datetime(timestamp: int | float, tz: timezone = timezone.utc) -> datetime | None:
|
|
168
|
+
"""Unix Timestamp 转换为 Datatime"""
|
|
169
|
+
try:
|
|
170
|
+
if not isinstance(timestamp, (int, float)):
|
|
171
|
+
return None
|
|
172
|
+
return (datetime.fromtimestamp(timestamp, tz=tz)).replace(tzinfo=None)
|
|
173
|
+
except Exception as e:
|
|
174
|
+
if DEBUG:
|
|
175
|
+
logger.exception(e)
|
|
176
|
+
else:
|
|
177
|
+
logger.error(e)
|
|
178
|
+
return None
|
|
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
|
|
File without changes
|
|
File without changes
|