byzh-core 0.0.2__tar.gz → 0.0.2.1__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.
Files changed (39) hide show
  1. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/PKG-INFO +1 -1
  2. byzh_core-0.0.2.1/byzh_core/Btqdm/__init__.py +4 -0
  3. byzh_core-0.0.2.1/byzh_core/Btqdm/my_tqdm.py +80 -0
  4. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/__init__.py +1 -1
  5. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core.egg-info/PKG-INFO +1 -1
  6. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core.egg-info/SOURCES.txt +1 -1
  7. byzh_core-0.0.2/byzh_core/Btqdm/__init__.py +0 -4
  8. byzh_core-0.0.2/byzh_core/Btqdm/b_tqdm.py +0 -76
  9. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/LICENSE +0 -0
  10. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/README.md +0 -0
  11. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Barchive/__init__.py +0 -0
  12. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Barchive/archive.py +0 -0
  13. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bbasic/__init__.py +0 -0
  14. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bbasic/text_style.py +0 -0
  15. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bconfig/__init__.py +0 -0
  16. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bconfig/config.py +0 -0
  17. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bmath/__init__.py +0 -0
  18. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bmath/divides.py +0 -0
  19. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bmath/get_norm.py +0 -0
  20. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bos/__init__.py +0 -0
  21. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bos/make.py +0 -0
  22. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bos/path.py +0 -0
  23. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bos/remove.py +0 -0
  24. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Btable/__init__.py +0 -0
  25. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Btable/auto_table.py +0 -0
  26. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Btable/obsolete/__init__.py +0 -0
  27. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Btable/obsolete/b_auto_table.py +0 -0
  28. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Btable/row_table.py +0 -0
  29. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Btable/xy_table.py +0 -0
  30. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bterminal/__init__.py +0 -0
  31. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bterminal/cmd.py +0 -0
  32. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bwriter/__init__.py +0 -0
  33. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bwriter/globalwriter.py +0 -0
  34. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core/Bwriter/writer.py +0 -0
  35. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core.egg-info/dependency_links.txt +0 -0
  36. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core.egg-info/requires.txt +0 -0
  37. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/byzh_core.egg-info/top_level.txt +0 -0
  38. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/setup.cfg +0 -0
  39. {byzh_core-0.0.2 → byzh_core-0.0.2.1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: byzh_core
3
- Version: 0.0.2
3
+ Version: 0.0.2.1
4
4
  Summary: byzh_core是byzh系列的核心库,包含了一些常用的工具函数和类。
5
5
  Author: byzh_rc
6
6
  License: MIT
@@ -0,0 +1,4 @@
1
+
2
+ from .my_tqdm import B_Tqdm
3
+
4
+ __all__ = ['B_Tqdm']
@@ -0,0 +1,80 @@
1
+ import sys
2
+ import time
3
+ import threading
4
+
5
+ from ..Bbasic import B_Color
6
+
7
+
8
+ class B_Tqdm:
9
+ def __init__(
10
+ self,
11
+ total: int|None = None,
12
+ prefix: str = 'Processing',
13
+ suffix: str = '',
14
+ length: int = 20,
15
+ fill: str = '█',
16
+ ):
17
+ """
18
+ 类似tqdm的进度条
19
+ :param total: 总数
20
+ :param prefix: 前缀
21
+ :param suffix: 后缀
22
+ :param length: 进度条长度(字符)
23
+ :param fill: 填充字符
24
+ """
25
+ super().__init__()
26
+ self.total = total
27
+ self.prefix = prefix
28
+ self.suffix = suffix
29
+ self.length = length
30
+ self.fill = fill
31
+ self.start_time = 0
32
+ self.current = 0
33
+
34
+ self._lock = threading.Lock()
35
+
36
+ def _format_time(self, seconds):
37
+ """将秒数转换为mm:ss格式"""
38
+ minutes = int(seconds // 60)
39
+ seconds = int(seconds % 60)
40
+ return f'{minutes:02}:{seconds:02}'
41
+
42
+ def update(self, step=1, color=B_Color.BLUE, prefix=None, suffix=None):
43
+ with self._lock:
44
+ if self.current == 0:
45
+ self.start_time = time.time()
46
+ if prefix is not None:
47
+ self.prefix = prefix
48
+ if suffix is not None:
49
+ self.suffix = suffix
50
+
51
+ # 更新进度
52
+ self.current += step
53
+
54
+ # 计算已用时间
55
+ elapsed_time = time.time() - self.start_time
56
+ elapsed_str = self._format_time(elapsed_time)
57
+ # 预估剩余时间
58
+ if self.total is not None:
59
+ estimated_time = elapsed_time / self.current * (self.total - self.current) if self.current > 0 else 0
60
+ estimated_str = self._format_time(estimated_time)
61
+ # 计算每秒处理的项数
62
+ speed = self.current / elapsed_time if elapsed_time > 0 else 0
63
+
64
+ # 更新进度条
65
+ if self.total is not None:
66
+ filled_length = int(self.length * self.current // self.total)
67
+ bar = self.fill * filled_length + '-' * (self.length - filled_length)
68
+
69
+ sys.stdout.write(f'\r{color}{self.prefix} |{bar}|'
70
+ f' {self.current}/{self.total} -> {elapsed_str}<{estimated_str} | {speed:.1f} it/s |'
71
+ f' {self.suffix}{B_Color.RESET}')
72
+ else:
73
+ sys.stdout.write(f'\r{color}{self.prefix} | {self.current} iters -> {elapsed_str} | {speed:.1f} it/s |'
74
+ f' {self.suffix}{B_Color.RESET}')
75
+ sys.stdout.flush()
76
+
77
+ # 补回车
78
+ if self.current == self.total:
79
+ sys.stdout.write('\n')
80
+ sys.stdout.flush()
@@ -2,4 +2,4 @@
2
2
  # class 以"B_"开头
3
3
  # function 以"b_"开头
4
4
 
5
- __version__ = '0.0.2'
5
+ __version__ = '0.0.2.1'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: byzh_core
3
- Version: 0.0.2
3
+ Version: 0.0.2.1
4
4
  Summary: byzh_core是byzh系列的核心库,包含了一些常用的工具函数和类。
5
5
  Author: byzh_rc
6
6
  License: MIT
@@ -29,7 +29,7 @@ byzh_core/Btable/obsolete/b_auto_table.py
29
29
  byzh_core/Bterminal/__init__.py
30
30
  byzh_core/Bterminal/cmd.py
31
31
  byzh_core/Btqdm/__init__.py
32
- byzh_core/Btqdm/b_tqdm.py
32
+ byzh_core/Btqdm/my_tqdm.py
33
33
  byzh_core/Bwriter/__init__.py
34
34
  byzh_core/Bwriter/globalwriter.py
35
35
  byzh_core/Bwriter/writer.py
@@ -1,4 +0,0 @@
1
-
2
- from .b_tqdm import B_Tqdm
3
-
4
- __all__ = ['B_Tqdm']
@@ -1,76 +0,0 @@
1
- import sys
2
- import time
3
-
4
- from ..Bbasic import B_Color
5
-
6
-
7
- class B_Tqdm:
8
- def __init__(
9
- self,
10
- total: int|None = None,
11
- prefix: str = 'Processing',
12
- suffix: str = '',
13
- length: int = 20,
14
- fill: str = '█',
15
- ):
16
- """
17
- 类似tqdm的进度条
18
- :param total: 总数
19
- :param prefix: 前缀
20
- :param suffix: 后缀
21
- :param length: 进度条长度(字符)
22
- :param fill: 填充字符
23
- """
24
- super().__init__()
25
- self.total = total
26
- self.prefix = prefix
27
- self.suffix = suffix
28
- self.length = length
29
- self.fill = fill
30
- self.start_time = 0
31
- self.current = 0
32
-
33
- def _format_time(self, seconds):
34
- """将秒数转换为mm:ss格式"""
35
- minutes = int(seconds // 60)
36
- seconds = int(seconds % 60)
37
- return f'{minutes:02}:{seconds:02}'
38
-
39
- def update(self, step=1, color=B_Color.BLUE, prefix=None, suffix=None):
40
- if self.current == 0:
41
- self.start_time = time.time()
42
- if prefix is not None:
43
- self.prefix = prefix
44
- if suffix is not None:
45
- self.suffix = suffix
46
-
47
- # 更新进度
48
- self.current += step
49
-
50
- # 计算已用时间
51
- elapsed_time = time.time() - self.start_time
52
- elapsed_str = self._format_time(elapsed_time)
53
- # 预估剩余时间
54
- if self.total is not None:
55
- estimated_time = elapsed_time / self.current * (self.total - self.current) if self.current > 0 else 0
56
- estimated_str = self._format_time(estimated_time)
57
- # 计算每秒处理的项数
58
- speed = self.current / elapsed_time if elapsed_time > 0 else 0
59
-
60
- # 更新进度条
61
- if self.total is not None:
62
- filled_length = int(self.length * self.current // self.total)
63
- bar = self.fill * filled_length + '-' * (self.length - filled_length)
64
-
65
- sys.stdout.write(f'\r{color}{self.prefix} |{bar}|'
66
- f' {self.current}/{self.total} -> {elapsed_str}<{estimated_str} | {speed:.1f} it/s |'
67
- f' {self.suffix}{B_Color.RESET}')
68
- else:
69
- sys.stdout.write(f'\r{color}{self.prefix} | {self.current} iters -> {elapsed_str} | {speed:.1f} it/s |'
70
- f' {self.suffix}{B_Color.RESET}')
71
- sys.stdout.flush()
72
-
73
- # 补回车
74
- if self.current == self.total:
75
- sys.stdout.write('\n')
76
- sys.stdout.flush()
File without changes
File without changes
File without changes
File without changes