byzh-core 0.0.3.1__tar.gz → 0.0.5.0__tar.gz
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-0.0.3.1 → byzh_core-0.0.5.0}/PKG-INFO +1 -1
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Barchive/archive.py +6 -1
- byzh_core-0.0.5.0/byzh_core/Bterminal/__init__.py +7 -0
- byzh_core-0.0.5.0/byzh_core/Bterminal/run_func.py +61 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Btqdm/my_tqdm.py +21 -8
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/__init__.py +1 -1
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core.egg-info/PKG-INFO +1 -1
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core.egg-info/SOURCES.txt +1 -0
- byzh_core-0.0.3.1/byzh_core/Bterminal/__init__.py +0 -3
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/LICENSE +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/README.md +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/B_os.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Barchive/__init__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Btable/__init__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Btable/auto_table.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Bterminal/cmd.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Btqdm/__init__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Butils/__init__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Butils/decorator.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Butils/text_style.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Butils/timer.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Bwriter/__init__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/Bwriter/writer.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/__main__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/obsolete/Bconfig/__init__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/obsolete/Bconfig/config.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/obsolete/__init__.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/obsolete/auto_table.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/obsolete/row_table.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core/obsolete/xy_table.py +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core.egg-info/dependency_links.txt +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core.egg-info/entry_points.txt +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core.egg-info/requires.txt +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/byzh_core.egg-info/top_level.txt +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/setup.cfg +0 -0
- {byzh_core-0.0.3.1 → byzh_core-0.0.5.0}/setup.py +0 -0
@@ -42,7 +42,12 @@ def b_archive_zip(
|
|
42
42
|
:param contain_empty_folder: 是否包含空文件夹
|
43
43
|
:return:
|
44
44
|
'''
|
45
|
-
|
45
|
+
if output_path is None:
|
46
|
+
if os.path.isdir(source_path):
|
47
|
+
output_path = source_path + '.zip'
|
48
|
+
else:
|
49
|
+
output_path = os.path.splitext(source_path)[0] + '.zip'
|
50
|
+
|
46
51
|
if os.path.exists(output_path):
|
47
52
|
print(f"检测到{output_path}已存在, 将在3秒后删除...")
|
48
53
|
time.sleep(3)
|
@@ -0,0 +1,61 @@
|
|
1
|
+
from itertools import product
|
2
|
+
from typing import Sequence, Callable, Literal
|
3
|
+
import warnings
|
4
|
+
class b_Wrapper():
|
5
|
+
def __init__(
|
6
|
+
self,
|
7
|
+
mode:Literal["product", "zip"] = "product",
|
8
|
+
**kwargs: Sequence
|
9
|
+
):
|
10
|
+
self.mode = mode
|
11
|
+
self.keys = []
|
12
|
+
|
13
|
+
for key, value in kwargs.items():
|
14
|
+
setattr(self, key+"_list", value)
|
15
|
+
self.keys.append(key)
|
16
|
+
|
17
|
+
self.values_lst = self._get_values_lst()
|
18
|
+
|
19
|
+
def _get_values_lst(self):
|
20
|
+
temp = [getattr(self, key + "_list") for key in self.keys]
|
21
|
+
if self.mode == "product":
|
22
|
+
return list(product(*temp))
|
23
|
+
elif self.mode == "zip":
|
24
|
+
# 检查是否个数相同
|
25
|
+
if len(set(map(len, temp)))!= 1:
|
26
|
+
warnings.warn("zip模式下, 如果各部分的len不一样, 则超出部分不参与遍历")
|
27
|
+
return list(zip(*temp))
|
28
|
+
else:
|
29
|
+
raise ValueError("Invalid mode")
|
30
|
+
|
31
|
+
def _set_values(self, index):
|
32
|
+
for key, value in zip(self.keys, self.values_lst[index]):
|
33
|
+
setattr(self, key, value)
|
34
|
+
|
35
|
+
def run(self, func: Callable, *args, **kwargs):
|
36
|
+
for i in range(len(self.values_lst)):
|
37
|
+
self._set_values(i)
|
38
|
+
func(*args, **kwargs)
|
39
|
+
|
40
|
+
|
41
|
+
if __name__ == '__main__':
|
42
|
+
def demo_func():
|
43
|
+
print(f"x={wrapper.x}, y={wrapper.y}, x+y={wrapper.x + wrapper.y}")
|
44
|
+
|
45
|
+
# 示例 1: product 笛卡尔积模式
|
46
|
+
print("=== product 模式 ===")
|
47
|
+
wrapper = b_Wrapper(
|
48
|
+
mode="product",
|
49
|
+
x=[1, 2, 3],
|
50
|
+
y=[10, 20]
|
51
|
+
)
|
52
|
+
wrapper.run(demo_func)
|
53
|
+
|
54
|
+
# 示例 2: zip 模式
|
55
|
+
print("\n=== zip 模式 ===")
|
56
|
+
wrapper = b_Wrapper(
|
57
|
+
mode="zip",
|
58
|
+
x=[1, 2, 3],
|
59
|
+
y=[10, 20, 30]
|
60
|
+
)
|
61
|
+
wrapper.run(demo_func)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import sys
|
2
2
|
import time
|
3
3
|
import threading
|
4
|
+
from typing import Iterable
|
4
5
|
|
5
6
|
from ..Butils import B_Color, B_Appearance, B_Background
|
6
7
|
|
@@ -8,7 +9,7 @@ from ..Butils import B_Color, B_Appearance, B_Background
|
|
8
9
|
class B_Tqdm:
|
9
10
|
def __init__(
|
10
11
|
self,
|
11
|
-
|
12
|
+
range: int|Iterable = None,
|
12
13
|
prefix: str = 'Processing',
|
13
14
|
suffix: str = '',
|
14
15
|
length: int = 20,
|
@@ -23,7 +24,14 @@ class B_Tqdm:
|
|
23
24
|
:param fill: 填充字符
|
24
25
|
"""
|
25
26
|
super().__init__()
|
26
|
-
self.
|
27
|
+
self.range = range
|
28
|
+
if isinstance(range, Iterable):
|
29
|
+
self.range_len = len(range)
|
30
|
+
elif isinstance(range, int):
|
31
|
+
self.range_len = range
|
32
|
+
else:
|
33
|
+
self.range_len = None
|
34
|
+
|
27
35
|
self.prefix = prefix
|
28
36
|
self.suffix = suffix
|
29
37
|
self.length = length
|
@@ -61,19 +69,19 @@ class B_Tqdm:
|
|
61
69
|
elapsed_time = time.time() - self.start_time
|
62
70
|
elapsed_str = self._format_time(elapsed_time)
|
63
71
|
# 预估剩余时间
|
64
|
-
if self.
|
65
|
-
estimated_time = elapsed_time / self.current * (self.
|
72
|
+
if self.range_len is not None:
|
73
|
+
estimated_time = elapsed_time / self.current * (self.range_len - self.current) if self.current > 0 else 0
|
66
74
|
estimated_str = self._format_time(estimated_time)
|
67
75
|
# 计算每秒处理的项数
|
68
76
|
speed = self.current / elapsed_time if elapsed_time > 0 else 0
|
69
77
|
|
70
78
|
# 更新进度条
|
71
|
-
if self.
|
72
|
-
filled_length = int(self.length * self.current // self.
|
79
|
+
if self.range_len is not None:
|
80
|
+
filled_length = int(self.length * self.current // self.range_len)
|
73
81
|
bar = self.fill * filled_length + '-' * (self.length - filled_length) * len(self.fill)
|
74
82
|
|
75
83
|
sys.stdout.write(f'\r{pre_show}{self.prefix} |{bar}|'
|
76
|
-
f' {self.current}/{self.
|
84
|
+
f' {self.current}/{self.range_len} -> {elapsed_str}<{estimated_str} | {speed:.1f} it/s |'
|
77
85
|
f' {self.suffix}{B_Color.RESET.value}')
|
78
86
|
else:
|
79
87
|
sys.stdout.write(f'\r{pre_show}{self.prefix} | {self.current} iters -> {elapsed_str} | {speed:.1f} it/s |'
|
@@ -81,6 +89,11 @@ class B_Tqdm:
|
|
81
89
|
sys.stdout.flush()
|
82
90
|
|
83
91
|
# 补回车
|
84
|
-
if self.current == self.
|
92
|
+
if self.current == self.range_len:
|
85
93
|
sys.stdout.write('\n')
|
86
94
|
sys.stdout.flush()
|
95
|
+
|
96
|
+
def __iter__(self):
|
97
|
+
for item in self.range:
|
98
|
+
yield item
|
99
|
+
self.update()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|