byzh-core 0.0.5.0__tar.gz → 0.0.7.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.
Files changed (40) hide show
  1. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/PKG-INFO +2 -2
  2. byzh_core-0.0.7.0/byzh/Brecorder/__init__.py +4 -0
  3. byzh_core-0.0.7.0/byzh/Brecorder/record1d.py +70 -0
  4. byzh_core-0.0.7.0/byzh/Brecorder/record2d.py +86 -0
  5. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Bterminal/cmd.py +9 -8
  6. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/byzh_core.egg-info/PKG-INFO +2 -2
  7. byzh_core-0.0.7.0/byzh_core.egg-info/SOURCES.txt +33 -0
  8. byzh_core-0.0.7.0/byzh_core.egg-info/top_level.txt +1 -0
  9. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/setup.py +5 -5
  10. byzh_core-0.0.5.0/byzh_core/B_os.py +0 -157
  11. byzh_core-0.0.5.0/byzh_core/__init__.py +0 -5
  12. byzh_core-0.0.5.0/byzh_core/__main__.py +0 -9
  13. byzh_core-0.0.5.0/byzh_core.egg-info/SOURCES.txt +0 -33
  14. byzh_core-0.0.5.0/byzh_core.egg-info/top_level.txt +0 -1
  15. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/LICENSE +0 -0
  16. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/README.md +0 -0
  17. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Barchive/__init__.py +0 -0
  18. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Barchive/archive.py +0 -0
  19. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Btable/__init__.py +0 -0
  20. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Btable/auto_table.py +0 -0
  21. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Bterminal/__init__.py +0 -0
  22. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Bterminal/run_func.py +0 -0
  23. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Btqdm/__init__.py +0 -0
  24. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Btqdm/my_tqdm.py +0 -0
  25. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Butils/__init__.py +0 -0
  26. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Butils/decorator.py +0 -0
  27. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Butils/text_style.py +0 -0
  28. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Butils/timer.py +0 -0
  29. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Bwriter/__init__.py +0 -0
  30. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/Bwriter/writer.py +0 -0
  31. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/obsolete/Bconfig/__init__.py +0 -0
  32. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/obsolete/Bconfig/config.py +0 -0
  33. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/obsolete/__init__.py +0 -0
  34. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/obsolete/auto_table.py +0 -0
  35. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/obsolete/row_table.py +0 -0
  36. {byzh_core-0.0.5.0/byzh_core → byzh_core-0.0.7.0/byzh}/obsolete/xy_table.py +0 -0
  37. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/byzh_core.egg-info/dependency_links.txt +0 -0
  38. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/byzh_core.egg-info/entry_points.txt +0 -0
  39. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/byzh_core.egg-info/requires.txt +0 -0
  40. {byzh_core-0.0.5.0 → byzh_core-0.0.7.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: byzh_core
3
- Version: 0.0.5.0
2
+ Name: byzh-core
3
+ Version: 0.0.7.0
4
4
  Summary: byzh_core是byzh系列的核心库,包含了一些常用的工具函数和类。
5
5
  Author: byzh_rc
6
6
  License: MIT
@@ -0,0 +1,4 @@
1
+ from .record1d import B_Record1d
2
+ from .record2d import B_Record2d
3
+
4
+ __all__ = ['B_Record1d', 'B_Record2d']
@@ -0,0 +1,70 @@
1
+ import pandas as pd
2
+
3
+ from .. import B_os
4
+
5
+ class B_Record1d:
6
+ '''
7
+ recorder = Record_1d(csv_file, mode="w")
8
+ recorder.write(name="Alice", age=25, city="Shanghai")
9
+ recorder.write(name="Bob", age=30, city="Beijing")
10
+ recorder.write(name="Charlie", age=22, city="Shenzhen")
11
+ '''
12
+ def __init__(self, csv_path, mode="a"):
13
+ self.csv_path = csv_path
14
+
15
+ B_os.makedirs(csv_path)
16
+ self.data = pd.DataFrame()
17
+ if mode == "w":
18
+ B_os.rm(csv_path)
19
+ self.__read()
20
+ elif mode == "a":
21
+ self.__read()
22
+
23
+ def write(self, **kwargs):
24
+ '''
25
+ :param kwargs:
26
+ :return:
27
+
28
+ '''
29
+ # 给DataFrame增加一行
30
+ # key作为column, value作为内容
31
+ new_row = pd.DataFrame([kwargs])
32
+ self.data = pd.concat([self.data, new_row], ignore_index=True)
33
+ self.__save()
34
+
35
+ return self
36
+ def __read(self):
37
+ try:
38
+ self.data = pd.read_csv(self.csv_path)
39
+ except FileNotFoundError:
40
+ self.data = pd.DataFrame()
41
+ except pd.errors.EmptyDataError:
42
+ self.data = pd.DataFrame()
43
+
44
+ def __save(self, csv_path=None):
45
+ if csv_path is None:
46
+ csv_path = self.csv_path
47
+ self.data.to_csv(csv_path, index=False, encoding='utf-8-sig')
48
+
49
+ def __str__(self):
50
+ return str(self.data)
51
+
52
+ if __name__ == '__main__':
53
+ # 指定保存的CSV路径
54
+ csv_file = "test_data.csv"
55
+
56
+ # 创建记录器(写模式 w 表示覆盖)
57
+ recorder = B_Record1d(csv_file, mode="w")
58
+
59
+ # 写入几条数据
60
+ recorder.write(name="Alice", age=25, city="Shanghai")
61
+ recorder.write(name="Bob", age=30, city="Beijing")
62
+ recorder.write(name="Charlie", age=22, city="Shenzhen")
63
+
64
+ # 追加模式 a
65
+ recorder2 = B_Record1d(csv_file, mode="a")
66
+ recorder2.write(name="David", age=28, city="Guangzhou")
67
+
68
+ # 打印当前内容
69
+ print("CSV 当前内容:")
70
+ print(recorder2)
@@ -0,0 +1,86 @@
1
+ import pandas as pd
2
+ from typing import Any
3
+
4
+ from .. import B_os
5
+
6
+ class B_Record2d:
7
+ def __init__(self, csv_path, mode="a"):
8
+ self.csv_path = csv_path
9
+
10
+ B_os.makedirs(csv_path)
11
+ self.data = pd.DataFrame()
12
+ if mode == "w":
13
+ B_os.rm(csv_path)
14
+ self.__read()
15
+ elif mode == "a":
16
+ self.__read()
17
+
18
+ def write(self, row, col, value):
19
+ row, col, value = str(row), str(col), str(value)
20
+
21
+ # 如果行不存在,pandas 会自动创建
22
+ # 如果列不存在,pandas 也会自动扩展
23
+ self.data.loc[row, col] = value
24
+
25
+ # 保存
26
+ self.__save()
27
+
28
+ def get(self, row, col) -> Any:
29
+ row, col = str(row), str(col)
30
+ result = self.data.loc[row, col]
31
+ return result
32
+ def get_str(self, row, col) -> str:
33
+ row, col = str(row), str(col)
34
+ result = self.data.loc[row, col]
35
+ return str(result)
36
+
37
+ def get_int(self, row, col) -> int:
38
+ row, col = str(row), str(col)
39
+ result = self.data.loc[row, col]
40
+ return int(result)
41
+ def get_float(self, row, col) -> float:
42
+ row, col = str(row), str(col)
43
+ result = self.data.loc[row, col]
44
+ return float(result)
45
+ def get_bool(self, row, col) -> bool:
46
+ row, col = str(row), str(col)
47
+ result = self.data.loc[row, col]
48
+ if result == "True" or result == "true" or result == "1":
49
+ return True
50
+ elif result == "False" or result == "false" or result == "0":
51
+ return False
52
+ else:
53
+ raise ValueError(f"无法转换为布尔值 -> {result}")
54
+
55
+ def __read(self):
56
+ try:
57
+ self.data = pd.read_csv(self.csv_path, index_col=0)
58
+ except FileNotFoundError:
59
+ self.data = pd.DataFrame()
60
+ except pd.errors.EmptyDataError:
61
+ self.data = pd.DataFrame()
62
+
63
+ def __save(self, csv_path=None):
64
+ if csv_path is None:
65
+ csv_path = self.csv_path
66
+ self.data.to_csv(csv_path, index=True, encoding='utf-8-sig')
67
+
68
+ def __str__(self):
69
+ return str(self.data)
70
+
71
+ if __name__ == '__main__':
72
+ csv_file = "test_data.csv"
73
+
74
+ recorder = B_Record2d(csv_file, mode="w")
75
+
76
+ # 写入一些单元格
77
+ recorder.write("awa", "OvO", 10)
78
+ recorder.write("awa", "TwT", 20)
79
+ recorder.write("qwq", "OvO", 30)
80
+ recorder.write("qwq", "TwT", 40)
81
+
82
+ print("当前内容:")
83
+ print(recorder)
84
+
85
+ recorder = B_Record2d(csv_file, mode="a")
86
+ print(recorder)
@@ -60,11 +60,11 @@ def b_run_python(
60
60
 
61
61
  str_lst = args_process(args)
62
62
 
63
- print(f"{B_Color.GREEN}=====================")
63
+ print(f"{B_Color.GREEN.value}=====================")
64
64
  print("BRunPython 将在3秒后开始:")
65
65
  for string in str_lst:
66
66
  print("\t" + string)
67
- print(f"====================={B_Color.RESET}")
67
+ print(f"====================={B_Color.RESET.value}")
68
68
  time.sleep(3)
69
69
 
70
70
  for string in str_lst:
@@ -92,21 +92,22 @@ def b_run_python(
92
92
  index = str_lst.index(string)
93
93
  str_lst[index] = string + f"\t[!!!Time limit!!!] [{h_t}h {m_t}m {s_t}s]"
94
94
 
95
- print(f"{B_Color.GREEN}====================={B_Color.RESET}")
96
- print(f"{B_Color.GREEN}BRunPython 结束:{B_Color.RESET}")
95
+ print(f"{B_Color.GREEN.value}====================={B_Color.RESET.value}")
96
+ print(f"{B_Color.GREEN.value}BRunPython 结束:{B_Color.RESET.value}")
97
97
  for string in str_lst:
98
98
  if 'Time limit' in string:
99
- print(f"\t{B_Color.YELLOW}" + string + f"{B_Color.RESET}")
99
+ print(f"\t{B_Color.YELLOW.value}" + string + f"{B_Color.RESET.value}")
100
100
  elif 'Error' in string:
101
- print(f"\t{B_Color.RED}" + string + f"{B_Color.RESET}")
101
+ print(f"\t{B_Color.RED.value}" + string + f"{B_Color.RESET.value}")
102
102
  else:
103
- print(f"\t{B_Color.GREEN}" + string + f"{B_Color.RESET}")
104
- print(f"{B_Color.GREEN}====================={B_Color.RESET}")
103
+ print(f"\t{B_Color.GREEN.value}" + string + f"{B_Color.RESET.value}")
104
+ print(f"{B_Color.GREEN.value}====================={B_Color.RESET.value}")
105
105
 
106
106
  run_log('结束')
107
107
 
108
108
 
109
109
 
110
+
110
111
  if __name__ == '__main__':
111
112
  b_run_cmd("echo hello", "echo world", "echo awa", show=True)
112
113
  # b_run_python(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: byzh_core
3
- Version: 0.0.5.0
2
+ Name: byzh-core
3
+ Version: 0.0.7.0
4
4
  Summary: byzh_core是byzh系列的核心库,包含了一些常用的工具函数和类。
5
5
  Author: byzh_rc
6
6
  License: MIT
@@ -0,0 +1,33 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ byzh/Barchive/__init__.py
5
+ byzh/Barchive/archive.py
6
+ byzh/Brecorder/__init__.py
7
+ byzh/Brecorder/record1d.py
8
+ byzh/Brecorder/record2d.py
9
+ byzh/Btable/__init__.py
10
+ byzh/Btable/auto_table.py
11
+ byzh/Bterminal/__init__.py
12
+ byzh/Bterminal/cmd.py
13
+ byzh/Bterminal/run_func.py
14
+ byzh/Btqdm/__init__.py
15
+ byzh/Btqdm/my_tqdm.py
16
+ byzh/Butils/__init__.py
17
+ byzh/Butils/decorator.py
18
+ byzh/Butils/text_style.py
19
+ byzh/Butils/timer.py
20
+ byzh/Bwriter/__init__.py
21
+ byzh/Bwriter/writer.py
22
+ byzh/obsolete/__init__.py
23
+ byzh/obsolete/auto_table.py
24
+ byzh/obsolete/row_table.py
25
+ byzh/obsolete/xy_table.py
26
+ byzh/obsolete/Bconfig/__init__.py
27
+ byzh/obsolete/Bconfig/config.py
28
+ byzh_core.egg-info/PKG-INFO
29
+ byzh_core.egg-info/SOURCES.txt
30
+ byzh_core.egg-info/dependency_links.txt
31
+ byzh_core.egg-info/entry_points.txt
32
+ byzh_core.egg-info/requires.txt
33
+ byzh_core.egg-info/top_level.txt
@@ -1,14 +1,14 @@
1
- from setuptools import setup, find_packages
2
- import byzh_core
1
+ from setuptools import setup, find_namespace_packages
2
+ import byzh
3
3
  setup(
4
- name='byzh_core',
5
- version=byzh_core.__version__,
4
+ name='byzh-core',
5
+ version=byzh.__version__,
6
6
  author="byzh_rc",
7
7
  description="byzh_core是byzh系列的核心库,包含了一些常用的工具函数和类。",
8
8
  long_description=open('README.md').read(),
9
9
  long_description_content_type='text/markdown',
10
10
  license='MIT',
11
- packages=find_packages(),
11
+ packages=find_namespace_packages(include=["byzh.*"]),
12
12
  install_requires=[
13
13
  'wcwidth',
14
14
  ],
@@ -1,157 +0,0 @@
1
- import shutil
2
- import os
3
- from pathlib import Path
4
-
5
- from .Butils import b_validate_params
6
-
7
- @b_validate_params({
8
- "path": __file__
9
- })
10
- def get_parent_dir(path) -> Path:
11
- '''
12
- 获取 该py文件 所在的文件夹
13
- :param path: __file__
14
- '''
15
- parent_dir = Path(path).parent
16
- return parent_dir
17
-
18
- def get_cwd() -> Path:
19
- '''
20
- 获取 当前工作目录current working directory
21
- '''
22
- return Path.cwd()
23
-
24
-
25
- def makedirs(path):
26
- def is_dir(path):
27
- path = Path(path)
28
-
29
- # 存在
30
- if os.path.isdir(path):
31
- return True
32
-
33
- # 不存在
34
- name = path.name
35
- if '.' in name:
36
- return False
37
- return True
38
-
39
- def is_file(path):
40
- path = Path(path)
41
-
42
- # 存在
43
- if os.path.isfile(path):
44
- return True
45
-
46
- # 不存在
47
- name = path.name
48
- if '.' in name:
49
- return True
50
- return False
51
-
52
- path = Path(path)
53
-
54
- if is_dir(path):
55
- os.makedirs(path, exist_ok=True)
56
- if is_file(path):
57
- os.makedirs(path.parent, exist_ok=True)
58
-
59
- def makefile(path):
60
- path = Path(path)
61
-
62
- parent_dir = path.parent
63
- makedirs(parent_dir)
64
-
65
- path.touch() # 创建文件
66
-
67
- def rm(path):
68
- if os.path.isdir(path):
69
- shutil.rmtree(path)
70
- if os.path.isfile(path):
71
- os.remove(path)
72
-
73
-
74
- def get_dirpaths_in_dir(root_dir_path, exclude_dir=['__pycache__', '.git']):
75
- result = []
76
- for root, dirs, files in os.walk(root_dir_path):
77
- for i, dir in enumerate(dirs):
78
- if str(dir) in exclude_dir:
79
- dirs.pop(i)
80
- path = Path(root)
81
- result.append(path)
82
-
83
- result = result[1:]
84
-
85
- return result
86
-
87
- def get_filepaths_in_dir(root_dir_path, exclude_name=[], exclude_suffix=['.pyc'], exclude_dir=['.git']):
88
- file_paths = []
89
- for root, dirs, files in os.walk(root_dir_path):
90
- for i, dir in enumerate(dirs):
91
- if str(dir) in exclude_dir:
92
- dirs.pop(i)
93
- for file in files:
94
- file_path = os.path.join(root, file)
95
- file_path = Path(file_path)
96
- if file_path.name in exclude_name or file_path.suffix in exclude_suffix:
97
- continue
98
- file_paths.append(file_path)
99
- return file_paths
100
-
101
- @b_validate_params({
102
- "black_dirnames": {"examples": ["__pycache__", ".git"]},
103
- "black_filenames": {"examples": ["__init__.py", "test.py"]},
104
- "black_stems": {"examples": ["test", "example"]},
105
- "black_exts": {"examples": [".pyc"]}
106
- })
107
- def walk(
108
- root: str,
109
- black_dirnames: list[str] = None,
110
- black_filenames: list[str] = None,
111
- black_stems: list[str] = None,
112
- black_exts: list[str] = None,
113
- ):
114
- """
115
- 遍历目录, 类似os.walk, 但可以指定黑名单
116
- :param root:
117
- :param black_dirnames:
118
- :param black_stems: 文件名
119
- :param black_stems: 文件名, 不包括后缀
120
- :param black_exts: 文件名的后缀(含.)
121
- :return: root, dirs, files
122
- """
123
-
124
- def get_lst(lst):
125
- return [] if lst is None else lst
126
- black_dirnames = get_lst(black_dirnames)
127
- black_filenames = get_lst(black_filenames)
128
- black_stems = get_lst(black_stems)
129
- black_exts = get_lst(black_exts)
130
-
131
- dirs = []
132
- files = []
133
- for entry in os.listdir(root):
134
- path = os.path.join(root, entry)
135
- # 是文件夹
136
- if os.path.isdir(path):
137
- dirs.append(entry)
138
- # 是文件
139
- elif os.path.isfile(path):
140
- files.append(entry)
141
- else:
142
- continue
143
- dirs = [d for d in dirs if d not in black_dirnames]
144
- files = [f for f in files if f not in black_filenames]
145
- files = [f for f in files if os.path.splitext(f)[0] not in black_stems]
146
- files = [f for f in files if os.path.splitext(f)[1] not in black_exts]
147
-
148
- yield root, dirs, files
149
-
150
- for dirname in dirs:
151
- new_path = os.path.join(root, dirname)
152
- yield from walk(new_path, black_dirnames, black_filenames, black_stems, black_exts)
153
-
154
- if __name__ == '__main__':
155
- # print(get_dirpaths_in_dir(r'E:\byzh_workingplace\byzh-rc-to-pypi'))
156
- a = get_filepaths_in_dir(r'E:\byzh_workingplace\byzh-rc-to-pypi')
157
- print(a)
@@ -1,5 +0,0 @@
1
- # package 以"B"开头
2
- # class 以"B_"开头
3
- # function 以"b_"开头
4
-
5
- __version__ = '0.0.5.0' # core的最后一位保持0, 留给其他包
@@ -1,9 +0,0 @@
1
- import argparse
2
-
3
- def b_zip():
4
- parser = argparse.ArgumentParser()
5
- parser.add_argument("dir_path")
6
- args = parser.parse_args()
7
-
8
- from .Barchive import b_archive_zip
9
- b_archive_zip(args.dir_path)
@@ -1,33 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.py
4
- byzh_core/B_os.py
5
- byzh_core/__init__.py
6
- byzh_core/__main__.py
7
- byzh_core.egg-info/PKG-INFO
8
- byzh_core.egg-info/SOURCES.txt
9
- byzh_core.egg-info/dependency_links.txt
10
- byzh_core.egg-info/entry_points.txt
11
- byzh_core.egg-info/requires.txt
12
- byzh_core.egg-info/top_level.txt
13
- byzh_core/Barchive/__init__.py
14
- byzh_core/Barchive/archive.py
15
- byzh_core/Btable/__init__.py
16
- byzh_core/Btable/auto_table.py
17
- byzh_core/Bterminal/__init__.py
18
- byzh_core/Bterminal/cmd.py
19
- byzh_core/Bterminal/run_func.py
20
- byzh_core/Btqdm/__init__.py
21
- byzh_core/Btqdm/my_tqdm.py
22
- byzh_core/Butils/__init__.py
23
- byzh_core/Butils/decorator.py
24
- byzh_core/Butils/text_style.py
25
- byzh_core/Butils/timer.py
26
- byzh_core/Bwriter/__init__.py
27
- byzh_core/Bwriter/writer.py
28
- byzh_core/obsolete/__init__.py
29
- byzh_core/obsolete/auto_table.py
30
- byzh_core/obsolete/row_table.py
31
- byzh_core/obsolete/xy_table.py
32
- byzh_core/obsolete/Bconfig/__init__.py
33
- byzh_core/obsolete/Bconfig/config.py
@@ -1 +0,0 @@
1
- byzh_core
File without changes
File without changes
File without changes