ezKit 1.10.8__tar.gz → 1.11.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ezKit
3
- Version: 1.10.8
3
+ Version: 1.11.0
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -44,9 +44,9 @@ class Database():
44
44
  info = "Database connect test"
45
45
  try:
46
46
  logger.info(f"{info} ......")
47
- self.engine.connect()
48
- logger.success(f"{info} [success]")
49
- return True
47
+ with self.engine.connect() as _:
48
+ logger.success(f"{info} [success]")
49
+ return True
50
50
  except Exception as e:
51
51
  logger.error(f"{info} [failed]")
52
52
  logger.exception(e)
@@ -235,6 +235,30 @@ def division(
235
235
  # --------------------------------------------------------------------------------------------------
236
236
 
237
237
 
238
+ def format_float(number: float | int, index: int = 2, limit: int = 3) -> float | None:
239
+ """格式化浮点数"""
240
+
241
+ # 以两位和三位为例, 如果结果为假, 即: 0, 0.0, 0.00 等,保留小数点后的三位, 否则保留小数点后的两位.
242
+
243
+ # 检查参数
244
+ if not check_arguments([
245
+ (number, (float, int), "number"),
246
+ (index, int, "index"),
247
+ (limit, int, "limit")
248
+ ]):
249
+ return False
250
+
251
+ try:
252
+ rounded_float = round(number, index)
253
+ return rounded_float if bool(rounded_float) else round(number, limit)
254
+ except Exception as e:
255
+ logger.exception(e)
256
+ return None
257
+
258
+
259
+ # --------------------------------------------------------------------------------------------------
260
+
261
+
238
262
  def check_file_type(
239
263
  file_object: str,
240
264
  file_type: str
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ezKit
3
- Version: 1.10.8
3
+ Version: 1.11.0
4
4
  Summary: Easy Kit
5
5
  Author: septvean
6
6
  Author-email: septvean@gmail.com
@@ -3,7 +3,7 @@ from setuptools import find_packages, setup
3
3
 
4
4
  setup(
5
5
  name='ezKit',
6
- version='1.10.8',
6
+ version='1.11.0',
7
7
  author='septvean',
8
8
  author_email='septvean@gmail.com',
9
9
  description='Easy Kit',
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