ErisPulse 2.1.9__tar.gz → 2.1.10__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.
- {erispulse-2.1.9 → erispulse-2.1.10}/PKG-INFO +1 -1
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/CHANGELOG.md +5 -1
- {erispulse-2.1.9 → erispulse-2.1.10}/pyproject.toml +1 -1
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/adapter.py +1 -1
- erispulse-2.1.9/src/ErisPulse/Core/core_config.py → erispulse-2.1.10/src/ErisPulse/Core/config.py +72 -9
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/env.py +5 -33
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/logger.py +1 -1
- {erispulse-2.1.9 → erispulse-2.1.10}/.github/assets/erispulse_logo.png +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/.github/tools/merge_md.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/.github/tools/update-api-docs.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/.github/workflows/auto-tag-release.yml +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/.github/workflows/pypi-publish.yml +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/.gitignore +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/.python-version +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/CODE_OF_CONDUCT.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/LICENSE +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/devs/test.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/devs/test_adapter.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/devs/test_files/test.docx +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/devs/test_files/test.jpg +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/devs/test_files/test.mp4 +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AIDocs/ErisPulse-AdapterDev.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AIDocs/ErisPulse-Core.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AIDocs/ErisPulse-Full.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AIDocs/ErisPulse-ModuleDev.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AIDocs/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AIModuleGeneration.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AdapterStandards/APIResponse.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AdapterStandards/EventConversion.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/AdapterStandards/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/CHANGELOG_1.x.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/CLI.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/Development/Adapter.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/Development/CLI.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/Development/Module.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/Development/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/PlatformFeatures.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/UseCore.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/Core/adapter.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/Core/env.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/Core/logger.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/Core/mods.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/Core/raiserr.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/Core/server.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/Core/util.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/__init__.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/ErisPulse/__main__.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/api/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/docs/quick-start.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-adapter/LICENSE +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-adapter/MyAdapter/Core.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-adapter/MyAdapter/__init__.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-adapter/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-adapter/pyproject.toml +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-cli-module/LICENSE +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-cli-module/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-cli-module/my_cli_module/__init__.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-cli-module/my_cli_module/cli.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-cli-module/pyproject.toml +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-module/LICENSE +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-module/MyModule/Core.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-module/MyModule/__init__.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-module/README.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/examples/example-module/pyproject.toml +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/scripts/install/install.ps1 +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/scripts/install/install.sh +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/__init__.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/mods.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/raiserr.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/server.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/Core/util.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/__init__.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/src/ErisPulse/__main__.py +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/style_guide/DOCSTRING_SPEC.md +0 -0
- {erispulse-2.1.9 → erispulse-2.1.10}/style_guide/README.md +0 -0
|
@@ -8,10 +8,14 @@
|
|
|
8
8
|
> **贡献日志**
|
|
9
9
|
> 如需为新版本添加日志,请在对应版本号下补充内容,并注明日期和主要贡献者。
|
|
10
10
|
|
|
11
|
-
## [2.1.
|
|
11
|
+
## [2.1.10] - 2025/07/20
|
|
12
|
+
### 新增
|
|
13
|
+
- 新增 `config` 模块,用于分离 `env` 模块功能,提供更友好的配置管理体验
|
|
12
14
|
|
|
13
15
|
### 变更
|
|
14
16
|
- 标准日志处理器替换为RichHandler,提供更美观的彩色控制台日志输出
|
|
17
|
+
- 使用独立的 `Config` 模块处理核心配置,避免与 `env` 模块冲突
|
|
18
|
+
- 兼容性性改进:解决情况下部分循环引用问题
|
|
15
19
|
|
|
16
20
|
### 修复
|
|
17
21
|
- 修复设置模块日志等级时,调用错误的问题
|
|
@@ -403,7 +403,7 @@ class AdapterManager:
|
|
|
403
403
|
platforms = list(self._adapters.keys())
|
|
404
404
|
|
|
405
405
|
from .server import adapter_server
|
|
406
|
-
from .
|
|
406
|
+
from .config import get_server_config
|
|
407
407
|
server_config = get_server_config()
|
|
408
408
|
host = server_config["host"]
|
|
409
409
|
port = server_config["port"]
|
erispulse-2.1.9/src/ErisPulse/Core/core_config.py → erispulse-2.1.10/src/ErisPulse/Core/config.py
RENAMED
|
@@ -4,9 +4,75 @@ ErisPulse 配置中心
|
|
|
4
4
|
集中管理所有配置项,避免循环导入问题
|
|
5
5
|
提供自动补全缺失配置项的功能
|
|
6
6
|
"""
|
|
7
|
-
|
|
7
|
+
import os
|
|
8
|
+
import toml
|
|
8
9
|
from typing import Dict, Any, Optional
|
|
9
10
|
|
|
11
|
+
class ConfigManager:
|
|
12
|
+
def __init__(self, config_file: str = "config.toml"):
|
|
13
|
+
self.CONFIG_FILE = config_file
|
|
14
|
+
|
|
15
|
+
def getConfig(self, key: str, default: Any = None) -> Any:
|
|
16
|
+
"""
|
|
17
|
+
获取模块/适配器配置项
|
|
18
|
+
:param key: 配置项的键(支持点分隔符如"module.sub.key")
|
|
19
|
+
:param default: 默认值
|
|
20
|
+
:return: 配置项的值
|
|
21
|
+
"""
|
|
22
|
+
try:
|
|
23
|
+
if not os.path.exists(self.CONFIG_FILE):
|
|
24
|
+
return default
|
|
25
|
+
|
|
26
|
+
with open(self.CONFIG_FILE, "r", encoding="utf-8") as f:
|
|
27
|
+
config = toml.load(f)
|
|
28
|
+
|
|
29
|
+
# 支持点分隔符访问嵌套配置
|
|
30
|
+
keys = key.split('.')
|
|
31
|
+
value = config
|
|
32
|
+
for k in keys:
|
|
33
|
+
if k not in value:
|
|
34
|
+
return default
|
|
35
|
+
value = value[k]
|
|
36
|
+
|
|
37
|
+
return value
|
|
38
|
+
except Exception as e:
|
|
39
|
+
from . import logger
|
|
40
|
+
logger.error(f"读取配置文件 {self.CONFIG_FILE} 失败: {e}")
|
|
41
|
+
return default
|
|
42
|
+
|
|
43
|
+
def setConfig(self, key: str, value: Any) -> bool:
|
|
44
|
+
"""
|
|
45
|
+
设置模块/适配器配置
|
|
46
|
+
:param key: 配置项键名(支持点分隔符如"module.sub.key")
|
|
47
|
+
:param value: 配置项值
|
|
48
|
+
:return: 操作是否成功
|
|
49
|
+
"""
|
|
50
|
+
try:
|
|
51
|
+
config = {}
|
|
52
|
+
if os.path.exists(self.CONFIG_FILE):
|
|
53
|
+
with open(self.CONFIG_FILE, "r", encoding="utf-8") as f:
|
|
54
|
+
config = toml.load(f)
|
|
55
|
+
|
|
56
|
+
# 支持点分隔符设置嵌套配置
|
|
57
|
+
keys = key.split('.')
|
|
58
|
+
current = config
|
|
59
|
+
for k in keys[:-1]:
|
|
60
|
+
if k not in current:
|
|
61
|
+
current[k] = {}
|
|
62
|
+
current = current[k]
|
|
63
|
+
current[keys[-1]] = value
|
|
64
|
+
|
|
65
|
+
with open(self.CONFIG_FILE, "w", encoding="utf-8") as f:
|
|
66
|
+
toml.dump(config, f)
|
|
67
|
+
|
|
68
|
+
return True
|
|
69
|
+
except Exception as e:
|
|
70
|
+
from . import logger
|
|
71
|
+
logger.error(f"写入配置文件 {self.CONFIG_FILE} 失败: {e}")
|
|
72
|
+
return False
|
|
73
|
+
|
|
74
|
+
config = ConfigManager()
|
|
75
|
+
|
|
10
76
|
# 默认配置
|
|
11
77
|
DEFAULT_CONFIG = {
|
|
12
78
|
"server": {
|
|
@@ -53,14 +119,13 @@ def get_config() -> Dict[str, Any]:
|
|
|
53
119
|
|
|
54
120
|
:return: 完整的配置字典
|
|
55
121
|
"""
|
|
56
|
-
|
|
57
|
-
|
|
122
|
+
|
|
58
123
|
# 获取现有配置
|
|
59
|
-
current_config =
|
|
124
|
+
current_config = config.getConfig("ErisPulse")
|
|
60
125
|
|
|
61
126
|
# 如果完全没有配置,设置默认配置
|
|
62
127
|
if current_config is None:
|
|
63
|
-
|
|
128
|
+
config.setConfig("ErisPulse", DEFAULT_CONFIG)
|
|
64
129
|
return DEFAULT_CONFIG
|
|
65
130
|
|
|
66
131
|
# 检查并补全缺失的配置项
|
|
@@ -68,7 +133,7 @@ def get_config() -> Dict[str, Any]:
|
|
|
68
133
|
|
|
69
134
|
# 如果配置有变化,更新到存储
|
|
70
135
|
if current_config != complete_config:
|
|
71
|
-
|
|
136
|
+
config.setConfig("ErisPulse", complete_config)
|
|
72
137
|
|
|
73
138
|
return complete_config
|
|
74
139
|
|
|
@@ -79,8 +144,6 @@ def update_config(new_config: Dict[str, Any]) -> bool:
|
|
|
79
144
|
:param new_config: 新的配置字典
|
|
80
145
|
:return: 是否更新成功
|
|
81
146
|
"""
|
|
82
|
-
from .env import env
|
|
83
|
-
|
|
84
147
|
# 获取当前配置并合并新配置
|
|
85
148
|
current = get_config()
|
|
86
149
|
merged = {**current, **new_config}
|
|
@@ -88,7 +151,7 @@ def update_config(new_config: Dict[str, Any]) -> bool:
|
|
|
88
151
|
# 确保合并后的配置结构完整
|
|
89
152
|
complete_config = _ensure_config_structure(merged)
|
|
90
153
|
|
|
91
|
-
return
|
|
154
|
+
return config.setConfig("ErisPulse", complete_config)
|
|
92
155
|
|
|
93
156
|
def get_server_config() -> Dict[str, Any]:
|
|
94
157
|
"""
|
|
@@ -180,6 +180,7 @@ class EnvManager:
|
|
|
180
180
|
return True
|
|
181
181
|
except Exception as e:
|
|
182
182
|
return False
|
|
183
|
+
|
|
183
184
|
def getConfig(self, key: str, default: Any = None) -> Any:
|
|
184
185
|
"""
|
|
185
186
|
获取模块/适配器配置项
|
|
@@ -188,21 +189,8 @@ class EnvManager:
|
|
|
188
189
|
:return: 配置项的值
|
|
189
190
|
"""
|
|
190
191
|
try:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
with open(self.CONFIG_FILE, "r", encoding="utf-8") as f:
|
|
195
|
-
config = toml.load(f)
|
|
196
|
-
|
|
197
|
-
# 支持点分隔符访问嵌套配置
|
|
198
|
-
keys = key.split('.')
|
|
199
|
-
value = config
|
|
200
|
-
for k in keys:
|
|
201
|
-
if k not in value:
|
|
202
|
-
return default
|
|
203
|
-
value = value[k]
|
|
204
|
-
|
|
205
|
-
return value
|
|
192
|
+
from .config import config
|
|
193
|
+
return config.getConfig(key, default)
|
|
206
194
|
except Exception as e:
|
|
207
195
|
from . import logger
|
|
208
196
|
logger.error(f"读取配置文件 {self.CONFIG_FILE} 失败: {e}")
|
|
@@ -216,24 +204,8 @@ class EnvManager:
|
|
|
216
204
|
:return: 操作是否成功
|
|
217
205
|
"""
|
|
218
206
|
try:
|
|
219
|
-
config
|
|
220
|
-
|
|
221
|
-
with open(self.CONFIG_FILE, "r", encoding="utf-8") as f:
|
|
222
|
-
config = toml.load(f)
|
|
223
|
-
|
|
224
|
-
# 支持点分隔符设置嵌套配置
|
|
225
|
-
keys = key.split('.')
|
|
226
|
-
current = config
|
|
227
|
-
for k in keys[:-1]:
|
|
228
|
-
if k not in current:
|
|
229
|
-
current[k] = {}
|
|
230
|
-
current = current[k]
|
|
231
|
-
current[keys[-1]] = value
|
|
232
|
-
|
|
233
|
-
with open(self.CONFIG_FILE, "w", encoding="utf-8") as f:
|
|
234
|
-
toml.dump(config, f)
|
|
235
|
-
|
|
236
|
-
return True
|
|
207
|
+
from .config import config
|
|
208
|
+
return config.setConfig(key, value)
|
|
237
209
|
except Exception as e:
|
|
238
210
|
from . import logger
|
|
239
211
|
logger.error(f"写入配置文件 {self.CONFIG_FILE} 失败: {e}")
|
|
@@ -174,7 +174,7 @@ class Logger:
|
|
|
174
174
|
self._logs[ModuleName].append(msg)
|
|
175
175
|
|
|
176
176
|
def _setup_config(self):
|
|
177
|
-
from .
|
|
177
|
+
from .config import get_logger_config
|
|
178
178
|
logger_config = get_logger_config()
|
|
179
179
|
if "level" in logger_config:
|
|
180
180
|
self.set_level(logger_config["level"])
|
|
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
|
|
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
|
|
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
|