byzh-core 0.0.2.5__py3-none-any.whl → 0.0.2.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.
- byzh_core/B_os.py +13 -7
- byzh_core/Barchive/archive.py +8 -1
- byzh_core/Bconfig/config.py +2 -2
- byzh_core/Btable/auto_table.py +80 -4
- byzh_core/Bwriter/__init__.py +1 -3
- byzh_core/__init__.py +1 -1
- {byzh_core-0.0.2.5.dist-info → byzh_core-0.0.2.7.dist-info}/METADATA +1 -1
- {byzh_core-0.0.2.5.dist-info → byzh_core-0.0.2.7.dist-info}/RECORD +11 -16
- byzh_core/Bos/B_os.py +0 -35
- byzh_core/Bos/__init__.py +0 -4
- byzh_core/Bos/make.py +0 -38
- byzh_core/Bos/remove.py +0 -8
- byzh_core/Bwriter/globalwriter.py +0 -62
- {byzh_core-0.0.2.5.dist-info → byzh_core-0.0.2.7.dist-info}/LICENSE +0 -0
- {byzh_core-0.0.2.5.dist-info → byzh_core-0.0.2.7.dist-info}/WHEEL +0 -0
- {byzh_core-0.0.2.5.dist-info → byzh_core-0.0.2.7.dist-info}/top_level.txt +0 -0
byzh_core/B_os.py
CHANGED
@@ -58,29 +58,35 @@ def rm(path):
|
|
58
58
|
if os.path.isfile(path):
|
59
59
|
os.remove(path)
|
60
60
|
|
61
|
-
|
61
|
+
|
62
|
+
def get_dirpaths_in_dir(root_dir_path, exclude_dir=['__pycache__', '.git']):
|
62
63
|
result = []
|
63
64
|
for root, dirs, files in os.walk(root_dir_path):
|
65
|
+
for i, dir in enumerate(dirs):
|
66
|
+
if str(dir) in exclude_dir:
|
67
|
+
dirs.pop(i)
|
64
68
|
path = Path(root)
|
65
|
-
if path.name in unwanted_dirname:
|
66
|
-
continue
|
67
69
|
result.append(path)
|
68
70
|
|
69
71
|
result = result[1:]
|
70
72
|
|
71
73
|
return result
|
72
74
|
|
73
|
-
def get_filepaths_in_dir(root_dir_path,
|
75
|
+
def get_filepaths_in_dir(root_dir_path, exclude_name=[], exclude_suffix=['.pyc'], exclude_dir=['.git']):
|
74
76
|
file_paths = []
|
75
77
|
for root, dirs, files in os.walk(root_dir_path):
|
78
|
+
for i, dir in enumerate(dirs):
|
79
|
+
if str(dir) in exclude_dir:
|
80
|
+
dirs.pop(i)
|
76
81
|
for file in files:
|
77
82
|
file_path = os.path.join(root, file)
|
78
83
|
file_path = Path(file_path)
|
79
|
-
if file_path.name in
|
84
|
+
if file_path.name in exclude_name or file_path.suffix in exclude_suffix:
|
80
85
|
continue
|
81
86
|
file_paths.append(file_path)
|
82
87
|
return file_paths
|
83
88
|
|
84
89
|
if __name__ == '__main__':
|
85
|
-
print(get_dirpaths_in_dir(r'E:\byzh_workingplace\byzh-rc-to-pypi
|
86
|
-
|
90
|
+
# print(get_dirpaths_in_dir(r'E:\byzh_workingplace\byzh-rc-to-pypi'))
|
91
|
+
a = get_filepaths_in_dir(r'E:\byzh_workingplace\byzh-rc-to-pypi')
|
92
|
+
print(a)
|
byzh_core/Barchive/archive.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import os
|
2
2
|
import zipfile
|
3
|
+
from ..Btqdm import B_Tqdm
|
3
4
|
|
4
5
|
def b_archive_zip(
|
5
6
|
source_path,
|
@@ -28,11 +29,14 @@ def b_archive_zip(
|
|
28
29
|
if while_list is None:
|
29
30
|
while_list = []
|
30
31
|
|
32
|
+
my_tqdm = B_Tqdm(prefix='Archive')
|
33
|
+
|
31
34
|
with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
32
35
|
# 压缩文件:
|
33
36
|
if os.path.isfile(source_path):
|
34
37
|
arcname = os.path.basename(source_path)
|
35
38
|
zipf.write(source_path, arcname)
|
39
|
+
my_tqdm.update(1)
|
36
40
|
return
|
37
41
|
|
38
42
|
# 压缩文件夹:
|
@@ -52,15 +56,18 @@ def b_archive_zip(
|
|
52
56
|
arcname = os.path.relpath(file_path, source_path) # 相对于source_path的相对路径
|
53
57
|
zipf.write(file_path, arcname)
|
54
58
|
|
59
|
+
my_tqdm.update(1)
|
60
|
+
|
55
61
|
# 若是空文件夹,则压缩文件夹:
|
56
62
|
if contain_empty_folder and (len(dirs) == 0 and len(files) == 0):
|
57
63
|
arcname = os.path.relpath(root, source_path)
|
58
64
|
folder_path = root
|
59
65
|
zipf.write(folder_path, arcname)
|
66
|
+
my_tqdm.update(1)
|
60
67
|
|
61
68
|
if __name__ == '__main__':
|
62
69
|
b_archive_zip(
|
63
|
-
source_path=r'E:\byzh_workingplace\byzh-rc-to-pypi\
|
70
|
+
source_path=r'E:\byzh_workingplace\byzh-rc-to-pypi\mnist',
|
64
71
|
output_path=r'E:\byzh_workingplace\byzh-rc-to-pypi\awaqwq.zip',
|
65
72
|
exclude_dirs=['__pycache__', 'com'],
|
66
73
|
exclude_exts=['.ppt']
|
byzh_core/Bconfig/config.py
CHANGED
@@ -251,8 +251,8 @@ class B_Config:
|
|
251
251
|
self.dict_lst[i][key] = value
|
252
252
|
|
253
253
|
def to_table(self, path):
|
254
|
-
from ..Btable import
|
255
|
-
my_table =
|
254
|
+
from ..Btable import B_Table2d
|
255
|
+
my_table = B_Table2d()
|
256
256
|
for index, group in enumerate(self.group_lst):
|
257
257
|
for key, value in self.dict_lst[index].items():
|
258
258
|
my_table[group][key] = value
|
byzh_core/Btable/auto_table.py
CHANGED
@@ -60,7 +60,7 @@ class Matrix2d:
|
|
60
60
|
def __init__(self, row_name='x', col_name='y'):
|
61
61
|
self.row_name = row_name
|
62
62
|
self.col_name = col_name
|
63
|
-
self.matrix = [[row_name + '
|
63
|
+
self.matrix = [[row_name + ' \\ ' + col_name]]
|
64
64
|
|
65
65
|
def get_rows(self): # 包含left_upper
|
66
66
|
if self.matrix == [[]]:
|
@@ -151,9 +151,14 @@ class Dict1d:
|
|
151
151
|
|
152
152
|
def __getitem__(self, key):
|
153
153
|
key = str(key)
|
154
|
-
|
154
|
+
try:
|
155
|
+
return self.dict[key]
|
156
|
+
except KeyError:
|
157
|
+
return None
|
155
158
|
def __setitem__(self, key, value): # 用于最底层赋值
|
156
159
|
key, value = str(key), str(value)
|
160
|
+
if value == 'None':
|
161
|
+
value = ' '
|
157
162
|
self.dict[key] = value
|
158
163
|
def set(self, key, value): # 用于非底层赋值(防止把子dict变为str)
|
159
164
|
key = str(key)
|
@@ -214,6 +219,26 @@ class B_Table2d:
|
|
214
219
|
# 判断是否改变
|
215
220
|
self.is_changed = False
|
216
221
|
|
222
|
+
def set(self, row, col, content):
|
223
|
+
row, col, content = str(row), str(col), str(content)
|
224
|
+
self[row][col] = content
|
225
|
+
|
226
|
+
def get_str(self, row, col):
|
227
|
+
return self[row][col]
|
228
|
+
def get_int(self, row, col):
|
229
|
+
return int(self[row][col])
|
230
|
+
def get_float(self, row, col):
|
231
|
+
return float(self[row][col])
|
232
|
+
def get_bool(self, row, col):
|
233
|
+
'''
|
234
|
+
如果是字符串"True"或"1",返回True,否则返回False
|
235
|
+
'''
|
236
|
+
temp = self[row][col]
|
237
|
+
if temp == "True" or temp == "1":
|
238
|
+
return True
|
239
|
+
else:
|
240
|
+
return False
|
241
|
+
|
217
242
|
def __getitem__(self, row):
|
218
243
|
self.is_changed = True
|
219
244
|
|
@@ -226,13 +251,19 @@ class B_Table2d:
|
|
226
251
|
row = str(row)
|
227
252
|
self.dict2d[row] = new_dict
|
228
253
|
|
229
|
-
def from_txt(self, txt_path, use_txt_name:bool=False):
|
254
|
+
def from_txt(self, txt_path, create:bool=False, use_txt_name:bool=False):
|
230
255
|
'''
|
231
|
-
|
232
256
|
:param txt_path:
|
257
|
+
:param create: 如果文件不存在,则创建
|
233
258
|
:param use_txt_name: 默认使用init时的row_name和col_name
|
234
259
|
:return:
|
235
260
|
'''
|
261
|
+
if not os.path.exists(txt_path):
|
262
|
+
if create:
|
263
|
+
self.to_txt(txt_path)
|
264
|
+
else:
|
265
|
+
raise FileNotFoundError(f"文件不存在: {txt_path}")
|
266
|
+
|
236
267
|
with open(txt_path, 'r', encoding='utf-8') as f:
|
237
268
|
lines = f.readlines()
|
238
269
|
matrix, row_name, col_name = strs2matrix(lines)
|
@@ -297,6 +328,51 @@ class B_Table2d:
|
|
297
328
|
def to_str(self):
|
298
329
|
return '\n'.join(self.to_strs())
|
299
330
|
|
331
|
+
def to_ini(self, path):
|
332
|
+
'''
|
333
|
+
输出为ini格式
|
334
|
+
:param path:
|
335
|
+
:return:
|
336
|
+
'''
|
337
|
+
if self.is_changed:
|
338
|
+
self.__dict2matrix()
|
339
|
+
|
340
|
+
groups = self.matrix2d.get_rows()[1:]
|
341
|
+
keys = self.matrix2d.get_cols()[1:]
|
342
|
+
with open(path, 'w', encoding='utf-8') as f:
|
343
|
+
for i, group in enumerate(groups):
|
344
|
+
f.write(f"[{group}]\n")
|
345
|
+
for j, key in enumerate(keys):
|
346
|
+
value = self.matrix2d.get_by_index(i+1, j+1)
|
347
|
+
f.write(f"{key} = {value}\n")
|
348
|
+
f.write("\n")
|
349
|
+
|
350
|
+
def from_ini(self, path):
|
351
|
+
'''
|
352
|
+
输入为ini格式
|
353
|
+
:param path:
|
354
|
+
:return:
|
355
|
+
'''
|
356
|
+
with open(path, 'r', encoding='utf-8') as f:
|
357
|
+
lines = f.readlines()
|
358
|
+
|
359
|
+
self.dict2d = Dict2d()
|
360
|
+
|
361
|
+
group = None
|
362
|
+
for line in lines:
|
363
|
+
line = line.strip()
|
364
|
+
if line.startswith('[') and line.endswith(']'):
|
365
|
+
group = line[1:-1]
|
366
|
+
elif '=' in line:
|
367
|
+
key, value = line.split('=')
|
368
|
+
key = key.strip()
|
369
|
+
value = value.strip()
|
370
|
+
if value == 'None':
|
371
|
+
value = None
|
372
|
+
self[group][key] = value
|
373
|
+
|
374
|
+
self.__dict2matrix()
|
375
|
+
|
300
376
|
def __str__(self):
|
301
377
|
return self.to_str()
|
302
378
|
|
byzh_core/Bwriter/__init__.py
CHANGED
byzh_core/__init__.py
CHANGED
@@ -1,20 +1,16 @@
|
|
1
|
-
byzh_core/B_os.py,sha256
|
2
|
-
byzh_core/__init__.py,sha256=
|
1
|
+
byzh_core/B_os.py,sha256=-6KjK2NzEeF8GiQno0BmbVDei9DDxOaXdaKGqFeL_eY,2372
|
2
|
+
byzh_core/__init__.py,sha256=d_c6dl-Qv2eGijPSDNAHZUqubney2tU5yZ3iWTk17FI,110
|
3
3
|
byzh_core/Barchive/__init__.py,sha256=wUdz646VS0Uhq9lwMkd3YQHCvQhLDqgADoDjFGMqIn0,65
|
4
|
-
byzh_core/Barchive/archive.py,sha256=
|
4
|
+
byzh_core/Barchive/archive.py,sha256=6uMoOs-lmdcezdOgXr4s9NmjHVRDvG4v_YGQhaPPyGo,2681
|
5
5
|
byzh_core/Bbasic/__init__.py,sha256=wr7Y7YJINhgpV5X6BT5DaGJKcHUOZYNerCGXoi2Egac,116
|
6
6
|
byzh_core/Bbasic/text_style.py,sha256=JelgL3AgcH607Mr-Bvr4u8Svb0twmNmqwXvOl4hHOSs,3161
|
7
7
|
byzh_core/Bconfig/__init__.py,sha256=7lAp7wNetW0AyJcike7ekdY_8wrQQtFjBsi6684t_lU,54
|
8
|
-
byzh_core/Bconfig/config.py,sha256=
|
8
|
+
byzh_core/Bconfig/config.py,sha256=zfURiqwxXrPo4Pei63GaVvTslHnYTgmleCjeaGBR9K8,10952
|
9
9
|
byzh_core/Bmath/__init__.py,sha256=G3AQug6izkEX3UfzO_mqUNJW88ZKlmYb4Q8CAactK4w,105
|
10
10
|
byzh_core/Bmath/divides.py,sha256=dr85IqGSE9NvugQu7az29GLcjRiLjXU_hZTwtNifIXg,1132
|
11
11
|
byzh_core/Bmath/get_norm.py,sha256=y1QsCTo7qhtGTXIxpc6JtamLWloC7ENRuVdNtK5yi58,596
|
12
|
-
byzh_core/Bos/B_os.py,sha256=iGzL9if9Jh5z3U_qWRPIZCrHly2ZCz8MJLWiJwYVefA,763
|
13
|
-
byzh_core/Bos/__init__.py,sha256=mMa6OugZs8gIfZMj7go_wEHZRe0JRffgiyIKTF5I_uc,88
|
14
|
-
byzh_core/Bos/make.py,sha256=uGmHc96lXChihJs2jGiXJRp3tU_U5DPCo8jcc-aW6d4,663
|
15
|
-
byzh_core/Bos/remove.py,sha256=HuGQlEOz7IZB_c6T9MzR3miRx60IeaBYP-3lp-P20-I,156
|
16
12
|
byzh_core/Btable/__init__.py,sha256=NlQBjp_mvObEUm4y6wXbGipkNM2N3uNIUidaJkTwFsw,62
|
17
|
-
byzh_core/Btable/auto_table.py,sha256=
|
13
|
+
byzh_core/Btable/auto_table.py,sha256=nc8RvF86laDnITAzX8sVj3l5tbIGflrsstIbSbGDaAI,14747
|
18
14
|
byzh_core/Btable/obsolete/__init__.py,sha256=wpfHMPD4awPRDJVYlaiGtkkpjq2srWB7d7LrWhoX5R0,161
|
19
15
|
byzh_core/Btable/obsolete/auto_table.py,sha256=nC9eHj_IIGVkS2lmN_1gtOyglLCaGlwdoHzPvNNQDEw,13952
|
20
16
|
byzh_core/Btable/obsolete/row_table.py,sha256=rIX0-Yvb3RnO0RJBkA4m18gux1zYSnEKTy6uQGcWilc,5999
|
@@ -23,11 +19,10 @@ byzh_core/Bterminal/__init__.py,sha256=B6p6mHVhi5LAHKlvqfrv20E6XNqUsfU2xD753V6-Z
|
|
23
19
|
byzh_core/Bterminal/cmd.py,sha256=iK0fwI0D3peEwUYYZWwnl9X8ImFfrBsEq6ySd3DcRdE,3839
|
24
20
|
byzh_core/Btqdm/__init__.py,sha256=PQRcUn9WXd1YGyFMEKnJU74mdV695_8NHQ56Nsja0DM,53
|
25
21
|
byzh_core/Btqdm/my_tqdm.py,sha256=myyFo3GgyX_wWfSjMWfSTkcnTECf1tqwpXEFpJkzNtw,2878
|
26
|
-
byzh_core/Bwriter/__init__.py,sha256=
|
27
|
-
byzh_core/Bwriter/globalwriter.py,sha256=tSjWxzLylAeZep67n5jbRsjQkXkBKRZLvKXUyGSY92Q,1824
|
22
|
+
byzh_core/Bwriter/__init__.py,sha256=7db9No0yYOW5ZUtFVKWLRZcu_nz3kvw2W25IoiIiilE,54
|
28
23
|
byzh_core/Bwriter/writer.py,sha256=px0ZNoSuXS_RbwVnYsBx2lYohyhHACfHM8-HBNEflhU,4006
|
29
|
-
byzh_core-0.0.2.
|
30
|
-
byzh_core-0.0.2.
|
31
|
-
byzh_core-0.0.2.
|
32
|
-
byzh_core-0.0.2.
|
33
|
-
byzh_core-0.0.2.
|
24
|
+
byzh_core-0.0.2.7.dist-info/LICENSE,sha256=-nRwf0Xga4AX5bsWBXXflpDpgX_U23X06oAMcdf0dSY,1089
|
25
|
+
byzh_core-0.0.2.7.dist-info/METADATA,sha256=v5PcdMGqu_VZFUOqpGQ5OPD-xJNh4XarkoXdYONIyQo,371
|
26
|
+
byzh_core-0.0.2.7.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
27
|
+
byzh_core-0.0.2.7.dist-info/top_level.txt,sha256=Xv-pzvl6kPdIbi5UehQcUdGhLtb8-4WhS5dRK1LINwM,10
|
28
|
+
byzh_core-0.0.2.7.dist-info/RECORD,,
|
byzh_core/Bos/B_os.py
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
import shutil
|
2
|
-
import os
|
3
|
-
from pathlib import Path
|
4
|
-
from typing import Literal
|
5
|
-
|
6
|
-
def get_parent_dir(path: Literal['__file__']) -> Path:
|
7
|
-
'''
|
8
|
-
获取 该py文件 所在的文件夹
|
9
|
-
:param path: __file__
|
10
|
-
'''
|
11
|
-
parent_dir = Path(path).parent
|
12
|
-
return parent_dir
|
13
|
-
|
14
|
-
def get_cwd() -> Path:
|
15
|
-
'''
|
16
|
-
获取 当前工作目录current working directory
|
17
|
-
'''
|
18
|
-
return Path.cwd()
|
19
|
-
|
20
|
-
|
21
|
-
def makedirs(path):
|
22
|
-
from .make import is_dir, is_file
|
23
|
-
|
24
|
-
path = Path(path)
|
25
|
-
|
26
|
-
if is_dir(path):
|
27
|
-
os.makedirs(path, exist_ok=True)
|
28
|
-
if is_file(path):
|
29
|
-
os.makedirs(path.parent, exist_ok=True)
|
30
|
-
|
31
|
-
def rm(path):
|
32
|
-
if os.path.isdir(path):
|
33
|
-
shutil.rmtree(path)
|
34
|
-
if os.path.isfile(path):
|
35
|
-
os.remove(path)
|
byzh_core/Bos/__init__.py
DELETED
byzh_core/Bos/make.py
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
from pathlib import Path
|
2
|
-
import os
|
3
|
-
import shutil
|
4
|
-
|
5
|
-
def is_dir(path):
|
6
|
-
path = Path(path)
|
7
|
-
|
8
|
-
# 存在
|
9
|
-
if os.path.isdir(path):
|
10
|
-
return True
|
11
|
-
|
12
|
-
# 不存在
|
13
|
-
name = path.name
|
14
|
-
if '.' in name:
|
15
|
-
return False
|
16
|
-
return True
|
17
|
-
|
18
|
-
def is_file(path):
|
19
|
-
path = Path(path)
|
20
|
-
|
21
|
-
# 存在
|
22
|
-
if os.path.isfile(path):
|
23
|
-
return True
|
24
|
-
|
25
|
-
# 不存在
|
26
|
-
name = path.name
|
27
|
-
if '.' in name:
|
28
|
-
return True
|
29
|
-
return False
|
30
|
-
def b_makedir(path):
|
31
|
-
path = Path(path)
|
32
|
-
|
33
|
-
if is_dir(path):
|
34
|
-
os.makedirs(path, exist_ok=True)
|
35
|
-
if is_file(path):
|
36
|
-
os.makedirs(path.parent, exist_ok=True)
|
37
|
-
|
38
|
-
|
byzh_core/Bos/remove.py
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
import threading
|
2
|
-
import time
|
3
|
-
import atexit
|
4
|
-
|
5
|
-
|
6
|
-
class B_GlobalWriter():
|
7
|
-
_instance = None
|
8
|
-
_lock = threading.Lock()
|
9
|
-
|
10
|
-
def __new__(cls):
|
11
|
-
if cls._instance is None:
|
12
|
-
with cls._lock:
|
13
|
-
if cls._instance is None:
|
14
|
-
cls._instance = super().__new__(cls)
|
15
|
-
# 初始化
|
16
|
-
cls._instance.file = None
|
17
|
-
cls._instance.f = None
|
18
|
-
cls._instance.ifTime = False
|
19
|
-
atexit.register(cls._instance.closeFile) # 注册关闭方法
|
20
|
-
return cls._instance
|
21
|
-
|
22
|
-
@classmethod
|
23
|
-
def setFile(cls, file, ifTime=False):
|
24
|
-
cls()
|
25
|
-
cls._instance.ifTime = ifTime
|
26
|
-
cls._instance.path = file
|
27
|
-
cls._instance.f = open(cls._instance.path, "a", encoding="utf-8")
|
28
|
-
|
29
|
-
@classmethod
|
30
|
-
def clearFile(cls):
|
31
|
-
cls()
|
32
|
-
assert cls._instance.f is not None, "请先调用setFile方法"
|
33
|
-
cls._instance.f.close()
|
34
|
-
cls._instance.f = open(cls._instance.path, 'w', encoding="utf-8")
|
35
|
-
|
36
|
-
@classmethod
|
37
|
-
def closeFile(cls):
|
38
|
-
if cls._instance.f:
|
39
|
-
cls._instance.f.close()
|
40
|
-
cls._instance.f = None
|
41
|
-
|
42
|
-
@classmethod
|
43
|
-
def toCmd(cls, string):
|
44
|
-
cls()
|
45
|
-
print(string)
|
46
|
-
|
47
|
-
@classmethod
|
48
|
-
def toFile(cls, string):
|
49
|
-
cls()
|
50
|
-
assert cls._instance.f is not None, "请先调用setFile方法"
|
51
|
-
if cls._instance.ifTime:
|
52
|
-
t = time.strftime("%Y-%m-%d %H:%M:%S ##### ", time.localtime())
|
53
|
-
cls._instance.f.write(t)
|
54
|
-
cls._instance.f.write(string)
|
55
|
-
cls._instance.f.write("\n")
|
56
|
-
cls._instance.f.flush()
|
57
|
-
|
58
|
-
@classmethod
|
59
|
-
def toBoth(cls, string):
|
60
|
-
cls()
|
61
|
-
cls.toFile(string)
|
62
|
-
cls.toCmd(string)
|
File without changes
|
File without changes
|
File without changes
|