ezKit 1.6.1__py3-none-any.whl → 1.7.0__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/cipher.py CHANGED
@@ -2,6 +2,7 @@
2
2
  https://docs.python.org/3.10/library/hashlib.html
3
3
  https://www.pycrypto.org/
4
4
  https://stackoverflow.com/a/21928790
5
+ pip install pycryptodome
5
6
  '''
6
7
  import base64
7
8
  import hashlib
ezKit/mongo.py CHANGED
@@ -1,3 +1,4 @@
1
+ """MongoDB"""
1
2
  from loguru import logger
2
3
  from pymongo import MongoClient
3
4
 
@@ -5,21 +6,19 @@ from . import utils
5
6
 
6
7
 
7
8
  class Mongo():
9
+ """MongoDB"""
8
10
 
9
11
  client = MongoClient()
10
12
 
11
- def __init__(self, mongo_url=None):
12
- ''' Initiation '''
13
- if mongo_url != None:
14
- self.client = MongoClient(mongo_url)
15
-
16
13
  def close(self):
14
+ """client close"""
17
15
  try:
18
16
  self.client.close()
19
17
  except Exception as e:
20
18
  logger.exception(e)
21
19
 
22
20
  def connect_test(self, debug: bool = False):
21
+ """client connect test"""
23
22
  info = 'MongoDB连接测试'
24
23
  try:
25
24
  logger.info(f'{info}[执行]')
@@ -28,19 +27,22 @@ class Mongo():
28
27
  return True
29
28
  except Exception as e:
30
29
  logger.error(f'{info}[失败]')
31
- logger.exception(e) if utils.v_true(debug, bool) else next
30
+ if utils.v_true(debug, bool):
31
+ logger.exception(e)
32
32
  return False
33
33
 
34
34
  def collection(self, database, name):
35
+ """client collection"""
35
36
  return self.client[database][name]
36
37
 
37
38
  def collection_insert(self, database, collection, data, drop=None):
39
+ """client collection insert"""
38
40
  db_collection = self.client[database][collection]
39
41
  info = '插入数据'
40
42
  try:
41
43
  logger.info(f'{info}[执行]')
42
44
  # 是否删除 collection
43
- if drop == True:
45
+ if drop is True:
44
46
  # 删除 collection
45
47
  db_collection.drop()
46
48
  # 插入数据