hutool-python 1.0.0__py3-none-any.whl → 1.0.1__py3-none-any.whl
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.
- hutool/cache/fifo_cache.py +11 -2
- hutool/cache/lru_cache.py +11 -2
- hutool/core/coll.py +65 -10
- hutool/core/date.py +1108 -1024
- hutool/core/exceptions.py +50 -1
- hutool/core/io/data_size_util.py +79 -79
- hutool/core/io/file_name_util.py +111 -111
- hutool/core/io/file_util.py +775 -650
- hutool/core/io/io_util.py +133 -133
- hutool/core/io/resource_util.py +137 -137
- hutool/core/map.py +971 -933
- hutool/core/text/str_builder.py +224 -224
- hutool/core/util/charset_util.py +42 -6
- hutool/core/util/id_util.py +40 -6
- hutool/core/util/number_util.py +720 -720
- hutool/core/util/page_util.py +96 -61
- hutool/core/util/random_util.py +97 -14
- hutool/core/util/runtime_util.py +113 -89
- hutool/core/util/system_util.py +53 -11
- hutool/core/util/version_util.py +29 -6
- hutool/cron/cron_util.py +8 -5
- hutool/crypto/digest_util.py +144 -22
- hutool/crypto/secure_util.py +11 -2
- hutool/json_util.py +124 -25
- {hutool_python-1.0.0.dist-info → hutool_python-1.0.1.dist-info}/METADATA +439 -438
- {hutool_python-1.0.0.dist-info → hutool_python-1.0.1.dist-info}/RECORD +29 -29
- {hutool_python-1.0.0.dist-info → hutool_python-1.0.1.dist-info}/LICENSE +0 -0
- {hutool_python-1.0.0.dist-info → hutool_python-1.0.1.dist-info}/WHEEL +0 -0
- {hutool_python-1.0.0.dist-info → hutool_python-1.0.1.dist-info}/top_level.txt +0 -0
hutool/cache/fifo_cache.py
CHANGED
|
@@ -79,9 +79,18 @@ class FIFOCache:
|
|
|
79
79
|
return self._cache.keys()
|
|
80
80
|
|
|
81
81
|
def __contains__(self, key: Any) -> bool:
|
|
82
|
-
"""
|
|
82
|
+
"""
|
|
83
|
+
判断键是否存在于缓存中。
|
|
84
|
+
|
|
85
|
+
:param key: 缓存键
|
|
86
|
+
:return: 是否存在
|
|
87
|
+
"""
|
|
83
88
|
return key in self._cache
|
|
84
89
|
|
|
85
90
|
def __len__(self) -> int:
|
|
86
|
-
"""
|
|
91
|
+
"""
|
|
92
|
+
返回缓存大小。
|
|
93
|
+
|
|
94
|
+
:return: 缓存条目数
|
|
95
|
+
"""
|
|
87
96
|
return len(self._cache)
|
hutool/cache/lru_cache.py
CHANGED
|
@@ -85,9 +85,18 @@ class LRUCache:
|
|
|
85
85
|
return self._cache.keys()
|
|
86
86
|
|
|
87
87
|
def __contains__(self, key: Any) -> bool:
|
|
88
|
-
"""
|
|
88
|
+
"""
|
|
89
|
+
判断键是否存在于缓存中。
|
|
90
|
+
|
|
91
|
+
:param key: 缓存键
|
|
92
|
+
:return: 是否存在
|
|
93
|
+
"""
|
|
89
94
|
return key in self._cache
|
|
90
95
|
|
|
91
96
|
def __len__(self) -> int:
|
|
92
|
-
"""
|
|
97
|
+
"""
|
|
98
|
+
返回缓存大小。
|
|
99
|
+
|
|
100
|
+
:return: 缓存条目数
|
|
101
|
+
"""
|
|
93
102
|
return len(self._cache)
|
hutool/core/coll.py
CHANGED
|
@@ -28,33 +28,62 @@ class CollUtil:
|
|
|
28
28
|
|
|
29
29
|
@staticmethod
|
|
30
30
|
def is_empty(coll) -> bool:
|
|
31
|
-
"""
|
|
31
|
+
"""
|
|
32
|
+
集合是否为空,None 也视为空。
|
|
33
|
+
|
|
34
|
+
支持 list/tuple/set/dict/frozenset。
|
|
35
|
+
|
|
36
|
+
:param coll: 集合对象
|
|
37
|
+
:return: 是否为空
|
|
38
|
+
"""
|
|
32
39
|
if coll is None:
|
|
33
40
|
return True
|
|
34
41
|
return len(coll) == 0
|
|
35
42
|
|
|
36
43
|
@staticmethod
|
|
37
44
|
def is_not_empty(coll) -> bool:
|
|
38
|
-
"""
|
|
45
|
+
"""
|
|
46
|
+
集合是否为非空。
|
|
47
|
+
|
|
48
|
+
:param coll: 集合对象
|
|
49
|
+
:return: 是否为非空
|
|
50
|
+
"""
|
|
39
51
|
return not CollUtil.is_empty(coll)
|
|
40
52
|
|
|
41
53
|
@staticmethod
|
|
42
54
|
def has_null(coll: Sequence) -> bool:
|
|
43
|
-
"""
|
|
55
|
+
"""
|
|
56
|
+
集合中是否有 None 元素。
|
|
57
|
+
|
|
58
|
+
:param coll: 序列对象
|
|
59
|
+
:return: 是否包含 None 元素
|
|
60
|
+
"""
|
|
44
61
|
if coll is None:
|
|
45
62
|
return True
|
|
46
63
|
return any(element is None for element in coll)
|
|
47
64
|
|
|
48
65
|
@staticmethod
|
|
49
66
|
def contains(coll: Iterable, element: Any) -> bool:
|
|
50
|
-
"""
|
|
67
|
+
"""
|
|
68
|
+
是否包含指定元素。
|
|
69
|
+
|
|
70
|
+
:param coll: 可迭代集合
|
|
71
|
+
:param element: 待查找的元素
|
|
72
|
+
:return: 是否包含
|
|
73
|
+
"""
|
|
51
74
|
if coll is None:
|
|
52
75
|
return False
|
|
53
76
|
return element in coll
|
|
54
77
|
|
|
55
78
|
@staticmethod
|
|
56
79
|
def contains_any(coll: Iterable, *elements) -> bool:
|
|
57
|
-
"""
|
|
80
|
+
"""
|
|
81
|
+
是否包含任意一个指定元素。
|
|
82
|
+
|
|
83
|
+
:param coll: 可迭代集合
|
|
84
|
+
:param elements: 待查找的元素
|
|
85
|
+
:return: 是否包含任意一个
|
|
86
|
+
"""
|
|
58
87
|
if coll is None or not elements:
|
|
59
88
|
return False
|
|
60
89
|
if isinstance(coll, (set, frozenset)):
|
|
@@ -64,7 +93,13 @@ class CollUtil:
|
|
|
64
93
|
|
|
65
94
|
@staticmethod
|
|
66
95
|
def contains_all(coll: Iterable, *elements) -> bool:
|
|
67
|
-
"""
|
|
96
|
+
"""
|
|
97
|
+
是否包含全部指定元素。
|
|
98
|
+
|
|
99
|
+
:param coll: 可迭代集合
|
|
100
|
+
:param elements: 待查找的元素
|
|
101
|
+
:return: 是否包含全部
|
|
102
|
+
"""
|
|
68
103
|
if coll is None:
|
|
69
104
|
return False
|
|
70
105
|
if not elements:
|
|
@@ -76,19 +111,34 @@ class CollUtil:
|
|
|
76
111
|
|
|
77
112
|
@staticmethod
|
|
78
113
|
def new_array_list(*args) -> list:
|
|
79
|
-
"""
|
|
114
|
+
"""
|
|
115
|
+
新建 ArrayList(Python list),可传入初始元素。
|
|
116
|
+
|
|
117
|
+
:param args: 初始元素
|
|
118
|
+
:return: 新列表
|
|
119
|
+
"""
|
|
80
120
|
return list(args) if args else []
|
|
81
121
|
|
|
82
122
|
@staticmethod
|
|
83
123
|
def new_hash_set(*args) -> set:
|
|
84
|
-
"""
|
|
124
|
+
"""
|
|
125
|
+
新建 HashSet(Python set),可传入初始元素。
|
|
126
|
+
|
|
127
|
+
:param args: 初始元素
|
|
128
|
+
:return: 新集合
|
|
129
|
+
"""
|
|
85
130
|
return set(args) if args else set()
|
|
86
131
|
|
|
87
132
|
# ── 转换 ──────────────────────────────────────────────
|
|
88
133
|
|
|
89
134
|
@staticmethod
|
|
90
135
|
def to_list(iterable: Iterable) -> list:
|
|
91
|
-
"""
|
|
136
|
+
"""
|
|
137
|
+
转为列表。
|
|
138
|
+
|
|
139
|
+
:param iterable: 可迭代对象
|
|
140
|
+
:return: 列表
|
|
141
|
+
"""
|
|
92
142
|
if iterable is None:
|
|
93
143
|
return []
|
|
94
144
|
if isinstance(iterable, list):
|
|
@@ -97,7 +147,12 @@ class CollUtil:
|
|
|
97
147
|
|
|
98
148
|
@staticmethod
|
|
99
149
|
def to_set(iterable: Iterable) -> set:
|
|
100
|
-
"""
|
|
150
|
+
"""
|
|
151
|
+
转为集合。
|
|
152
|
+
|
|
153
|
+
:param iterable: 可迭代对象
|
|
154
|
+
:return: 集合
|
|
155
|
+
"""
|
|
101
156
|
if iterable is None:
|
|
102
157
|
return set()
|
|
103
158
|
return set(iterable)
|