Skip to content

Commit bb6f70e

Browse files
committed
* packing模块支持src目录下的packages
1 parent cbf3c2e commit bb6f70e

File tree

2 files changed

+73
-22
lines changed

2 files changed

+73
-22
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
### 更新日志
22

3-
4-
#### JadeV2.2.2 - 2024-05-09
5-
* 数据库操作支持int和Bool类型
3+
#### JadeV2.2.3 - 2024-05-09
4+
* packing模块支持src目录下的packages
65
---
76

8-
97
<details onclose>
108
<summary>查看更多更新日志</summary>
119

10+
#### JadeV2.2.2 - 2024-05-09
11+
* 数据库操作支持int和Bool类型
12+
---
13+
1214
#### JadeV2.2.1 - 2024-05-09
1315
* 解决传入多个feature id,加密狗不满足条件,程序不退出的bug
1416
---

jade/jade_packing.py

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import platform
1515
import subprocess
1616
import uuid
17-
17+
import re
1818

1919
def str_to_bool(str):
2020
if str == "False":
@@ -70,23 +70,53 @@ def get_import_content(f1, src_import, content, import_list):
7070
return edit
7171

7272

73-
def copyPy(args):
74-
new_src_path = CreateSavePath("new_src")
75-
try:
76-
if str_to_bool(args.is_qt) is False:
77-
src_path_list = ["src"]
78-
src_import_list = ["src."]
79-
else:
80-
src_path_list = ["src", "view", "view/customView", "controller"]
81-
src_import_list = ["src.", "view.", "view.customView.", "controller."]
82-
except:
83-
src_path_list = ["src"]
84-
src_import_list = ["src."]
85-
import_list = []
86-
for src_path in src_path_list:
87-
for file_name in os.listdir(src_path):
88-
if "py" in file_name and "init" not in file_name and os.path.isfile(os.path.join(src_path, file_name)):
89-
if file_name != "samplesMain.py":
73+
def writePyContent(args,src_path,new_src_path,src_path_list,src_import_list,import_list):
74+
for file_name in os.listdir(src_path):
75+
if os.path.isfile(os.path.join(src_path, file_name)):
76+
file_name_suffix = re.search(r"\.(\w+)$", file_name).group(1)
77+
if file_name_suffix == "py":
78+
if "__init__.py" == file_name :
79+
if src_path not in src_path_list :
80+
with open(os.path.join(new_src_path, GetLastDir(src_path)) + ".py", "wb") as f1:
81+
with open(os.path.join(src_path, file_name), "rb") as f:
82+
try:
83+
content_list = str(f.read(), encoding="utf-8").split("\n")
84+
except:
85+
pass
86+
for content in content_list:
87+
if "import" in content or ("from" in content and "import" in content):
88+
edit = False
89+
for src_import in src_import_list:
90+
if "from" in content:
91+
prefix_list = content.split("from")[1].split("import")[0].split(".")[
92+
:-1]
93+
prefix = ""
94+
if len(prefix_list) > 0:
95+
for text in prefix_list:
96+
prefix = prefix + text + "."
97+
if src_import in prefix.strip():
98+
f1.write(
99+
(content.replace(prefix.strip(), "") + '\n').encode("utf-8"))
100+
if content not in import_list and "#" not in content and \
101+
content[
102+
0] != " ":
103+
import_list.append(content)
104+
edit = True
105+
break
106+
if edit is False:
107+
f1.write((content + '\n').encode("utf-8"))
108+
if content not in import_list and "#" not in content and content[0] != " ":
109+
import_list.append(content)
110+
elif "JadeLog = JadeLogging" in content:
111+
if str_to_bool(args.use_jade_log):
112+
update_log = "\n JadeLog.INFO('{}-更新时间为:{}',True)\r".format(
113+
args.name + "V" + args.app_version, GetTimeStamp(), True)
114+
f1.write((content + update_log).encode("utf-8"))
115+
else:
116+
f1.write((content).encode("utf-8"))
117+
else:
118+
f1.write((content + "\n").encode("utf-8"))
119+
elif file_name != "samplesMain.py":
90120
with open(os.path.join(new_src_path, file_name), "wb") as f1:
91121
with open(os.path.join(src_path, file_name), "rb") as f:
92122
try:
@@ -165,6 +195,25 @@ def copyPy(args):
165195
f1.write((content + "\n").encode("utf-8"))
166196
else:
167197
f1.write((content + '\n').encode("utf-8"))
198+
else:
199+
if os.path.isdir( os.path.join(src_path, file_name)) and "pycache" not in file_name:
200+
writePyContent(args, os.path.join(src_path, file_name), new_src_path,src_path_list,src_import_list, import_list)
201+
202+
def copyPy(args):
203+
new_src_path = CreateSavePath("new_src")
204+
try:
205+
if str_to_bool(args.is_qt) is False:
206+
src_path_list = ["src"]
207+
src_import_list = ["src."]
208+
else:
209+
src_path_list = ["src", "view", "view/customView", "controller"]
210+
src_import_list = ["src.", "view.", "view.customView.", "controller."]
211+
except:
212+
src_path_list = ["src"]
213+
src_import_list = ["src."]
214+
import_list = []
215+
for src_path in src_path_list:
216+
writePyContent(args,src_path,new_src_path,src_path_list,src_import_list,import_list)
168217
if args.app_version:
169218
with open("new_src/samplesVersion.py","wb") as f:
170219
f.write('#!/usr/bin/env python\n'

0 commit comments

Comments
 (0)