ezKit 1.12.1__py3-none-any.whl → 1.12.2__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.
ezKit/database.py CHANGED
@@ -251,9 +251,7 @@ class Database:
251
251
  with open(encoding="utf-8", **read_sql_file_kwargs) as _file:
252
252
  sql_statement = _file.read()
253
253
  else:
254
- if not (
255
- isinstance(sql, str) and utils.check_arguments([(sql, str, "sql")])
256
- ):
254
+ if not isinstance(sql, str):
257
255
  return None
258
256
  sql_statement = sql
259
257
  except Exception as e:
@@ -277,9 +275,7 @@ class Database:
277
275
  logger.success(f"{info} [success]")
278
276
 
279
277
  # 返回查询结果
280
- if isinstance(save_to_csv, dict) and utils.isTrue(
281
- save_to_csv, dict
282
- ):
278
+ if isinstance(save_to_csv, dict) and utils.isTrue(save_to_csv, dict):
283
279
  save_to_csv_kwargs: dict = {
284
280
  "mode": "w",
285
281
  "encoding": "utf-8",
@@ -298,9 +294,7 @@ class Database:
298
294
 
299
295
  # ----------------------------------------------------------------------------------------------
300
296
 
301
- def read_with_pandas(
302
- self, method: str = "read_sql", result_type: str = "df", **kwargs
303
- ) -> pd.DataFrame | list | dict:
297
+ def read_with_pandas(self, method: str = "read_sql", result_type: str = "df", **kwargs) -> pd.DataFrame | list | dict:
304
298
  """读取数据"""
305
299
 
306
300
  # 使用SQL查询数据: 使用 pd.read_sql 的参数
@@ -311,12 +305,6 @@ class Database:
311
305
 
312
306
  data: pd.DataFrame = pd.DataFrame()
313
307
 
314
- if not utils.check_arguments([(method, str, "method")]):
315
- return data
316
-
317
- if not utils.check_arguments([(result_type, str, "result_type")]):
318
- return data
319
-
320
308
  info: str = "read data"
321
309
 
322
310
  try:
ezKit/qywx.py CHANGED
@@ -169,10 +169,6 @@ class QYWX:
169
169
 
170
170
  info: str = f"根据电话号码获取用户ID: {mobile}"
171
171
 
172
- if not utils.check_arguments([(mobile, str, "mobile")]):
173
- logger.error(f"{info} [错误]")
174
- return None
175
-
176
172
  try:
177
173
 
178
174
  logger.info(f"{info} ......")
@@ -236,12 +232,6 @@ class QYWX:
236
232
 
237
233
  info: str = "发送消息"
238
234
 
239
- if not utils.check_arguments(
240
- [(mobile, (str, list), "mobile"), (message, str, "message")]
241
- ):
242
- logger.error(f"{info} [失败]")
243
- return False
244
-
245
235
  try:
246
236
 
247
237
  logger.info(f"{info} ......")
@@ -267,19 +257,12 @@ class QYWX:
267
257
 
268
258
  user_object = self.get_user_id_by_mobile(user)
269
259
 
270
- if not (
271
- isinstance(user_object, dict) and utils.isTrue(user_object, dict)
272
- ):
260
+ if not (isinstance(user_object, dict) and utils.isTrue(user_object, dict)):
273
261
  logger.error(f"{info} [获取用户ID错误: {user}]")
274
262
  continue
275
263
 
276
- if (
277
- user_object.get("errcode", -1) != 0
278
- or user_object.get("errmsg", "") != "ok"
279
- ):
280
- logger.error(
281
- f"{user_object.get('errcode')}: {user_object.get('errmsg')}"
282
- )
264
+ if user_object.get("errcode", -1) != 0 or user_object.get("errmsg", "") != "ok":
265
+ logger.error(f"{user_object.get('errcode')}: {user_object.get('errmsg')}")
283
266
  continue
284
267
 
285
268
  json_dict = {
ezKit/utils.py CHANGED
@@ -73,23 +73,23 @@ def isTrue(target: object, typeClass: Any) -> bool:
73
73
  # --------------------------------------------------------------------------------------------------
74
74
 
75
75
 
76
- def check_arguments(data: list) -> bool:
77
- """检查函数参数"""
76
+ # def check_arguments(data: list) -> bool:
77
+ # """检查函数参数"""
78
78
 
79
- # data 示例: [(name, str, "name"), (age, int, "age")]
79
+ # # data 示例: [(name, str, "name"), (age, int, "age")]
80
80
 
81
- try:
82
- if not isTrue(data, list):
83
- logger.error(f"argument error: data {type(data)}")
84
- return False
85
- for arg, arg_type, info in data:
86
- if not isTrue(arg, arg_type):
87
- logger.error(f"argument error: {info} {type(arg)}")
88
- return False
89
- return True
90
- except Exception as e:
91
- logger.exception(e)
92
- return False
81
+ # try:
82
+ # if not isTrue(data, list):
83
+ # logger.error(f"argument error: data {type(data)}")
84
+ # return False
85
+ # for arg, arg_type, info in data:
86
+ # if not isTrue(arg, arg_type):
87
+ # logger.error(f"argument error: {info} {type(arg)}")
88
+ # return False
89
+ # return True
90
+ # except Exception as e:
91
+ # logger.exception(e)
92
+ # return False
93
93
 
94
94
 
95
95
  # --------------------------------------------------------------------------------------------------
@@ -102,10 +102,6 @@ def os_environ(name: str, value: Any = None) -> Any:
102
102
  # Python 没有全局变量, 多个文件无法调用同一个变量.
103
103
  # 为了解决这个问题, 将变量设置为系统变量, 从而实现多个文件调用同一个变量.
104
104
 
105
- # 检查参数是否正确
106
- if not check_arguments([(name, str, "name")]):
107
- return None
108
-
109
105
  try:
110
106
 
111
107
  # 变量名添加一个前缀, 防止和系统中其它变量名冲突
@@ -144,10 +140,6 @@ def mam_of_numbers(numbers: list | tuple, dest_type: str | None = None) -> tuple
144
140
  # numbers 数字列表 (仅支持 list 和 tuple, 不支 set)
145
141
  # dest_type 目标类型 (将数字列表中的数字转换成统一的类型)
146
142
 
147
- # 检查参数是否正确
148
- if not check_arguments([(numbers, (list, tuple), "numbers")]):
149
- return None
150
-
151
143
  if not any([isTrue(dest_type, str), dest_type is None]):
152
144
  logger.error("argument error: dest_type")
153
145
  return None
@@ -184,9 +176,7 @@ def mam_of_numbers(numbers: list | tuple, dest_type: str | None = None) -> tuple
184
176
  # --------------------------------------------------------------------------------------------------
185
177
 
186
178
 
187
- def step_number_for_split_equally(
188
- integer: int, split_equally_number: int
189
- ) -> int | None:
179
+ def step_number_for_split_equally(integer: int, split_equally_number: int) -> int | None:
190
180
  """
191
181
  step number for split equally
192
182
 
@@ -218,11 +208,6 @@ def step_number_for_split_equally(
218
208
 
219
209
  def division(dividend: int | float, divisor: int | float) -> float | None:
220
210
  """Division"""
221
- # 检查参数是否正确
222
- if not check_arguments(
223
- [(dividend, (int, float), "dividend"), (divisor, (int, float), "divisor")]
224
- ):
225
- return None
226
211
  try:
227
212
  return dividend / divisor
228
213
  except Exception as e:
@@ -238,12 +223,6 @@ def format_float(number: float | int, index: int = 2, limit: int = 3) -> float |
238
223
 
239
224
  # 以两位和三位为例, 如果结果为假, 即: 0, 0.0, 0.00 等,保留小数点后的三位, 否则保留小数点后的两位.
240
225
 
241
- # 检查参数
242
- if not check_arguments(
243
- [(number, (float, int), "number"), (index, int, "index"), (limit, int, "limit")]
244
- ):
245
- return False
246
-
247
226
  try:
248
227
  rounded_float = round(number, index)
249
228
  return rounded_float if bool(rounded_float) else round(number, limit)
@@ -261,10 +240,6 @@ def check_file_type(file_object: str, file_type: str) -> bool:
261
240
  # file_object 文件对象
262
241
  # file_type 文件类型
263
242
 
264
- # 检查参数是否正确
265
- if not check_arguments([(file_object, str, "file"), (file_type, str, "file_type")]):
266
- return False
267
-
268
243
  try:
269
244
 
270
245
  _file_path = Path(file_object)
@@ -274,9 +249,7 @@ def check_file_type(file_object: str, file_type: str) -> bool:
274
249
  result = False
275
250
  case True if file_type == "absolute" and _file_path.is_absolute() is True:
276
251
  result = True
277
- case True if (
278
- file_type == "block_device" and _file_path.is_block_device() is True
279
- ):
252
+ case True if file_type == "block_device" and _file_path.is_block_device() is True:
280
253
  result = True
281
254
  case True if file_type == "dir" and _file_path.is_dir() is True:
282
255
  result = True
@@ -370,10 +343,6 @@ def list_split(data: list, number: int, equally: bool = False) -> list | None:
370
343
  # list_split(data, 2, True) -> [[1, 2, 3, 4], [5, 6, 7, 8]] 将 data 平均分成 2个子list
371
344
  # list_split(data, 3, True) -> [[1, 2, 3], [4, 5, 6], [7, 8]] 将 data 平均分成 3个子list
372
345
 
373
- # 检查参数是否正确
374
- if not check_arguments([(data, list, "data"), (number, int, "number")]):
375
- return None
376
-
377
346
  try:
378
347
 
379
348
  # 要将列表平均分成 n 个子列表
@@ -384,9 +353,7 @@ def list_split(data: list, number: int, equally: bool = False) -> list | None:
384
353
 
385
354
  # 将列表按每 n 个元素为一个列表进行分割
386
355
  it = iter(data)
387
- return [
388
- list(islice(it, number)) for _ in range((len(data) + number - 1) // number)
389
- ]
356
+ return [list(islice(it, number)) for _ in range((len(data) + number - 1) // number)]
390
357
 
391
358
  except Exception as e:
392
359
  logger.exception(e)
@@ -396,12 +363,6 @@ def list_split(data: list, number: int, equally: bool = False) -> list | None:
396
363
  def list_print_by_step(data: list, step: int, separator: str = " ") -> bool:
397
364
  """根据 步长 和 分隔符 有规律的打印列表中的数据"""
398
365
 
399
- # 检查参数是否正确
400
- if not check_arguments(
401
- [(data, list, "data"), (step, int, "step"), (separator, str, "separator")]
402
- ):
403
- return False
404
-
405
366
  try:
406
367
 
407
368
  # 打印
@@ -789,9 +750,7 @@ def datetime_now(**kwargs) -> datetime | None:
789
750
  return None
790
751
 
791
752
 
792
- def datetime_offset(
793
- datetime_instance: datetime | None = None, **kwargs
794
- ) -> datetime | None:
753
+ def datetime_offset(datetime_instance: datetime | None = None, **kwargs) -> datetime | None:
795
754
  """
796
755
  获取 '向前或向后特定日期时间' 的日期和时间
797
756
 
@@ -812,9 +771,7 @@ def datetime_offset(
812
771
  return None
813
772
 
814
773
 
815
- def datetime_to_string(
816
- datetime_instance: datetime, string_format: str = "%Y-%m-%d %H:%M:%S"
817
- ) -> str | None:
774
+ def datetime_to_string(datetime_instance: datetime, string_format: str = "%Y-%m-%d %H:%M:%S") -> str | None:
818
775
  """'日期时间'转换为'字符串'"""
819
776
  try:
820
777
  if not isTrue(datetime_instance, datetime):
@@ -834,19 +791,13 @@ def datetime_to_timestamp(datetime_instance: datetime, utc: bool = False) -> int
834
791
  try:
835
792
  if not isTrue(datetime_instance, datetime):
836
793
  return None
837
- return (
838
- int(datetime_instance.replace(tzinfo=timezone.utc).timestamp())
839
- if utc is True
840
- else int(datetime_instance.timestamp())
841
- )
794
+ return int(datetime_instance.replace(tzinfo=timezone.utc).timestamp()) if utc is True else int(datetime_instance.timestamp())
842
795
  except Exception as e:
843
796
  logger.exception(e)
844
797
  return None
845
798
 
846
799
 
847
- def datetime_local_to_timezone(
848
- datetime_instance: datetime, tz: timezone = timezone.utc
849
- ) -> datetime | None:
800
+ def datetime_local_to_timezone(datetime_instance: datetime, tz: timezone = timezone.utc) -> datetime | None:
850
801
  """
851
802
  Local datetime to TimeZone datetime(默认转换为 UTC datetime)
852
803
  replace(tzinfo=None) 移除结尾的时区信息
@@ -854,9 +805,7 @@ def datetime_local_to_timezone(
854
805
  try:
855
806
  if not isTrue(datetime_instance, datetime):
856
807
  return None
857
- return (datetime.fromtimestamp(datetime_instance.timestamp(), tz=tz)).replace(
858
- tzinfo=None
859
- )
808
+ return (datetime.fromtimestamp(datetime_instance.timestamp(), tz=tz)).replace(tzinfo=None)
860
809
  except Exception as e:
861
810
  logger.exception(e)
862
811
  return None
@@ -873,20 +822,14 @@ def datetime_utc_to_timezone(
873
822
  try:
874
823
  if not isTrue(datetime_instance, datetime):
875
824
  return None
876
- return (
877
- datetime_instance.replace(tzinfo=timezone.utc)
878
- .astimezone(tz)
879
- .replace(tzinfo=None)
880
- )
825
+ return datetime_instance.replace(tzinfo=timezone.utc).astimezone(tz).replace(tzinfo=None)
881
826
 
882
827
  except Exception as e:
883
828
  logger.exception(e)
884
829
  return None
885
830
 
886
831
 
887
- def timestamp_to_datetime(
888
- timestamp: int, tz: timezone = timezone.utc
889
- ) -> datetime | None:
832
+ def timestamp_to_datetime(timestamp: int, tz: timezone = timezone.utc) -> datetime | None:
890
833
  """Unix Timestamp 转换为 Datatime"""
891
834
  try:
892
835
  if not isTrue(timestamp, int):
@@ -897,9 +840,7 @@ def timestamp_to_datetime(
897
840
  return None
898
841
 
899
842
 
900
- def datetime_string_to_datetime(
901
- datetime_string: str, datetime_format: str = "%Y-%m-%d %H:%M:%S"
902
- ) -> datetime | None:
843
+ def datetime_string_to_datetime(datetime_string: str, datetime_format: str = "%Y-%m-%d %H:%M:%S") -> datetime | None:
903
844
  """datetime string to datetime"""
904
845
  try:
905
846
  if not isTrue(datetime_string, str):
@@ -910,9 +851,7 @@ def datetime_string_to_datetime(
910
851
  return None
911
852
 
912
853
 
913
- def datetime_string_to_timestamp(
914
- datetime_string: str, datetime_format: str = "%Y-%m-%d %H:%M:%S"
915
- ) -> int | None:
854
+ def datetime_string_to_timestamp(datetime_string: str, datetime_format: str = "%Y-%m-%d %H:%M:%S") -> int | None:
916
855
  """datetime string to timestamp"""
917
856
  try:
918
857
  if not isTrue(datetime_string, str):
@@ -972,11 +911,7 @@ def shell(
972
911
 
973
912
  # 构造命令
974
913
  if isfile:
975
- args = (
976
- [sh_shell, command]
977
- if sh_option is None
978
- else [sh_shell, sh_option, command]
979
- )
914
+ args = [sh_shell, command] if sh_option is None else [sh_shell, sh_option, command]
980
915
  else:
981
916
  sh_option = sh_option or "-c"
982
917
  args = [sh_shell, sh_option, command]
@@ -1158,25 +1093,15 @@ def processor(
1158
1093
 
1159
1094
  try:
1160
1095
 
1161
- # 检查参数
1162
- if not check_arguments([(process_data, list, "process_data")]):
1163
- return False
1164
-
1165
1096
  # 确保并行数不超过数据量
1166
1097
  process_num = min(len(process_data), process_num)
1167
- data_chunks = (
1168
- list_split(process_data, process_num, equally=True)
1169
- if process_num > 1
1170
- else [process_data]
1171
- )
1098
+ data_chunks = list_split(process_data, process_num, equally=True) if process_num > 1 else [process_data]
1172
1099
 
1173
1100
  if not data_chunks:
1174
1101
  logger.error("data chunks error")
1175
1102
  return False
1176
1103
 
1177
- logger.info(
1178
- f"Starting {'multi-threading' if thread else 'multi-processing'} with {process_num} workers..."
1179
- )
1104
+ logger.info(f"Starting {'multi-threading' if thread else 'multi-processing'} with {process_num} workers...")
1180
1105
 
1181
1106
  # 执行多线程或多进程任务
1182
1107
  pool = ThreadPoolExecutor if thread else ProcessPoolExecutor
@@ -1342,8 +1267,6 @@ def url_parse(
1342
1267
  """URL Parse"""
1343
1268
  # none_result = ParseResult(scheme='', netloc='', path='', params='', query='', fragment='')
1344
1269
  try:
1345
- if not check_arguments([(url, str, "url_parse -> url")]):
1346
- return None
1347
1270
  # 如果没有 scheme 的话, 字符串是不解析的. 所以, 如果没有 scheme, 就添加一个 scheme, 默认添加 http
1348
1271
  # if isTrue(url, str) and (url.find('://') == -1) and isTrue(scheme, str):
1349
1272
  # url = f'{scheme}://{url}'
@@ -1388,15 +1311,6 @@ def markdown_to_html(markdown_file: str, html_file: str, title: str) -> bool:
1388
1311
 
1389
1312
  logger.info(f"{info} [开始]")
1390
1313
 
1391
- if not check_arguments(
1392
- [
1393
- (markdown_file, str, "markdown_to_html -> markdown_file"),
1394
- (html_file, str, "markdown_to_html -> html_file"),
1395
- (title, str, "markdown_to_html -> title"),
1396
- ]
1397
- ):
1398
- return False
1399
-
1400
1314
  # 读取 HTML模版 文件
1401
1315
  logger.info(f"{info} [读取 HTML模版 文件]")
1402
1316
  html_template_file = f"{current_dir(__file__)}/markdown_to_html.template"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ezKit
3
- Version: 1.12.1
3
+ Version: 1.12.2
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -3,20 +3,20 @@ ezKit/_file.py,sha256=0qRZhwYuagTgTGrhm-tzAMvEQT4HTJA_xZKqF2bo0ho,1207
3
3
  ezKit/bottle.py,sha256=43h4v1kzz6qrLvCt5IMN0H-gFtaT0koG9wETqteXsps,181666
4
4
  ezKit/bottle_extensions.py,sha256=27rogmfK7mL2qUSjXH79IMGZbCVULtYEikql_N9O6Zs,1165
5
5
  ezKit/cipher.py,sha256=7jBarRH7ukSYzkz-Anl8B8JzluhnRz4CLHidPRRj_cg,2939
6
- ezKit/database.py,sha256=6mfH--zRk2xwjlaqfxEWCeX-9HczMYk2dSnsRkjzpFk,12502
6
+ ezKit/database.py,sha256=InFkXoh9eNLQG-y5EGJ1nhiUjZfAQ4XAblGLQnGZXZE,12165
7
7
  ezKit/dockerhub.py,sha256=j-wQO-71BsOgExHZhYynuy2k_hCX3on-vg0TH7QCit4,1996
8
8
  ezKit/http.py,sha256=zhNxJF-x91UqGncXWxVXnhZVpFo_wmmpGnMXVT11y9E,1832
9
9
  ezKit/markdown_to_html.template,sha256=21G2sSVGJn6aJvHd0NN4zY5YiDteKe4UtW36AzBwSdk,22274
10
10
  ezKit/mongo.py,sha256=vsRCjJ2uWbNp-1bnGKICPohNYx25El8XnHp10o-lsM4,2397
11
- ezKit/qywx.py,sha256=Nc4HTzWia6PsngUcoxJa8FX6-gzAo3XIqBC2IFTrbjA,10797
11
+ ezKit/qywx.py,sha256=3SMm63xJw7Yrj67rvvHIH0ot5PbRHtohShqXLcH0BF0,10325
12
12
  ezKit/redis.py,sha256=leAre527XDBmA_FsjlqQ2_JT1eqwM9uvpYid1Ir1Va4,1972
13
13
  ezKit/sendemail.py,sha256=xqlFyRp96zggSN3eF3fCBXi0WMwGbOZxwDWkpQMCn9I,7412
14
14
  ezKit/token.py,sha256=Ac-i9xfq4TqpGyfCzakjrh4NYzxHiN2sCQrMk1tzVi8,1716
15
- ezKit/utils.py,sha256=wyh3lNTG2fJ-a-lszNZUoSluEC5V8Y9cs1JiAVI6D_A,44243
15
+ ezKit/utils.py,sha256=VyAw2yEs15VER9RCpMgskx1l0zrSpRlV34X___eOia0,42416
16
16
  ezKit/xftp.py,sha256=-XQXyhMqeigT63P6sXkSS7r4GROXyqqlkzKxITLWG-g,8278
17
17
  ezKit/zabbix.py,sha256=PkMnfu7mcuotwwIIsHaC9FsNg-gap6hD1xvm0AwSL1Y,33777
18
- ezkit-1.12.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
19
- ezkit-1.12.1.dist-info/METADATA,sha256=tNwfMN1cWo0bSyTv7WCBubgTscvf7f9HLDeJi74e6OM,316
20
- ezkit-1.12.1.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
21
- ezkit-1.12.1.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
22
- ezkit-1.12.1.dist-info/RECORD,,
18
+ ezkit-1.12.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
19
+ ezkit-1.12.2.dist-info/METADATA,sha256=yrZHrtCA_1Nhn0-iAshHHl18yDLh0SvBpnkIGqTnnSw,316
20
+ ezkit-1.12.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
21
+ ezkit-1.12.2.dist-info/top_level.txt,sha256=aYLB_1WODsqNTsTFWcKP-BN0KCTKcV-HZJ4zlHkCFw8,6
22
+ ezkit-1.12.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5