byzh-core 0.0.6.0__py3-none-any.whl → 0.0.8.0__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 → byzh/core}/B_os.py +1 -1
- byzh/core/Brecorder/__init__.py +4 -0
- byzh/core/Brecorder/record1d.py +71 -0
- byzh/core/Brecorder/record2d.py +86 -0
- {byzh_core → byzh/core}/Bterminal/cmd.py +7 -6
- byzh/core/__init__.py +0 -0
- {byzh_core-0.0.6.0.dist-info → byzh_core-0.0.8.0.dist-info}/METADATA +2 -2
- byzh_core-0.0.8.0.dist-info/RECORD +26 -0
- byzh_core-0.0.8.0.dist-info/top_level.txt +1 -0
- byzh_core/__init__.py +0 -5
- byzh_core/__main__.py +0 -9
- byzh_core/obsolete/Bconfig/__init__.py +0 -3
- byzh_core/obsolete/Bconfig/config.py +0 -328
- byzh_core/obsolete/__init__.py +0 -6
- byzh_core/obsolete/auto_table.py +0 -427
- byzh_core/obsolete/row_table.py +0 -175
- byzh_core/obsolete/xy_table.py +0 -211
- byzh_core-0.0.6.0.dist-info/RECORD +0 -30
- byzh_core-0.0.6.0.dist-info/top_level.txt +0 -1
- {byzh_core → byzh/core}/Barchive/__init__.py +0 -0
- {byzh_core → byzh/core}/Barchive/archive.py +0 -0
- {byzh_core → byzh/core}/Btable/__init__.py +0 -0
- {byzh_core → byzh/core}/Btable/auto_table.py +0 -0
- {byzh_core → byzh/core}/Bterminal/__init__.py +0 -0
- {byzh_core → byzh/core}/Bterminal/run_func.py +0 -0
- {byzh_core → byzh/core}/Btqdm/__init__.py +0 -0
- {byzh_core → byzh/core}/Btqdm/my_tqdm.py +0 -0
- {byzh_core → byzh/core}/Butils/__init__.py +0 -0
- {byzh_core → byzh/core}/Butils/decorator.py +0 -0
- {byzh_core → byzh/core}/Butils/text_style.py +0 -0
- {byzh_core → byzh/core}/Butils/timer.py +0 -0
- {byzh_core → byzh/core}/Bwriter/__init__.py +0 -0
- {byzh_core → byzh/core}/Bwriter/writer.py +0 -0
- {byzh_core-0.0.6.0.dist-info → byzh_core-0.0.8.0.dist-info}/LICENSE +0 -0
- {byzh_core-0.0.6.0.dist-info → byzh_core-0.0.8.0.dist-info}/WHEEL +0 -0
- {byzh_core-0.0.6.0.dist-info → byzh_core-0.0.8.0.dist-info}/entry_points.txt +0 -0
byzh_core/obsolete/xy_table.py
DELETED
@@ -1,211 +0,0 @@
|
|
1
|
-
import copy
|
2
|
-
import math
|
3
|
-
from typing import List, Tuple, Union
|
4
|
-
Seq = Union[List, Tuple]
|
5
|
-
try:
|
6
|
-
from wcwidth import wcswidth
|
7
|
-
except ImportError:
|
8
|
-
print("[text table] 请先安装wcwidth库: pip install wcwidth")
|
9
|
-
|
10
|
-
class MyDict:
|
11
|
-
def __init__(self, init_dict:dict|None = None):
|
12
|
-
self.dict = init_dict if init_dict is not None else dict()
|
13
|
-
|
14
|
-
def update(self, other_dict):
|
15
|
-
self.dict.update(other_dict)
|
16
|
-
|
17
|
-
def items(self):
|
18
|
-
return self.dict.items()
|
19
|
-
def keys(self):
|
20
|
-
return self.dict.keys()
|
21
|
-
def values(self):
|
22
|
-
return self.dict.values()
|
23
|
-
|
24
|
-
def __getitem__(self, item):
|
25
|
-
return self.dict[str(item)]
|
26
|
-
|
27
|
-
def __setitem__(self, key, value):
|
28
|
-
self.dict[str(key)] = value
|
29
|
-
|
30
|
-
class B_XYTable:
|
31
|
-
def __init__(self, x_name, y_name, x_sidebars=[], y_sidebars=[]):
|
32
|
-
self.x_sidebars = self._seq2strlist(x_sidebars)
|
33
|
-
self.y_sidebars = self._seq2strlist(y_sidebars)
|
34
|
-
self.x_name = x_name
|
35
|
-
self.y_name = y_name
|
36
|
-
self.dict = self._create_dict(self.x_sidebars, self.y_sidebars)
|
37
|
-
self._widths = {x: 0 for x in self.y_sidebars}
|
38
|
-
self._update_widths(MyDict({y: y for y in self.y_sidebars}))
|
39
|
-
|
40
|
-
def set(self, x_sidebar, y_sidebar, content):
|
41
|
-
x_sidebar, y_sidebar, content = str(x_sidebar), str(y_sidebar), str(content)
|
42
|
-
assert x_sidebar in self.dict.keys(), "x_sidebar 与 不是指定好的属性"
|
43
|
-
assert y_sidebar in self.dict[x_sidebar].keys(), "y_sidebar 与 不是指定好的属性"
|
44
|
-
self.dict[x_sidebar][y_sidebar] = str(content)
|
45
|
-
|
46
|
-
def get(self, x_sidebar, y_sidebar):
|
47
|
-
return self.dict[x_sidebar][y_sidebar]
|
48
|
-
def items(self):
|
49
|
-
'''
|
50
|
-
(key1, key2, value)
|
51
|
-
'''
|
52
|
-
result = [(x, y, self.dict[x][y]) for x in self.x_sidebars for y in self.y_sidebars]
|
53
|
-
return result
|
54
|
-
|
55
|
-
def get_table_by_strs(self) -> List[str]:
|
56
|
-
results = self._create_prefix()
|
57
|
-
|
58
|
-
for x in self.dict.values():
|
59
|
-
self._update_widths(x)
|
60
|
-
|
61
|
-
str_dash = ''
|
62
|
-
str_head = ''
|
63
|
-
for y in self.y_sidebars:
|
64
|
-
pre_space, suf_space = self._get_prefix_suffix(y, self._widths[y], ' ')
|
65
|
-
pre_dash, suf_dash = self._get_prefix_suffix('-', self._widths[y], '-')
|
66
|
-
str_head += ' ' + pre_space + y + suf_space + ' |'
|
67
|
-
str_dash += '-' + pre_dash + '-' + suf_dash + '-+'
|
68
|
-
results[0] += str_dash
|
69
|
-
results[1] += str_head
|
70
|
-
results[2] += str_dash
|
71
|
-
|
72
|
-
offset = 3
|
73
|
-
for index, y_dicts in enumerate(self.dict.values()):
|
74
|
-
for key, value in y_dicts.items():
|
75
|
-
pre_space, suf_space = self._get_prefix_suffix(value, self._widths[key], ' ')
|
76
|
-
str_content = ' ' + pre_space + value + suf_space + ' |'
|
77
|
-
results[index+offset] += str_content
|
78
|
-
|
79
|
-
results[-1] += str_dash
|
80
|
-
|
81
|
-
return results
|
82
|
-
|
83
|
-
def get_table_by_str(self) -> str:
|
84
|
-
result = ""
|
85
|
-
strs = self.get_table_by_strs()
|
86
|
-
for x in strs[:-1]:
|
87
|
-
result += x + '\n'
|
88
|
-
result += strs[-1]
|
89
|
-
|
90
|
-
return result
|
91
|
-
def print_table(self):
|
92
|
-
print(self.get_table_by_str())
|
93
|
-
|
94
|
-
def _create_dict(self, seq1, seq2):
|
95
|
-
result = dict()
|
96
|
-
for x in seq1:
|
97
|
-
temp = MyDict()
|
98
|
-
for y in seq2:
|
99
|
-
temp.update({y: ''})
|
100
|
-
result.update({x: temp})
|
101
|
-
|
102
|
-
return result
|
103
|
-
|
104
|
-
def _create_prefix(self):
|
105
|
-
'''
|
106
|
-
得到
|
107
|
-
+-------+
|
108
|
-
| x \ y |
|
109
|
-
+-------+
|
110
|
-
| 1 |
|
111
|
-
| 2 |
|
112
|
-
| 3 |
|
113
|
-
+-------+
|
114
|
-
'''
|
115
|
-
results = []
|
116
|
-
|
117
|
-
title = self.x_name + " \ " + self.y_name
|
118
|
-
n = self._get_maxlength_from_list(self.x_sidebars)
|
119
|
-
length = max(n, self._get_width(title))
|
120
|
-
|
121
|
-
pre_dash, suf_dash = self._get_prefix_suffix("-", length, '-')
|
122
|
-
str_dash = "+-" + pre_dash + "-" + suf_dash + "-+"
|
123
|
-
results.append(str_dash)
|
124
|
-
|
125
|
-
pre_space, suf_space = self._get_prefix_suffix(title, length, ' ')
|
126
|
-
str_index = "| " + pre_space + title + suf_space + " |"
|
127
|
-
results.append(str_index)
|
128
|
-
results.append(str_dash)
|
129
|
-
|
130
|
-
for x in self.x_sidebars:
|
131
|
-
pre_space, suf_space = self._get_prefix_suffix(x, length, ' ')
|
132
|
-
str_number = "| " + pre_space + x + suf_space + " |"
|
133
|
-
results.append(str_number)
|
134
|
-
results.append(str_dash)
|
135
|
-
|
136
|
-
return results
|
137
|
-
|
138
|
-
def _get_prefix_suffix(self, string, length, charactor=' '):
|
139
|
-
prefix = ''
|
140
|
-
suffix = ''
|
141
|
-
str_len = self._get_width(string)
|
142
|
-
|
143
|
-
delta = length - str_len
|
144
|
-
if delta < 0:
|
145
|
-
assert "string的宽度比length宽"
|
146
|
-
elif delta == 0:
|
147
|
-
pass
|
148
|
-
else:
|
149
|
-
prefix = charactor * math.floor(delta / 2)
|
150
|
-
suffix = charactor * math.ceil(delta / 2)
|
151
|
-
|
152
|
-
return prefix, suffix
|
153
|
-
|
154
|
-
def _get_maxlength_from_list(self, lst: List[str]) -> int:
|
155
|
-
temp = [self._get_width(x) for x in lst]
|
156
|
-
if len(temp) == 0:
|
157
|
-
return 0
|
158
|
-
else:
|
159
|
-
return max(temp)
|
160
|
-
|
161
|
-
def _update_widths(self, new_dict: MyDict):
|
162
|
-
temps = copy.deepcopy(self._widths)
|
163
|
-
for key, value in new_dict.items():
|
164
|
-
temps[key] = self._get_width(value)
|
165
|
-
|
166
|
-
if len(self._widths) == 0:
|
167
|
-
self._widths = temps
|
168
|
-
else:
|
169
|
-
for key, value in temps.items():
|
170
|
-
if value > self._widths[key]:
|
171
|
-
self._widths[key] = value
|
172
|
-
|
173
|
-
def _seq2strlist(self, seq):
|
174
|
-
seq = copy.deepcopy(list(seq))
|
175
|
-
for i, x in enumerate(seq):
|
176
|
-
seq[i] = str(x)
|
177
|
-
|
178
|
-
return seq
|
179
|
-
|
180
|
-
def _get_width(self, string):
|
181
|
-
return wcswidth(string)
|
182
|
-
|
183
|
-
def __len__(self):
|
184
|
-
return len(self.x_sidebars) * len(self.y_sidebars)
|
185
|
-
def __contains__(self, item):
|
186
|
-
for x in self.x_sidebars:
|
187
|
-
for y in self.y_sidebars:
|
188
|
-
if str(item) == self.dict[x][y]:
|
189
|
-
return True
|
190
|
-
return False
|
191
|
-
def __str__(self):
|
192
|
-
return self.get_table_by_str()
|
193
|
-
|
194
|
-
def __getitem__(self, index):
|
195
|
-
return self.dict[str(index)]
|
196
|
-
def __setitem__(self, index, value):
|
197
|
-
self.dict[index] = value
|
198
|
-
if __name__ == '__main__':
|
199
|
-
my_table = B_XYTable("x", "y", [123, 234], [345, 456])
|
200
|
-
|
201
|
-
my_table[123]['345'] = 'qwq'
|
202
|
-
my_table['123']['456'] = '456'
|
203
|
-
my_table.set(234, '345', "awwwa")
|
204
|
-
my_table.set('234', '456', "123")
|
205
|
-
|
206
|
-
print(my_table)
|
207
|
-
print(my_table[123][345])
|
208
|
-
for key1, key2, value in my_table.items():
|
209
|
-
print(key1, key2, value)
|
210
|
-
|
211
|
-
print('qwq' in my_table)
|
@@ -1,30 +0,0 @@
|
|
1
|
-
byzh_core/B_os.py,sha256=f8XuZZOMnP0Fszg6oPLlo9kxX1ytJBK8cEoHqzVkMVA,4313
|
2
|
-
byzh_core/__init__.py,sha256=mCVeV36AbtVmNRcAo5lRjksvR-d-BhsBeEhVe8w9wW0,156
|
3
|
-
byzh_core/__main__.py,sha256=o7-Mn6j1g-VGWhE13goDOMmxKSlXvtrkYVkwt4DrCjo,217
|
4
|
-
byzh_core/Barchive/__init__.py,sha256=wUdz646VS0Uhq9lwMkd3YQHCvQhLDqgADoDjFGMqIn0,65
|
5
|
-
byzh_core/Barchive/archive.py,sha256=S1hy3qYFEZr5RRmx_Mnq1s2IMUEw973ny1rKSL7J_a0,6721
|
6
|
-
byzh_core/Btable/__init__.py,sha256=NlQBjp_mvObEUm4y6wXbGipkNM2N3uNIUidaJkTwFsw,62
|
7
|
-
byzh_core/Btable/auto_table.py,sha256=avMeRWydw9L8s3fU0-BSl8a2dCyreIUzW--csm5eR0g,14734
|
8
|
-
byzh_core/Bterminal/__init__.py,sha256=azRLD-kY8Tv2c3llHRBrEJIdVgYw6hAoLgzJeA4PvE0,142
|
9
|
-
byzh_core/Bterminal/cmd.py,sha256=nnEkZiAwPgm_guc0E6yvSTD7aT1u5eTvsShf5XkO-oI,3851
|
10
|
-
byzh_core/Bterminal/run_func.py,sha256=B2CZSxdSrcBbt7w5_hnOYrUmwrjK5CPqbyyt_YkB_I0,1836
|
11
|
-
byzh_core/Btqdm/__init__.py,sha256=G8pvJYizvdTUI3Xw-yELXY7BbjTghCXJLdqUuDoRNZA,141
|
12
|
-
byzh_core/Btqdm/my_tqdm.py,sha256=MMYFwy5dUCzg8fzRWZ7vrpZ-q_DDqoLvywDk8rgSaSM,3578
|
13
|
-
byzh_core/Butils/__init__.py,sha256=_0aAm72oynvpFf-v9EAMSqhWBHbTt4Tn85jtv3Yf0z8,236
|
14
|
-
byzh_core/Butils/decorator.py,sha256=HaB8F80wsqQuS30jlI8C2d3SmEa0mBNfJEr5-pwGZj0,584
|
15
|
-
byzh_core/Butils/text_style.py,sha256=34u2-Rsur63iNQ0m7tHxpFWqnQZWybSxBx7vnhOhqDo,3346
|
16
|
-
byzh_core/Butils/timer.py,sha256=OLxbWWRauYjp1KwavACjoyrqrCciUiIG2ae7qgtZrVA,511
|
17
|
-
byzh_core/Bwriter/__init__.py,sha256=QcHzKs0305Pr78ZvZgcC_4miSYZh8jJQDt5TD0GIeEg,82
|
18
|
-
byzh_core/Bwriter/writer.py,sha256=ss9EWo-l7czBUlY7Fu0buvQgO5fRspYKtC2X6eaRa0c,3213
|
19
|
-
byzh_core/obsolete/__init__.py,sha256=wpfHMPD4awPRDJVYlaiGtkkpjq2srWB7d7LrWhoX5R0,161
|
20
|
-
byzh_core/obsolete/auto_table.py,sha256=nC9eHj_IIGVkS2lmN_1gtOyglLCaGlwdoHzPvNNQDEw,13952
|
21
|
-
byzh_core/obsolete/row_table.py,sha256=rIX0-Yvb3RnO0RJBkA4m18gux1zYSnEKTy6uQGcWilc,5999
|
22
|
-
byzh_core/obsolete/xy_table.py,sha256=-KHK8EUlkJj3Rh0sp_KHI0QFt29AlMASMmR8q8ykUBM,6784
|
23
|
-
byzh_core/obsolete/Bconfig/__init__.py,sha256=7lAp7wNetW0AyJcike7ekdY_8wrQQtFjBsi6684t_lU,54
|
24
|
-
byzh_core/obsolete/Bconfig/config.py,sha256=_gUNHfW46mTRecYsz_DQn0LENEPifcF3IMHFVE1prgg,10953
|
25
|
-
byzh_core-0.0.6.0.dist-info/LICENSE,sha256=-nRwf0Xga4AX5bsWBXXflpDpgX_U23X06oAMcdf0dSY,1089
|
26
|
-
byzh_core-0.0.6.0.dist-info/METADATA,sha256=E1Tb3JDcoj8YGN0jQuGpQ5op5uAEBXO-cFEWvEHIVFA,371
|
27
|
-
byzh_core-0.0.6.0.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
28
|
-
byzh_core-0.0.6.0.dist-info/entry_points.txt,sha256=qoN3Uvulj0BcOQVDqsFqP2dBVQzG1QrUtC5wFsghSLo,51
|
29
|
-
byzh_core-0.0.6.0.dist-info/top_level.txt,sha256=Xv-pzvl6kPdIbi5UehQcUdGhLtb8-4WhS5dRK1LINwM,10
|
30
|
-
byzh_core-0.0.6.0.dist-info/RECORD,,
|
@@ -1 +0,0 @@
|
|
1
|
-
byzh_core
|
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
|