byzh-core 0.0.9.2__tar.gz → 0.0.9.4__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 (31) hide show
  1. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/PKG-INFO +1 -1
  2. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Brecorder/record2d.py +40 -10
  3. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh_core.egg-info/PKG-INFO +1 -1
  4. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/LICENSE +0 -0
  5. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/README.md +0 -0
  6. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/B_os.py +0 -0
  7. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Barchive/__init__.py +0 -0
  8. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Barchive/archive.py +0 -0
  9. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Brecorder/__init__.py +0 -0
  10. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Brecorder/record1d.py +0 -0
  11. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Btable/__init__.py +0 -0
  12. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Btable/auto_table.py +0 -0
  13. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Bterminal/__init__.py +0 -0
  14. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Bterminal/cmd.py +0 -0
  15. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Bterminal/run_func.py +0 -0
  16. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Btqdm/__init__.py +0 -0
  17. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Btqdm/my_tqdm.py +0 -0
  18. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Butils/__init__.py +0 -0
  19. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Butils/decorator.py +0 -0
  20. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Butils/text_style.py +0 -0
  21. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Butils/timer.py +0 -0
  22. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Bwriter/__init__.py +0 -0
  23. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/Bwriter/writer.py +0 -0
  24. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh/core/__init__.py +0 -0
  25. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh_core.egg-info/SOURCES.txt +0 -0
  26. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh_core.egg-info/dependency_links.txt +0 -0
  27. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh_core.egg-info/entry_points.txt +0 -0
  28. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh_core.egg-info/requires.txt +0 -0
  29. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/byzh_core.egg-info/top_level.txt +0 -0
  30. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/setup.cfg +0 -0
  31. {byzh_core-0.0.9.2 → byzh_core-0.0.9.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: byzh-core
3
- Version: 0.0.9.2
3
+ Version: 0.0.9.4
4
4
  Summary: byzh-core是byzh系列的核心库,包含了一些常用的工具函数和类。
5
5
  Author: byzh_rc
6
6
  License: MIT
@@ -2,10 +2,12 @@ import pandas as pd
2
2
  from typing import Literal
3
3
 
4
4
  from .. import B_os
5
+ # from byzh.core import B_os
5
6
 
6
7
  class B_Record2d:
7
- def __init__(self, csv_path, mode:Literal["w", "a"]="w"):
8
+ def __init__(self, csv_path, mode:Literal["w", "a", "r"]="r"):
8
9
  self.csv_path = csv_path
10
+ self.mode = mode
9
11
 
10
12
  B_os.makedirs(csv_path)
11
13
  self.data = pd.DataFrame()
@@ -14,19 +16,45 @@ class B_Record2d:
14
16
  self.__read()
15
17
  elif mode == "a":
16
18
  self.__read()
19
+ elif mode == "r":
20
+ self.__read()
17
21
 
18
22
  # 支持 recorder[row, col] 访问
19
23
  def __getitem__(self, key):
20
- row, col = key
21
- row, col = str(row), str(col)
22
- return self.data.loc[row, col]
24
+ if isinstance(key, tuple) and len(key) == 2: # 读值操作
25
+ row, col = key
26
+ row, col = str(row), str(col)
27
+ return self.data.loc[row, col]
28
+ if isinstance(key, str): # 读行操作
29
+ row = str(key)
30
+ return self.data.loc[row, :]
23
31
 
24
32
  # 支持 recorder[row, col] = value
25
33
  def __setitem__(self, key, value):
26
- row, col = key
27
- row, col, value = str(row), str(col), str(value)
28
- self.data.loc[row, col] = value
34
+ assert self.mode!="r", "不允许读模式下赋值"
35
+
36
+ if isinstance(key, tuple) and len(key) == 2: # 赋值操作
37
+ row, col = key
38
+ row, col, value = str(row), str(col), str(value)
39
+ self.data.loc[row, col] = value
40
+ self.__save()
41
+ if isinstance(key, str): # 赋值行操作
42
+ assert type(value) == pd.Series, "仅支持 Series 赋值"
43
+ key = str(key)
44
+ self.data.loc[key, :] = value.copy()
45
+
46
+ # 复制一行
47
+ def copy_row(self, new_row, origin_row):
48
+ new_row, origin_row = str(new_row), str(origin_row)
49
+
50
+ if origin_row not in self.data.index:
51
+ raise KeyError(f"源行 {origin_row} 不存在")
52
+
53
+ # 深拷贝一份行数据
54
+ self.data.loc[new_row] = self.data.loc[origin_row].copy()
55
+
29
56
  self.__save()
57
+ return self
30
58
 
31
59
  # 转置
32
60
  def T(self):
@@ -51,10 +79,10 @@ class B_Record2d:
51
79
  return float(self[row, col])
52
80
 
53
81
  def get_bool(self, row, col) -> bool:
54
- result = self[row, col]
55
- if result in ("True", "true", "1"):
82
+ result:str = self[row, col]
83
+ if result.lower() in ("true", "1"):
56
84
  return True
57
- elif result in ("False", "false", "0"):
85
+ elif result.lower() in ("false", "0"):
58
86
  return False
59
87
  else:
60
88
  raise ValueError(f"无法转换为布尔值 -> {result}")
@@ -85,6 +113,8 @@ if __name__ == '__main__':
85
113
  recorder["qwq", "OvO"] = 30
86
114
  recorder["qwq", "TwT"] = 40
87
115
 
116
+ recorder['aaa'] = recorder['qwwq']
117
+
88
118
  print("当前内容:")
89
119
  print(recorder)
90
120
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: byzh-core
3
- Version: 0.0.9.2
3
+ Version: 0.0.9.4
4
4
  Summary: byzh-core是byzh系列的核心库,包含了一些常用的工具函数和类。
5
5
  Author: byzh_rc
6
6
  License: MIT
File without changes
File without changes
File without changes
File without changes