fix build exe error

This commit is contained in:
xaoyaoo committed 2024-08-17 13:51:44 +08:00
1 parent 33da8c4b78
commit 0c727dc34f
12 files changed
+56 -43

No files matched your search

+6 -4
View File
@@ -1,12 +1,10 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: __init__.py.py
# Description:
# Name: __init__.py
# Description: db
# Author: xaoyaoo
# Date: 2024/04/15
# -------------------------------------------------------------------------------
# import pandas as pd
from .utils import download_file, dat2img
from .dbFavorite import FavoriteHandler
@@ -82,3 +80,7 @@ class DBHandler(MicroHandler, MediaHandler, OpenIMContactHandler, PublicMsgHandl
count = {k: chat_count.get(k, 0) + chat_count1.get(k, 0) for k in
list(set(list(chat_count.keys()) + list(chat_count1.keys())))}
return count
__all__ = ["DBHandler", "FavoriteHandler", "MsgHandler", "MicroHandler", "MediaHandler",
"OpenIMContactHandler", "PublicMsgHandler", "OpenIMMediaHandler", "SnsHandler"]
-10
View File
@@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: __init__.py
# Description:
# Author: xaoyaoo
# Date: 2024/04/20
# -------------------------------------------------------------------------------
from .exportCSV import export_csv
from .exportJSON import export_json
from .exportHtml import export_html
-63
View File
@@ -1,63 +0,0 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: exportCSV.py
# Description:
# Author: xaoyaoo
# Date: 2024/04/20
# -------------------------------------------------------------------------------
import csv
import json
import os
from ..__init__ import DBHandler
def export_csv(wxid, outpath, db_config, my_wxid="我", page_size=5000):
if not os.path.exists(outpath):
outpath = os.path.join(os.getcwd(), "export" + os.sep + wxid)
if not os.path.exists(outpath):
os.makedirs(outpath)
db = DBHandler(db_config, my_wxid)
count = db.get_msgs_count(wxid)
chatCount = count.get(wxid, 0)
if chatCount == 0:
return False, "没有聊天记录"
if page_size > chatCount:
page_size = chatCount + 1
users = {}
for i in range(0, chatCount, page_size):
start_index = i
data, users_t = db.get_msg_list(wxid, start_index, page_size)
users.update(users_t)
if len(data) == 0:
return False, "没有聊天记录"
save_path = os.path.join(outpath, f"{wxid}_{i}_{i + page_size}.csv")
with open(save_path, "w", encoding="utf-8", newline='') as f:
csv_writer = csv.writer(f, quoting=csv.QUOTE_MINIMAL)
csv_writer.writerow(["id", "MsgSvrID", "type_name", "is_sender", "talker", "room_name", "msg", "src",
"CreateTime"])
for row in data:
id = row.get("id", "")
MsgSvrID = row.get("MsgSvrID", "")
type_name = row.get("type_name", "")
is_sender = row.get("is_sender", "")
talker = row.get("talker", "")
room_name = row.get("room_name", "")
msg = row.get("msg", "")
src = row.get("src", "")
CreateTime = row.get("CreateTime", "")
csv_writer.writerow([id, MsgSvrID, type_name, is_sender, talker, room_name, msg, src, CreateTime])
with open(os.path.join(outpath, "users.json"), "w", encoding="utf-8") as f:
json.dump(users, f, ensure_ascii=False, indent=4)
return True, f"导出成功: {outpath}"
if __name__ == '__main__':
pass
-46
View File
@@ -1,46 +0,0 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: exportCSV.py
# Description:
# Author: xaoyaoo
# Date: 2024/04/20
# -------------------------------------------------------------------------------
import json
import os
from ..__init__ import DBHandler
def export_html(wxid, outpath, db_config, my_wxid="我"):
if not os.path.exists(outpath):
outpath = os.path.join(os.getcwd(), "export" + os.sep + wxid)
if not os.path.exists(outpath):
os.makedirs(outpath)
db = DBHandler(db_config, my_wxid)
count = db.get_msgs_count(wxid)
chatCount = count.get(wxid, 0)
if chatCount == 0:
return False, "没有聊天记录"
msgs, users = db.get_msgs(wxid, 0, chatCount + 1)
if len(msgs) == 0:
return False, "没有聊天记录"
data_js = (
"localStorage.setItem('isUseLocalData', 't') // 't' : 'f' \n"
f"const local_msg_count = {chatCount}\n"
f"const local_mywxid = '{my_wxid}' \n"
f"const local_user_list = {json.dumps(users, ensure_ascii=False, indent=None )} \n"
f"const local_msg_list = {json.dumps(msgs, ensure_ascii=False, indent=None )} \n"
)
save_path = os.path.join(outpath, f"data.js")
with open(save_path, "w", encoding="utf-8") as f:
f.write(data_js)
return True, f"导出成功: {outpath}"
if __name__ == '__main__':
pass
-43
View File
@@ -1,43 +0,0 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: exportCSV.py
# Description:
# Author: xaoyaoo
# Date: 2024/04/20
# -------------------------------------------------------------------------------
import json
import os
from ..__init__ import DBHandler
def export_json(wxid, outpath, db_config, my_wxid="我", indent=4):
if not os.path.exists(outpath):
outpath = os.path.join(os.getcwd(), "export" + os.sep + wxid)
if not os.path.exists(outpath):
os.makedirs(outpath)
db = DBHandler(db_config, my_wxid)
count = db.get_msgs_count(wxid)
chatCount = count.get(wxid, 0)
if chatCount == 0:
return False, "没有聊天记录"
users = {}
page_size = chatCount + 1
for i in range(0, chatCount, page_size):
start_index = i
data, users_t = db.get_msgs(wxid, start_index, page_size)
users.update(users_t)
if len(data) == 0:
return False, "没有聊天记录"
save_path = os.path.join(outpath, f"{wxid}_{i}_{i + page_size}.json")
with open(save_path, "w", encoding="utf-8") as f:
json.dump(data, f, ensure_ascii=False, indent=indent)
with open(os.path.join(outpath, "users.json"), "w", encoding="utf-8") as f:
json.dump(users, f, ensure_ascii=False, indent=indent)
return True, f"导出成功: {outpath}"
if __name__ == '__main__':
pass
+2 -2
View File
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: __init__.py.py
# Description:
# Description: db.utils
# Author: xaoyaoo
# Date: 2024/07/23
# -------------------------------------------------------------------------------
@@ -10,4 +10,4 @@ from .common_utils import timestamp2str, xml2dict, silk2audio, bytes2str, get_md
type_converter, match_BytesExtra, db_error, download_file, dat2img
__all__ = ["db_loger", "timestamp2str", "xml2dict", "silk2audio", "bytes2str", "get_md5", "name2typeid", "typeid2name",
"type_converter", "match_BytesExtra", "db_error", "download_file", "dat2img"]
"type_converter", "match_BytesExtra", "db_error", "download_file", "dat2img"]