gomyck-tools 1.0.0__py3-none-any.whl → 1.4.7__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.
- ctools/__init__.py +21 -0
- ctools/ai/__init__.py +4 -0
- ctools/ai/llm_chat.py +184 -0
- ctools/ai/llm_client.py +163 -0
- ctools/ai/llm_exception.py +17 -0
- ctools/ai/mcp/__init__.py +4 -0
- ctools/ai/mcp/mcp_client.py +326 -0
- ctools/ai/tools/__init__.py +4 -0
- ctools/ai/tools/json_extract.py +202 -0
- ctools/ai/tools/quick_tools.py +149 -0
- ctools/ai/tools/think_process.py +11 -0
- ctools/ai/tools/tool_use_xml_parse.py +40 -0
- ctools/ai/tools/xml_extract.py +15 -0
- ctools/application.py +50 -47
- ctools/aspect.py +65 -0
- ctools/auto/__init__.py +4 -0
- ctools/{browser_element_tools.py → auto/browser_element.py} +18 -8
- ctools/{plan_area_tools.py → auto/plan_area.py} +5 -7
- ctools/{pty_tools.py → auto/pty_process.py} +6 -3
- ctools/{resource_bundle_tools.py → auto/resource_bundle.py} +4 -4
- ctools/{screenshot_tools.py → auto/screenshot.py} +7 -6
- ctools/{win_canvas.py → auto/win_canvas.py} +10 -4
- ctools/{win_control.py → auto/win_control.py} +14 -5
- ctools/call.py +34 -49
- ctools/cdate.py +84 -0
- ctools/cdebug.py +146 -0
- ctools/cid.py +20 -0
- ctools/cipher/__init__.py +4 -0
- ctools/{aes_tools.py → cipher/aes_util.py} +10 -0
- ctools/{b64.py → cipher/b64.py} +2 -0
- ctools/cipher/czip.py +133 -0
- ctools/cipher/rsa.py +75 -0
- ctools/{sign.py → cipher/sign.py} +2 -1
- ctools/{sm_tools.py → cipher/sm_util.py} +20 -4
- ctools/cjson.py +10 -10
- ctools/cron_lite.py +109 -97
- ctools/database/__init__.py +4 -0
- ctools/{database.py → database/database.py} +93 -26
- ctools/dict_wrapper.py +21 -0
- ctools/ex.py +4 -0
- ctools/geo/__init__.py +4 -0
- ctools/geo/coord_trans.py +127 -0
- ctools/geo/douglas_rarefy.py +139 -0
- ctools/metrics.py +56 -63
- ctools/office/__init__.py +4 -0
- ctools/office/cword.py +30 -0
- ctools/{word_fill.py → office/word_fill.py} +3 -6
- ctools/patch.py +88 -0
- ctools/{work_path.py → path_info.py} +34 -2
- ctools/pkg/__init__.py +4 -0
- ctools/pkg/dynamic_imp.py +38 -0
- ctools/pools/__init__.py +4 -0
- ctools/pools/process_pool.py +41 -0
- ctools/{thread_pool.py → pools/thread_pool.py} +13 -4
- ctools/similar.py +25 -0
- ctools/stream/__init__.py +4 -0
- ctools/stream/ckafka.py +164 -0
- ctools/stream/credis.py +127 -0
- ctools/{mqtt_utils.py → stream/mqtt_utils.py} +20 -12
- ctools/sys_info.py +36 -13
- ctools/sys_log.py +46 -27
- ctools/util/__init__.py +4 -0
- ctools/util/cftp.py +76 -0
- ctools/util/cklock.py +118 -0
- ctools/util/config_util.py +52 -0
- ctools/util/env_config.py +63 -0
- ctools/{html_soup.py → util/html_soup.py} +0 -7
- ctools/{http_utils.py → util/http_util.py} +4 -2
- ctools/{images_tools.py → util/image_process.py} +10 -1
- ctools/util/jb_cut.py +54 -0
- ctools/{id_worker_tools.py → util/snow_id.py} +8 -23
- ctools/web/__init__.py +4 -0
- ctools/web/aio_web_server.py +186 -0
- ctools/web/api_result.py +56 -0
- ctools/web/bottle_web_base.py +239 -0
- ctools/web/bottle_webserver.py +191 -0
- ctools/web/bottle_websocket.py +79 -0
- ctools/web/ctoken.py +103 -0
- ctools/{download_tools.py → web/download_util.py} +14 -12
- ctools/web/params_util.py +46 -0
- ctools/{upload_tools.py → web/upload_util.py} +3 -2
- gomyck_tools-1.4.7.dist-info/METADATA +70 -0
- gomyck_tools-1.4.7.dist-info/RECORD +88 -0
- {gomyck_tools-1.0.0.dist-info → gomyck_tools-1.4.7.dist-info}/WHEEL +1 -1
- gomyck_tools-1.4.7.dist-info/licenses/LICENSE +13 -0
- ctools/bashPath.py +0 -13
- ctools/bottle_server.py +0 -49
- ctools/console.py +0 -55
- ctools/date_utils.py +0 -44
- ctools/enums.py +0 -4
- ctools/excelOpt.py +0 -36
- ctools/imgDialog.py +0 -44
- ctools/license.py +0 -37
- ctools/log.py +0 -28
- ctools/mvc.py +0 -56
- ctools/obj.py +0 -20
- ctools/pacth.py +0 -73
- ctools/ssh.py +0 -9
- ctools/strDiff.py +0 -20
- ctools/string_tools.py +0 -101
- ctools/token_tools.py +0 -13
- ctools/wordFill.py +0 -24
- gomyck_tools-1.0.0.dist-info/METADATA +0 -20
- gomyck_tools-1.0.0.dist-info/RECORD +0 -54
- /ctools/{word_fill_entity.py → office/word_fill_entity.py} +0 -0
- /ctools/{compile_tools.py → util/compile_util.py} +0 -0
- {gomyck_tools-1.0.0.dist-info → gomyck_tools-1.4.7.dist-info}/top_level.txt +0 -0
ctools/excelOpt.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
from openpyxl import load_workbook
|
|
2
|
-
from openpyxl.worksheet.datavalidation import DataValidation
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class excelUtil:
|
|
6
|
-
wb = None
|
|
7
|
-
sourcePath = None
|
|
8
|
-
savePath = None
|
|
9
|
-
|
|
10
|
-
def __init__(self, path, save_path):
|
|
11
|
-
# 创建一个 Workbook 对象
|
|
12
|
-
self.wb = load_workbook(path)
|
|
13
|
-
# 在 Workbook 中创建一个 Worksheet 对象
|
|
14
|
-
self.ws = self.wb.active
|
|
15
|
-
self.sourcePath = path
|
|
16
|
-
self.savePath = save_path
|
|
17
|
-
|
|
18
|
-
def makeDropData(self, col, drop_data):
|
|
19
|
-
# 定义下拉框的数据
|
|
20
|
-
dropdown_items = drop_data
|
|
21
|
-
# 将下拉框数据转换成字符串
|
|
22
|
-
dropdown_items_str = ','.join(dropdown_items)
|
|
23
|
-
# 在第一列中添加下拉框
|
|
24
|
-
dropdown_col = col
|
|
25
|
-
dropdown_start_row = 2
|
|
26
|
-
dropdown_end_row = 200
|
|
27
|
-
# 配置下拉框参数
|
|
28
|
-
dropdown = DataValidation(type="list", formula1=f'"{dropdown_items_str}"', allow_blank=True)
|
|
29
|
-
# 添加下拉框到指定的单元格区域
|
|
30
|
-
dropdown_range = f"{dropdown_col}{dropdown_start_row}:{dropdown_col}{dropdown_end_row}"
|
|
31
|
-
self.ws.add_data_validation(dropdown)
|
|
32
|
-
dropdown.add(dropdown_range)
|
|
33
|
-
|
|
34
|
-
def save(self):
|
|
35
|
-
# 保存工作簿
|
|
36
|
-
self.wb.save(self.savePath)
|
ctools/imgDialog.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import tkinter
|
|
2
|
-
from tkinter import ttk
|
|
3
|
-
import tkinter as tk
|
|
4
|
-
import requests
|
|
5
|
-
from PIL import Image, ImageTk
|
|
6
|
-
from io import BytesIO
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def showImageTip(root, title, imagePath, tips):
|
|
10
|
-
# 创建一个Tk对象
|
|
11
|
-
if root:
|
|
12
|
-
window = root
|
|
13
|
-
else:
|
|
14
|
-
window = tk.Tk()
|
|
15
|
-
# 设置窗口大小和位置
|
|
16
|
-
win_width = 400
|
|
17
|
-
win_height = 480
|
|
18
|
-
screen_width = window.winfo_screenwidth()
|
|
19
|
-
screen_height = window.winfo_screenheight()
|
|
20
|
-
x = int((screen_width - win_width) / 2)
|
|
21
|
-
y = int((screen_height - win_height) / 2)
|
|
22
|
-
window.geometry("{}x{}+{}+{}".format(win_width, win_height, x, y))
|
|
23
|
-
|
|
24
|
-
# 设置窗口大小和标题
|
|
25
|
-
window.title(title)
|
|
26
|
-
|
|
27
|
-
# 创建一个Label控件用于显示图片
|
|
28
|
-
resp = requests.get(imagePath)
|
|
29
|
-
image = Image.open(BytesIO(resp.content)) # 替换你自己的图片路径
|
|
30
|
-
image = image.resize((400, 400))
|
|
31
|
-
photo = ImageTk.PhotoImage(image)
|
|
32
|
-
label1 = ttk.Label(window, image=photo)
|
|
33
|
-
label1.pack(side=tkinter.TOP)
|
|
34
|
-
|
|
35
|
-
# 创建一个Label控件用于显示提示文字
|
|
36
|
-
label2 = ttk.Label(window, text=tips, font=("Arial Bold", 16))
|
|
37
|
-
label2.config(anchor='center', justify='center')
|
|
38
|
-
label2.pack(side=tkinter.BOTTOM)
|
|
39
|
-
# 显示窗口
|
|
40
|
-
window.mainloop()
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if __name__ == '__main__':
|
|
44
|
-
showImageTip(root=None, title='在线授权', imagePath='https://blog.gomyck.com/img/pay-img/wechatPay2Me.jpg', tips='{}\n授权已失效,请联系微信:\n{}'.format(123, 123))
|
ctools/license.py
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import base64
|
|
2
|
-
|
|
3
|
-
from Crypto.Cipher import PKCS1_OAEP
|
|
4
|
-
from Crypto.PublicKey import RSA
|
|
5
|
-
|
|
6
|
-
from ctools import work_path, cjson
|
|
7
|
-
|
|
8
|
-
ENCRYPT_CHUNK_SIZE = 245
|
|
9
|
-
decrypt_CHUNK_SIZE = 512
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# 加密函数
|
|
13
|
-
def encrypt(msg, public_key):
|
|
14
|
-
parts = b''
|
|
15
|
-
private_key = RSA.import_key(public_key)
|
|
16
|
-
cipher = PKCS1_OAEP.new(private_key)
|
|
17
|
-
for i in range(0, len(msg), ENCRYPT_CHUNK_SIZE):
|
|
18
|
-
parts += cipher.encrypt(msg[i:i + ENCRYPT_CHUNK_SIZE].encode())
|
|
19
|
-
encrypted_base64 = base64.b64encode(parts)
|
|
20
|
-
return encrypted_base64.decode()
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# 解密函数
|
|
24
|
-
def decrypt(msg, private_key):
|
|
25
|
-
parts = b''
|
|
26
|
-
public_key = RSA.import_key(private_key)
|
|
27
|
-
cipher = PKCS1_OAEP.new(public_key)
|
|
28
|
-
encrypted_bytes = base64.b64decode(msg)
|
|
29
|
-
for i in range(0, len(encrypted_bytes), decrypt_CHUNK_SIZE):
|
|
30
|
-
parts += cipher.decrypt(encrypted_bytes[i:i + decrypt_CHUNK_SIZE])
|
|
31
|
-
return parts.decode()
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def loadLicenseInfo(auth_code):
|
|
35
|
-
with open(work_path.get_app_path() + '/keys/license.key', 'r') as pri:
|
|
36
|
-
decrypt_message = decrypt(auth_code.strip(), pri.read())
|
|
37
|
-
return cjson.loads(decrypt_message)
|
ctools/log.py
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
import os
|
|
3
|
-
import time
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# 文件日志
|
|
7
|
-
def flog(base_work_path: str = './', log_level: int = logging.INFO, mixin: bool = False) -> logging:
|
|
8
|
-
try:
|
|
9
|
-
os.mkdir(base_work_path + ".logs")
|
|
10
|
-
except Exception:
|
|
11
|
-
pass
|
|
12
|
-
log_file = base_work_path + ".logs" + os.path.sep + "log-" + time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime(time.time())) + ".ck"
|
|
13
|
-
if mixin:
|
|
14
|
-
handlers = [logging.FileHandler(filename=log_file, encoding='utf-8'), logging.StreamHandler()]
|
|
15
|
-
else:
|
|
16
|
-
handlers = [logging.FileHandler(filename=log_file, encoding='utf-8')]
|
|
17
|
-
logging.basicConfig(level=log_level,
|
|
18
|
-
format='%(asctime)s-%(levelname)s-%(thread)d-%(funcName)s-%(lineno)d - %(message)s',
|
|
19
|
-
handlers=handlers)
|
|
20
|
-
return logging.getLogger("ck-flog")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# 控制台日志
|
|
24
|
-
def clog(log_level: int = logging.INFO) -> logging:
|
|
25
|
-
logging.basicConfig(level=log_level,
|
|
26
|
-
format='%(asctime)s-%(levelname)s-%(thread)d-%(funcName)s-%(lineno)d - %(message)s',
|
|
27
|
-
handlers=[logging.StreamHandler()])
|
|
28
|
-
return logging.getLogger("ck-clog")
|
ctools/mvc.py
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
from functools import wraps
|
|
2
|
-
|
|
3
|
-
from bottle import request
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class PageInfo:
|
|
7
|
-
def __init__(self, page_size, page_index):
|
|
8
|
-
self.page_size = page_size
|
|
9
|
-
self.page_index = page_index
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class FormDataParams:
|
|
13
|
-
def __init__(self, data, files):
|
|
14
|
-
self.data = data
|
|
15
|
-
self.files = files
|
|
16
|
-
|
|
17
|
-
class DictWrapper(dict):
|
|
18
|
-
def __getattr__(self, key):
|
|
19
|
-
return self.get(key)
|
|
20
|
-
|
|
21
|
-
def __setattr__(self, key, value):
|
|
22
|
-
self[key] = value
|
|
23
|
-
|
|
24
|
-
def parameter_handler():
|
|
25
|
-
def return_func(func):
|
|
26
|
-
@wraps(func)
|
|
27
|
-
def decorated(*args, **kwargs):
|
|
28
|
-
if request.method == 'GET':
|
|
29
|
-
queryStr = request.query.decode('utf-8')
|
|
30
|
-
pageInfo = PageInfo(
|
|
31
|
-
page_size=10 if request.headers.get('page_size') is None else int(request.headers.get('page_size')),
|
|
32
|
-
page_index=1 if request.headers.get('page_index') is None else int(request.headers.get('page_index'))
|
|
33
|
-
)
|
|
34
|
-
try:
|
|
35
|
-
return func(params=queryStr, *args, **kwargs)
|
|
36
|
-
except TypeError:
|
|
37
|
-
return func(params=queryStr, pageInfo=pageInfo, *args, **kwargs)
|
|
38
|
-
elif request.method == 'POST':
|
|
39
|
-
content_type = request.get_header('content-type')
|
|
40
|
-
if content_type == 'application/json':
|
|
41
|
-
params = request.json
|
|
42
|
-
return func(params=DictWrapper(params), *args, **kwargs)
|
|
43
|
-
elif content_type and 'multipart/form-data' in content_type:
|
|
44
|
-
form_data = request.forms.decode()
|
|
45
|
-
form_files = request.files.decode()
|
|
46
|
-
params = FormDataParams(data=DictWrapper(form_data), files=form_files)
|
|
47
|
-
return func(params=params, *args, **kwargs)
|
|
48
|
-
else:
|
|
49
|
-
params = request.query.decode('utf-8')
|
|
50
|
-
return func(params=params, *args, **kwargs)
|
|
51
|
-
else:
|
|
52
|
-
return func(*args, **kwargs)
|
|
53
|
-
|
|
54
|
-
return decorated
|
|
55
|
-
|
|
56
|
-
return return_func
|
ctools/obj.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
def isNull(param) -> bool:
|
|
3
|
-
if type(param) == str:
|
|
4
|
-
return param == ''
|
|
5
|
-
elif type(param) == list:
|
|
6
|
-
return len(param) == 0
|
|
7
|
-
elif type(param) == dict:
|
|
8
|
-
return len(param) == 0
|
|
9
|
-
elif type(param) == int:
|
|
10
|
-
return param == 0
|
|
11
|
-
elif type(param) == float:
|
|
12
|
-
return param == 0.0
|
|
13
|
-
elif type(param) == bool:
|
|
14
|
-
return param == False
|
|
15
|
-
else:
|
|
16
|
-
return param is None
|
|
17
|
-
|
|
18
|
-
def isNotNull(param) -> bool:
|
|
19
|
-
return not isNull(param)
|
|
20
|
-
|
ctools/pacth.py
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import shutil
|
|
3
|
-
|
|
4
|
-
from sqlalchemy.sql import text
|
|
5
|
-
|
|
6
|
-
from business.persistent import database
|
|
7
|
-
|
|
8
|
-
class Patch:
|
|
9
|
-
|
|
10
|
-
def __init__(self, oldVersion, newVersion, pythonPath, playwrightPath, driverPath) -> None:
|
|
11
|
-
super().__init__()
|
|
12
|
-
self.oldV = oldVersion[len('V'):].replace('.', '').replace('-snapshot', '')
|
|
13
|
-
self.currentV = newVersion[len('V'):].replace('.', '').replace('-snapshot', '')
|
|
14
|
-
self.snapshot = '-snapshot' in newVersion or '-snapshot' in oldVersion
|
|
15
|
-
self.pythonPath = pythonPath
|
|
16
|
-
self.playwrightPath = playwrightPath
|
|
17
|
-
self.driverPath = driverPath
|
|
18
|
-
self.deleteSDK, self.deleteHPL, self.deleteDriver = False, False, False
|
|
19
|
-
|
|
20
|
-
def apply_patch(self):
|
|
21
|
-
patch_methods = [method for method in dir(self) if callable(getattr(self, method)) and method.startswith('patch_V')]
|
|
22
|
-
patch_methods.sort(key=lambda x: int(x[len('patch_V'):]))
|
|
23
|
-
max_method_name = patch_methods[-1]
|
|
24
|
-
exec_max_method = False
|
|
25
|
-
for method_name in patch_methods:
|
|
26
|
-
slVersion = method_name[len('patch_V'):]
|
|
27
|
-
if int(self.currentV) > int(slVersion) >= int(self.oldV):
|
|
28
|
-
if max_method_name == method_name: exec_max_method = True
|
|
29
|
-
method = getattr(self, method_name)
|
|
30
|
-
print('start exec patch {}'.format(method_name))
|
|
31
|
-
method()
|
|
32
|
-
print('patch {} update success'.format(method_name))
|
|
33
|
-
if self.snapshot and not exec_max_method:
|
|
34
|
-
print('start exec snapshot patch {}'.format(max_method_name))
|
|
35
|
-
method = getattr(self, max_method_name)
|
|
36
|
-
method()
|
|
37
|
-
print('snapshot patch {} update success'.format(max_method_name))
|
|
38
|
-
|
|
39
|
-
def patch_V220(self):
|
|
40
|
-
pass
|
|
41
|
-
|
|
42
|
-
def run_sqls(self, sqls):
|
|
43
|
-
with database.get_session() as s:
|
|
44
|
-
for sql in sqls.split(";"):
|
|
45
|
-
try:
|
|
46
|
-
s.execute(text(sql.strip()))
|
|
47
|
-
s.commit()
|
|
48
|
-
except Exception as e:
|
|
49
|
-
print('结构升级错误, 请检查!!! {}'.format(e.__cause__))
|
|
50
|
-
|
|
51
|
-
def remove_sdk(self):
|
|
52
|
-
if self.deleteSDK: return
|
|
53
|
-
try:
|
|
54
|
-
self.deleteSDK = True
|
|
55
|
-
if os.path.exists(self.pythonPath): shutil.rmtree(self.pythonPath)
|
|
56
|
-
except Exception as e:
|
|
57
|
-
print('删除SDK错误: {}'.format(e))
|
|
58
|
-
|
|
59
|
-
def remove_hpl(self):
|
|
60
|
-
if self.deleteHPL: return
|
|
61
|
-
try:
|
|
62
|
-
self.deleteHPL = True
|
|
63
|
-
if os.path.exists(self.playwrightPath): shutil.rmtree(self.playwrightPath)
|
|
64
|
-
except Exception as e:
|
|
65
|
-
print('删除HPL错误: {}'.format(e))
|
|
66
|
-
|
|
67
|
-
def remove_driver(self):
|
|
68
|
-
if self.deleteDriver: return
|
|
69
|
-
try:
|
|
70
|
-
self.deleteDriver = True
|
|
71
|
-
if os.path.exists(self.driverPath): shutil.rmtree(self.driverPath)
|
|
72
|
-
except Exception as e:
|
|
73
|
-
print('删除Driver错误: {}'.format(e))
|
ctools/ssh.py
DELETED
ctools/strDiff.py
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# import difflib
|
|
2
|
-
#
|
|
3
|
-
# s1 = '12-23'
|
|
4
|
-
# s2 = '00-11'
|
|
5
|
-
# s3 = '2023-05-05 12:00:00-2023-05-06 23:00:00 剩余4'
|
|
6
|
-
#
|
|
7
|
-
# sm = difflib.SequenceMatcher(None, s1, s3)
|
|
8
|
-
#
|
|
9
|
-
# print(sm.ratio()) # 输出相似度得分
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
from fuzzywuzzy import fuzz
|
|
13
|
-
|
|
14
|
-
s1 = '12-23'
|
|
15
|
-
s2 = '00-11'
|
|
16
|
-
s3 = '2023-05-05 12:00:00-2023-05-06 23:00:00 剩余4'
|
|
17
|
-
s4 = '2023-04-28 00:00:00-2023-04-28 11:00:00 剩余12'
|
|
18
|
-
score = fuzz.ratio(s2, s4)
|
|
19
|
-
|
|
20
|
-
print(score) # 输出相似度得
|
ctools/string_tools.py
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import hashlib
|
|
2
|
-
import random
|
|
3
|
-
import uuid
|
|
4
|
-
from typing import Union
|
|
5
|
-
|
|
6
|
-
import chardet
|
|
7
|
-
|
|
8
|
-
from ctools.id_worker_tools import IdWorker
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def get_random_str(size: int = 10):
|
|
12
|
-
"""
|
|
13
|
-
根据长度获取随机字符串
|
|
14
|
-
:param size:
|
|
15
|
-
:return:
|
|
16
|
-
"""
|
|
17
|
-
return "".join(random.sample('abcdefghijklmnopqrstuvwxyz0123456789', size))
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def get_uuid():
|
|
21
|
-
return str(uuid.uuid1()).replace("-", "")
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def get_snowflake_id():
|
|
25
|
-
return IdWorker(1, 2, 0).get_id()
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def decode_bytes(bytes_str: Union[bytes, bytearray]):
|
|
29
|
-
res_str = ""
|
|
30
|
-
if bytes_str:
|
|
31
|
-
detect = chardet.detect(bytes_str)
|
|
32
|
-
if detect:
|
|
33
|
-
confidence = 0
|
|
34
|
-
chardet_error = False
|
|
35
|
-
try:
|
|
36
|
-
confidence = float(detect.get('confidence'))
|
|
37
|
-
res_str = bytes_str.decode(encoding=detect.get('encoding'))
|
|
38
|
-
except Exception:
|
|
39
|
-
chardet_error = True
|
|
40
|
-
|
|
41
|
-
try:
|
|
42
|
-
if confidence <= 0.95 or chardet_error:
|
|
43
|
-
encoding = "utf-8" if detect.get('encoding') == "utf-8" else "gbk"
|
|
44
|
-
res_str = bytes_str.decode(encoding=encoding)
|
|
45
|
-
except Exception:
|
|
46
|
-
res_str = str(bytes_str)
|
|
47
|
-
return res_str
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def check_sum(content: str):
|
|
51
|
-
try:
|
|
52
|
-
algorithm = hashlib.sha256()
|
|
53
|
-
algorithm.update(content.encode())
|
|
54
|
-
return algorithm.hexdigest()
|
|
55
|
-
except Exception:
|
|
56
|
-
return None
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
def is_list(v: str):
|
|
60
|
-
try:
|
|
61
|
-
list(v)
|
|
62
|
-
if v[0] == "[" and v[-1] == "]":
|
|
63
|
-
return True
|
|
64
|
-
else:
|
|
65
|
-
return False
|
|
66
|
-
except Exception:
|
|
67
|
-
return False
|
|
68
|
-
|
|
69
|
-
def is_digit(v: str):
|
|
70
|
-
try:
|
|
71
|
-
float(v)
|
|
72
|
-
return True
|
|
73
|
-
except Exception:
|
|
74
|
-
return False
|
|
75
|
-
|
|
76
|
-
def is_bool(v: str):
|
|
77
|
-
if v in ["False", "True"]:
|
|
78
|
-
return True
|
|
79
|
-
else:
|
|
80
|
-
return False
|
|
81
|
-
|
|
82
|
-
def is_obj(k: str):
|
|
83
|
-
if k in ['operate', 'pm_browser_sm_options', 'pw_context_sm_service']:
|
|
84
|
-
return True
|
|
85
|
-
else:
|
|
86
|
-
return False
|
|
87
|
-
|
|
88
|
-
def dict_to_params(obj: dict):
|
|
89
|
-
params = ""
|
|
90
|
-
for k, v in obj.items():
|
|
91
|
-
if k == 'varname':
|
|
92
|
-
continue
|
|
93
|
-
v = str(v)
|
|
94
|
-
if not is_list(v) and not is_digit(v) and not is_bool(v) and not is_obj(k):
|
|
95
|
-
if k == "path" and v[:4] != "http":
|
|
96
|
-
v = "r'%s'" % v
|
|
97
|
-
else:
|
|
98
|
-
v = "'%s'" % v
|
|
99
|
-
params += "%s=%s, " % (k, v)
|
|
100
|
-
params = params[:params.rfind(',')]
|
|
101
|
-
return params
|
ctools/token_tools.py
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from business.controller.base import GlobalState
|
|
2
|
-
from ctools import string_tools
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
def get_tmp_token():
|
|
6
|
-
tmp_token = string_tools.get_uuid()
|
|
7
|
-
GlobalState.tmp_token.append(tmp_token)
|
|
8
|
-
return tmp_token
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def remove_tmp_token(token: str):
|
|
12
|
-
if token in GlobalState.tmp_token:
|
|
13
|
-
GlobalState.tmp_token.remove(token)
|
ctools/wordFill.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# from docxtpl import DocxTemplate
|
|
2
|
-
#
|
|
3
|
-
# # tpl = DocxTemplate('/Users/haoyang/Desktop/xxx.docx')
|
|
4
|
-
# tpl = DocxTemplate('/Users/haoyang/Desktop/123.doc')
|
|
5
|
-
#
|
|
6
|
-
# # 设置好各标签需要填写的内容
|
|
7
|
-
# context = {'xxxx': '计算机科学与技术', 'cccc': '2022050513'}
|
|
8
|
-
# # 将标签内容填入模板中
|
|
9
|
-
# tpl.render(context)
|
|
10
|
-
# # 保存
|
|
11
|
-
# tpl.save('/Users/haoyang/Desktop/new_test2.docx')
|
|
12
|
-
|
|
13
|
-
from docx import Document
|
|
14
|
-
def merge_word_files(input_files, output_file):
|
|
15
|
-
merged_doc = Document()
|
|
16
|
-
for file in input_files:
|
|
17
|
-
doc = Document(file)
|
|
18
|
-
for element in doc.element.body:
|
|
19
|
-
merged_doc.element.body.append(element)
|
|
20
|
-
merged_doc.save(output_file)
|
|
21
|
-
# 示例用法
|
|
22
|
-
input_files = ["/Users/haoyang/Desktop/xxx.docx", "/Users/haoyang/Desktop/xxx 2.docx"]
|
|
23
|
-
output_file = "/Users/haoyang/Desktop/merged_file.docx"
|
|
24
|
-
merge_word_files(input_files, output_file)
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: gomyck-tools
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: A ctools for python development
|
|
5
|
-
Home-page: https://blog.gomyck.com
|
|
6
|
-
Author: gomyck
|
|
7
|
-
Author-email: hao474798383@163.com
|
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Requires-Python: >=3.8
|
|
12
|
-
Description-Content-Type: text/markdown
|
|
13
|
-
Requires-Dist: jieba ==0.42.1
|
|
14
|
-
Requires-Dist: jsonpickle ==3.2.2
|
|
15
|
-
Requires-Dist: SQLAlchemy ==2.0.32
|
|
16
|
-
Requires-Dist: paddlepaddle ==2.6.1
|
|
17
|
-
Requires-Dist: chardet ==5.2.0
|
|
18
|
-
Requires-Dist: psycopg2-binary ==2.9.9
|
|
19
|
-
|
|
20
|
-
this package is for python development
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
ctools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
ctools/aes_tools.py,sha256=ylUgyhlx7bNCTGrbWEZVwCObzYdJTQtwEc4ZMidL2Fo,563
|
|
3
|
-
ctools/application.py,sha256=WviU7p9GOqducbGW3XGkP7jCNKmraCh6JGSYBC33CQk,16008
|
|
4
|
-
ctools/b64.py,sha256=_BdhX3p3-MaSSlU2wivN5qPxQfacR3VRBr1WC456tU0,194
|
|
5
|
-
ctools/bashPath.py,sha256=BCN_EhYzqvwsxYso81omMNd3SbEociwSOyb9kLvu8V4,337
|
|
6
|
-
ctools/bottle_server.py,sha256=1FngczUlovRpS8HGx7_q2-jrnGmS0g2UUxbILaMmsR8,1482
|
|
7
|
-
ctools/browser_element_tools.py,sha256=tWNxUJ9m-hNTYtS0NRvmH9r5I-Qw55uKekwDYgt49bc,9951
|
|
8
|
-
ctools/call.py,sha256=v1QGKo8UeWDs1zASJSHUUuFkYZ5zb8Pzd0vEYzAi4d8,1545
|
|
9
|
-
ctools/cjson.py,sha256=n7Q3k5-1F30uIKRsRoizXdDTsIC-wAyt338B_FzktdE,1236
|
|
10
|
-
ctools/compile_tools.py,sha256=Nybh3vnkurIKnPnubdYzigjnzFu4GaTMKPvqFdibxmE,510
|
|
11
|
-
ctools/console.py,sha256=1VAq_-fSGgHKYv6Qe53kHaJL0-3NpFRUZljahbJPcfk,1807
|
|
12
|
-
ctools/cron_lite.py,sha256=ehayjzS9HHNc9ub9BY4aBJglXS01PJCGYvOrQyr3X8Y,7713
|
|
13
|
-
ctools/database.py,sha256=33MWjA536g3JltpQ_Xi8QfLjwiVWpe_prfvqEa1ZEMc,4983
|
|
14
|
-
ctools/date_utils.py,sha256=-xI2anEzAonOvYwVmM1hCnkuLKodZ8pb33dS3dRxEIc,865
|
|
15
|
-
ctools/download_tools.py,sha256=h12HGr2IaVvl8IDAvpDftHycSACI5V7HF0Yk9kV4bVY,1750
|
|
16
|
-
ctools/enums.py,sha256=QbHa3j7j4-BDdwaga5Y0nYfA2uNSVJDHumYdIZdKVkM,118
|
|
17
|
-
ctools/ex.py,sha256=vIkSWzHuNFslDFeBZCzCmbOefgLTEeScJp0vKeNm_P8,783
|
|
18
|
-
ctools/excelOpt.py,sha256=q3HLAb1JScTrMCvx_x-4WWnqKhyTEzQ-m5vtqFy8NZU,1138
|
|
19
|
-
ctools/html_soup.py,sha256=LabCo4yWI58fbFBPhunk3THWBf0BbHEWLgwyvSpTGR4,1903
|
|
20
|
-
ctools/http_utils.py,sha256=5tW_MV8JUfA4hMLh4cup0kyBsiiTK1l6sgdHVdc8p5g,614
|
|
21
|
-
ctools/id_worker_tools.py,sha256=xtfxpL8q4hHLT02JFx2jVXEXpasHq44ZFsOhO580JmE,2357
|
|
22
|
-
ctools/images_tools.py,sha256=hjYu-3tpjZ96yMqAM3XrFSUEOiUcyGk4DbAsz2_OeIs,669
|
|
23
|
-
ctools/imgDialog.py,sha256=DSq5cFofyP_el80AFConht_ZYRqxZhIz4CWjqBlJ0cw,1385
|
|
24
|
-
ctools/license.py,sha256=0Kh7lXL7LD1PQqyijHajFL0GbmZGNB88PA2WskbQn_s,1066
|
|
25
|
-
ctools/log.py,sha256=kLlT67by9kTV6UlFXuYPg5AkNnqFRZknoUqLGGIKj14,1097
|
|
26
|
-
ctools/metrics.py,sha256=wHRw1qBFqjDdRXWQQgIJdXUKQgocRlIoTsjNDA9t0SU,6288
|
|
27
|
-
ctools/mqtt_utils.py,sha256=9q_5CGvEhhvy8fZxaioguPSz8mvkdpCxnZ86GxjwTE0,10676
|
|
28
|
-
ctools/mvc.py,sha256=MgOaM7Jg_tUwVoBSzTgr12E3bX4-IQnIqBwDC-1BO08,1792
|
|
29
|
-
ctools/obj.py,sha256=GYS1B8NyjtUIh0HlK9r8avC2eGbK2SJac4C1CGnfGhI,479
|
|
30
|
-
ctools/pacth.py,sha256=D2bTpYZ05MvLJ9aPwsRPo3ze2jV-siKQ6s0zDUCg82E,2616
|
|
31
|
-
ctools/plan_area_tools.py,sha256=yyFWIAvVe_p1e8HugR_h7r_W7dW9dQ-CGtgMz_Hz5QQ,3396
|
|
32
|
-
ctools/pty_tools.py,sha256=H-j2xlZ5A0Q75NMop1ghCs2C0BZPKOPjilRujnh5Ngg,1602
|
|
33
|
-
ctools/resource_bundle_tools.py,sha256=8zW1-aj6jAYFBCoyslz5bL-5916G6Aif1RUy_ObbiVU,3793
|
|
34
|
-
ctools/screenshot_tools.py,sha256=-DzWgguxTOTolzQXdZfUIHTOU3HNhp74fdomeSTBxKs,4538
|
|
35
|
-
ctools/sign.py,sha256=YOrON1SeLRPavPWtE3GonvWFVv1SGFjfjrEVJ3k4x6s,566
|
|
36
|
-
ctools/sm_tools.py,sha256=RwhTjuKw_TjaAJAui39wctzFFpbt79MQ3hjF0fhL638,1113
|
|
37
|
-
ctools/ssh.py,sha256=3Oo4Lf6UyX-F_u_c1icHHDNzvVDHMKiWIO1u7E22QkM,217
|
|
38
|
-
ctools/strDiff.py,sha256=QUtXOfsRLTFozH_zByqsC39JeuG3eZtrwGVeLyaHYUI,429
|
|
39
|
-
ctools/string_tools.py,sha256=qjFn47lM27ISAa2Q4OKO7WOBdhyWC5lLHbME-uSeICE,2142
|
|
40
|
-
ctools/sys_info.py,sha256=podW43pcn7z2f6FW2w1L9bU1HfeVjC3D34BdN_H6rf4,3625
|
|
41
|
-
ctools/sys_log.py,sha256=S-H8z3Gf2lZPu8KL-N6h5Y-bGGcg3BIVEiCDk1DV9eM,2192
|
|
42
|
-
ctools/thread_pool.py,sha256=1u7zOfXqrn426rC3knfk8TE1aDutDhvmsukP9NlGg68,795
|
|
43
|
-
ctools/token_tools.py,sha256=yFMAtdoGWAPQexqilX6mLER7h2_OxzIdcUL-LqZ-56o,316
|
|
44
|
-
ctools/upload_tools.py,sha256=sqe6K3ZWiyY58pFE5IO5mNaS1znnS7U4c4UqY8noED4,1068
|
|
45
|
-
ctools/win_canvas.py,sha256=PAxI4i1jalfree9d1YG4damjc2EzaHZrgHZCTgk2GiM,2530
|
|
46
|
-
ctools/win_control.py,sha256=zNu06wNCtOnfIg12LIMMy2hBb1rskVQ8QIZu9qx4CNY,3487
|
|
47
|
-
ctools/wordFill.py,sha256=dB1OLt6GLmWdkDV8H20VWbJmY4ggNNI8iHD1ocae2iM,875
|
|
48
|
-
ctools/word_fill.py,sha256=aIkzjAF2soSW6w2dO2CRZlveDcuIdr6v9DtyyyB8uxM,18216
|
|
49
|
-
ctools/word_fill_entity.py,sha256=eX3G0Gy16hfGpavQSEkCIoKDdTnNgRRJrFvKliETZK8,985
|
|
50
|
-
ctools/work_path.py,sha256=i4MTUobqNW2WMrT3mwEC_XYQ0_IhFmKoNpTX2W6A8Tc,1680
|
|
51
|
-
gomyck_tools-1.0.0.dist-info/METADATA,sha256=QMUSjOazj7W24mtjuwh79X11mgZ1ALWQy2r2d_TQrg4,636
|
|
52
|
-
gomyck_tools-1.0.0.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
|
|
53
|
-
gomyck_tools-1.0.0.dist-info/top_level.txt,sha256=-MiIH9FYRVKp1i5_SVRkaI-71WmF1sZSRrNWFU9ls3s,7
|
|
54
|
-
gomyck_tools-1.0.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|