byzh-core 0.0.2.11__py3-none-any.whl → 0.0.2.13__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/Barchive/archive.py +20 -14
- byzh_core/Bbasic/text_style.py +5 -3
- byzh_core/Btqdm/__init__.py +4 -2
- byzh_core/Btqdm/my_tqdm.py +12 -6
- byzh_core/__init__.py +1 -1
- {byzh_core-0.0.2.11.dist-info → byzh_core-0.0.2.13.dist-info}/METADATA +1 -1
- {byzh_core-0.0.2.11.dist-info → byzh_core-0.0.2.13.dist-info}/RECORD +10 -13
- byzh_core/Bmath/__init__.py +0 -4
- byzh_core/Bmath/divides.py +0 -41
- byzh_core/Bmath/get_norm.py +0 -21
- {byzh_core-0.0.2.11.dist-info → byzh_core-0.0.2.13.dist-info}/LICENSE +0 -0
- {byzh_core-0.0.2.11.dist-info → byzh_core-0.0.2.13.dist-info}/WHEEL +0 -0
- {byzh_core-0.0.2.11.dist-info → byzh_core-0.0.2.13.dist-info}/top_level.txt +0 -0
byzh_core/Barchive/archive.py
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
import os
|
2
2
|
import zipfile
|
3
|
+
from pathlib import Path
|
4
|
+
|
3
5
|
from ..Btqdm import B_Tqdm
|
4
6
|
|
5
7
|
def b_archive_zip(
|
6
8
|
source_path,
|
7
|
-
output_path,
|
9
|
+
output_path:str|Path=None,
|
8
10
|
exclude_dirs:list[str]=None,
|
9
11
|
exclude_files:list[str]=None,
|
10
12
|
exclude_exts:list[str]=None,
|
@@ -13,21 +15,26 @@ def b_archive_zip(
|
|
13
15
|
):
|
14
16
|
'''
|
15
17
|
压缩文件夹,排除 指定文件夹and指定后缀文件
|
18
|
+
|
19
|
+
name代表前缀, ext代表后缀(包括.)
|
20
|
+
|
16
21
|
:param source_path:
|
17
|
-
:param output_path:
|
18
|
-
:param exclude_dirs: ['__pycache__', '.git', '.idea']
|
19
|
-
:param exclude_files: ['.gitignore', 'README.md']
|
20
|
-
:param exclude_exts: ['.csv', '.npy', '.pt', '.pth']
|
22
|
+
:param output_path: 如果不传入, 则默认为source_path同名同路径的zip文件
|
23
|
+
:param exclude_dirs: 黑名单-文件夹名 >>> ['__pycache__', '.git', '.idea']
|
24
|
+
:param exclude_files: 黑名单-文件全名 >>> ['.gitignore', 'README.md']
|
25
|
+
:param exclude_exts: 黑名单-文件后缀(包括.) >>> ['.csv', '.npy', '.pt', '.pth']
|
26
|
+
:param while_list: 白名单-文件全名 >>> ['.gitignore', 'README.md']
|
27
|
+
:param contain_empty_folder: 是否包含空文件夹
|
21
28
|
:return:
|
22
29
|
'''
|
23
|
-
if
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
output_path = source_path + '.zip' if output_path is None else output_path
|
31
|
+
def get_lst(lst):
|
32
|
+
return [] if lst is None else lst
|
33
|
+
exclude_dirs = get_lst(exclude_dirs)
|
34
|
+
exclude_files = get_lst(exclude_files)
|
35
|
+
exclude_exts = get_lst(exclude_exts)
|
36
|
+
while_list = get_lst(while_list)
|
37
|
+
|
31
38
|
|
32
39
|
my_tqdm = B_Tqdm(prefix='Archive')
|
33
40
|
|
@@ -49,7 +56,6 @@ def b_archive_zip(
|
|
49
56
|
# 排除指定后缀文件files
|
50
57
|
files = [f for f in files if f in while_list or not any(f.endswith(ext) for ext in exclude_exts)]
|
51
58
|
|
52
|
-
|
53
59
|
# 压缩文件:
|
54
60
|
for file in files:
|
55
61
|
file_path = os.path.join(root, file)
|
byzh_core/Bbasic/text_style.py
CHANGED
@@ -31,6 +31,7 @@ class B_Appearance(Enum):
|
|
31
31
|
|
32
32
|
HIGHLIGHT = "\033[1m" # 高亮
|
33
33
|
LOWLIGHT = "\033[2m" # 低亮
|
34
|
+
ITALIC = "\033[3m" # 斜体
|
34
35
|
UNDERLINE = "\033[4m" # 下划线
|
35
36
|
REVERSE = "\033[7m" # 反显(白底黑字)
|
36
37
|
|
@@ -41,12 +42,13 @@ if __name__ == '__main__':
|
|
41
42
|
print("\033[0m默认文字\033[0m")
|
42
43
|
print("\033[1m高亮文字\033[0m")
|
43
44
|
print("\033[2m低亮文字\033[0m")
|
44
|
-
|
45
|
+
print("\033[3m斜体文字\033[0m") # 在某些终端中可能无效
|
45
46
|
print("\033[4m下划线文字\033[0m")
|
46
|
-
print("\033[5m
|
47
|
-
|
47
|
+
print("\033[5m闪烁文字\033[0m") # 在某些终端中可能无效
|
48
|
+
print("\033[6m快速闪烁文字\033[0m") # 在某些终端中可能无效
|
48
49
|
print("\033[7m反显文字\033[0m")
|
49
50
|
print("\033[8m消隐文字(无效)\033[0m")
|
51
|
+
# exit()
|
50
52
|
|
51
53
|
print("\n\033[31;1m字体颜色\033[0m测试文字")
|
52
54
|
print("\033[30m低亮黑色文字\033[0m\t\033[30;1m高亮黑色文字\033[0m")
|
byzh_core/Btqdm/__init__.py
CHANGED
byzh_core/Btqdm/my_tqdm.py
CHANGED
@@ -2,7 +2,7 @@ import sys
|
|
2
2
|
import time
|
3
3
|
import threading
|
4
4
|
|
5
|
-
from ..Bbasic import B_Color
|
5
|
+
from ..Bbasic import B_Color, B_Appearance, B_Background
|
6
6
|
|
7
7
|
|
8
8
|
class B_Tqdm:
|
@@ -39,8 +39,14 @@ class B_Tqdm:
|
|
39
39
|
seconds = int(seconds % 60)
|
40
40
|
return f'{minutes:02}:{seconds:02}'
|
41
41
|
|
42
|
-
def update(self, step=1, color=B_Color.BLUE,
|
42
|
+
def update(self, step=1, prefix=None, suffix=None, color:B_Color=B_Color.BLUE, appearance:B_Appearance=None, background:B_Background=None):
|
43
43
|
with self._lock:
|
44
|
+
pre_show = color.value
|
45
|
+
if appearance is not None:
|
46
|
+
pre_show += appearance.value
|
47
|
+
if background is not None:
|
48
|
+
pre_show += background.value
|
49
|
+
|
44
50
|
if self.current == 0:
|
45
51
|
self.start_time = time.time()
|
46
52
|
if prefix is not None:
|
@@ -66,12 +72,12 @@ class B_Tqdm:
|
|
66
72
|
filled_length = int(self.length * self.current // self.total)
|
67
73
|
bar = self.fill * filled_length + '-' * (self.length - filled_length) * len(self.fill)
|
68
74
|
|
69
|
-
sys.stdout.write(f'\r{
|
75
|
+
sys.stdout.write(f'\r{pre_show}{self.prefix} |{bar}|'
|
70
76
|
f' {self.current}/{self.total} -> {elapsed_str}<{estimated_str} | {speed:.1f} it/s |'
|
71
|
-
f' {self.suffix}{B_Color.RESET}')
|
77
|
+
f' {self.suffix}{B_Color.RESET.value}')
|
72
78
|
else:
|
73
|
-
sys.stdout.write(f'\r{
|
74
|
-
f' {self.suffix}{B_Color.RESET}')
|
79
|
+
sys.stdout.write(f'\r{pre_show}{self.prefix} | {self.current} iters -> {elapsed_str} | {speed:.1f} it/s |'
|
80
|
+
f' {self.suffix}{B_Color.RESET.value}')
|
75
81
|
sys.stdout.flush()
|
76
82
|
|
77
83
|
# 补回车
|
byzh_core/__init__.py
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
byzh_core/B_os.py,sha256=-6KjK2NzEeF8GiQno0BmbVDei9DDxOaXdaKGqFeL_eY,2372
|
2
|
-
byzh_core/__init__.py,sha256=
|
2
|
+
byzh_core/__init__.py,sha256=3MQSx_FHA9m2ns8iWJvgFa0fodxgXK2zeOmKii0WeIU,111
|
3
3
|
byzh_core/Barchive/__init__.py,sha256=wUdz646VS0Uhq9lwMkd3YQHCvQhLDqgADoDjFGMqIn0,65
|
4
|
-
byzh_core/Barchive/archive.py,sha256=
|
4
|
+
byzh_core/Barchive/archive.py,sha256=sG9m1Hr-d2zxYVmzTVRNXX2U2T5baMYECZVqjt0k8pU,3157
|
5
5
|
byzh_core/Bbasic/__init__.py,sha256=wr7Y7YJINhgpV5X6BT5DaGJKcHUOZYNerCGXoi2Egac,116
|
6
|
-
byzh_core/Bbasic/text_style.py,sha256=
|
7
|
-
byzh_core/Bmath/__init__.py,sha256=G3AQug6izkEX3UfzO_mqUNJW88ZKlmYb4Q8CAactK4w,105
|
8
|
-
byzh_core/Bmath/divides.py,sha256=dr85IqGSE9NvugQu7az29GLcjRiLjXU_hZTwtNifIXg,1132
|
9
|
-
byzh_core/Bmath/get_norm.py,sha256=y1QsCTo7qhtGTXIxpc6JtamLWloC7ENRuVdNtK5yi58,596
|
6
|
+
byzh_core/Bbasic/text_style.py,sha256=34u2-Rsur63iNQ0m7tHxpFWqnQZWybSxBx7vnhOhqDo,3346
|
10
7
|
byzh_core/Btable/__init__.py,sha256=NlQBjp_mvObEUm4y6wXbGipkNM2N3uNIUidaJkTwFsw,62
|
11
8
|
byzh_core/Btable/auto_table.py,sha256=nc8RvF86laDnITAzX8sVj3l5tbIGflrsstIbSbGDaAI,14747
|
12
9
|
byzh_core/Bterminal/__init__.py,sha256=B6p6mHVhi5LAHKlvqfrv20E6XNqUsfU2xD753V6-Zf4,83
|
13
10
|
byzh_core/Bterminal/cmd.py,sha256=iK0fwI0D3peEwUYYZWwnl9X8ImFfrBsEq6ySd3DcRdE,3839
|
14
|
-
byzh_core/Btqdm/__init__.py,sha256=
|
15
|
-
byzh_core/Btqdm/my_tqdm.py,sha256=
|
11
|
+
byzh_core/Btqdm/__init__.py,sha256=G8pvJYizvdTUI3Xw-yELXY7BbjTghCXJLdqUuDoRNZA,141
|
12
|
+
byzh_core/Btqdm/my_tqdm.py,sha256=OIlT01P6g-rDyDt6wlX9lORAUux9x-LA6EZRGQyJaXU,3202
|
16
13
|
byzh_core/Bwriter/__init__.py,sha256=QcHzKs0305Pr78ZvZgcC_4miSYZh8jJQDt5TD0GIeEg,82
|
17
14
|
byzh_core/Bwriter/writer.py,sha256=kSfIyGdx-XGoV1TBUY6f7NoFL_40fTx9ISTT8Fic0yE,3167
|
18
15
|
byzh_core/obsolete/__init__.py,sha256=wpfHMPD4awPRDJVYlaiGtkkpjq2srWB7d7LrWhoX5R0,161
|
@@ -21,8 +18,8 @@ byzh_core/obsolete/row_table.py,sha256=rIX0-Yvb3RnO0RJBkA4m18gux1zYSnEKTy6uQGcWi
|
|
21
18
|
byzh_core/obsolete/xy_table.py,sha256=-KHK8EUlkJj3Rh0sp_KHI0QFt29AlMASMmR8q8ykUBM,6784
|
22
19
|
byzh_core/obsolete/Bconfig/__init__.py,sha256=7lAp7wNetW0AyJcike7ekdY_8wrQQtFjBsi6684t_lU,54
|
23
20
|
byzh_core/obsolete/Bconfig/config.py,sha256=TD8CC1P2Zu95Tf8AGK2IHRXjrCCMBA_tdoZsc1Rr0Gk,10953
|
24
|
-
byzh_core-0.0.2.
|
25
|
-
byzh_core-0.0.2.
|
26
|
-
byzh_core-0.0.2.
|
27
|
-
byzh_core-0.0.2.
|
28
|
-
byzh_core-0.0.2.
|
21
|
+
byzh_core-0.0.2.13.dist-info/LICENSE,sha256=-nRwf0Xga4AX5bsWBXXflpDpgX_U23X06oAMcdf0dSY,1089
|
22
|
+
byzh_core-0.0.2.13.dist-info/METADATA,sha256=3zXlKKCBBEzdMdoI6-WVmgqsnZ7UqAaB5lzqjjy1ZqM,372
|
23
|
+
byzh_core-0.0.2.13.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
24
|
+
byzh_core-0.0.2.13.dist-info/top_level.txt,sha256=Xv-pzvl6kPdIbi5UehQcUdGhLtb8-4WhS5dRK1LINwM,10
|
25
|
+
byzh_core-0.0.2.13.dist-info/RECORD,,
|
byzh_core/Bmath/__init__.py
DELETED
byzh_core/Bmath/divides.py
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
from typing import Union, List, Set, Tuple
|
2
|
-
|
3
|
-
my_type1 = Union[int, float, str]
|
4
|
-
def get_num(num: my_type1):
|
5
|
-
if isinstance(num, str):
|
6
|
-
return float(num)
|
7
|
-
return num
|
8
|
-
|
9
|
-
my_type2 = Union[my_type1, List[my_type1], Set[my_type1], Tuple[my_type1]]
|
10
|
-
def b_divides(iterUp: my_type2, iterDown: my_type2):
|
11
|
-
"""
|
12
|
-
支持list, tuple, set, 单个数\n
|
13
|
-
iterUp as 分子\n
|
14
|
-
iterDown as 分母
|
15
|
-
"""
|
16
|
-
up = 1
|
17
|
-
down = 1
|
18
|
-
|
19
|
-
if not isinstance(iterUp, list) and not isinstance(iterUp, tuple) and not isinstance(iterUp, set):
|
20
|
-
up *= get_num(iterUp)
|
21
|
-
else:
|
22
|
-
for x in iterUp:
|
23
|
-
up *= get_num(x)
|
24
|
-
|
25
|
-
if not isinstance(iterDown, list) and not isinstance(iterDown, tuple) and not isinstance(iterDown, set):
|
26
|
-
down *= get_num(iterDown)
|
27
|
-
else:
|
28
|
-
for x in iterDown:
|
29
|
-
down *= get_num(x)
|
30
|
-
|
31
|
-
return up / down
|
32
|
-
|
33
|
-
if __name__ == '__main__':
|
34
|
-
result = b_divides([1, 2, 3], [4, 5])
|
35
|
-
print(result)
|
36
|
-
|
37
|
-
result = b_divides(6.63e-34, (9.11e-31, 3e8))
|
38
|
-
print(result)
|
39
|
-
|
40
|
-
result = b_divides('6.63e-34', ['9.11e-31', 3e8])
|
41
|
-
print(result)
|
byzh_core/Bmath/get_norm.py
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
from typing import Literal
|
2
|
-
def b_get_norm(
|
3
|
-
lst: list,
|
4
|
-
mode: Literal['min-max'] = 'min-max',
|
5
|
-
ndigits: int | None = None
|
6
|
-
) -> tuple[list, float, float]:
|
7
|
-
|
8
|
-
if mode =='min-max':
|
9
|
-
minimum = min(lst)
|
10
|
-
maximum = max(lst)
|
11
|
-
if ndigits is None:
|
12
|
-
result = [(x-minimum)/(maximum-minimum) for x in lst]
|
13
|
-
else:
|
14
|
-
result = [round((x-minimum)/(maximum-minimum), ndigits) for x in lst]
|
15
|
-
return (result, minimum, maximum)
|
16
|
-
|
17
|
-
|
18
|
-
if __name__ == '__main__':
|
19
|
-
lst = [1, 2, 3, 4, 5]
|
20
|
-
result = b_get_norm(lst)
|
21
|
-
print(result)
|
File without changes
|
File without changes
|
File without changes
|