This commit is contained in:
2025-12-03 17:16:44 +08:00
parent 1e80eb643e
commit 113864ceed
6 changed files with 18 additions and 8 deletions

View File

@@ -1,3 +1,2 @@
# 基础模块现代化改进分支
您正浏览潜进项目的基础模块现代化改进原型分支!
[] - HeurAMK

1
config Symbolic link
View File

@@ -0,0 +1 @@
config.example

View File

@@ -1 +1,2 @@
print("Hello from HeurAMS Program :)")
print("Hello from HeurAMS Program :)")

View File

@@ -6,12 +6,18 @@ from contextvars import ContextVar
import pathlib
from heurams.services.config import ConfigFile
# 默认配置文件路径规定: 以包目录为准
# 用户配置文件路径规定: 以运行目录为准
# 数据文件路径规定: 以运行目录为准
root_dir = pathlib.Path(__file__).parent
print(f'rootdir: {rootdir}')
working_dir = pathlib.Path.cwd()
config_var: ContextVar[ConfigFile] = ContextVar('config_var', default=ConfigFile(working_dir / "config" / "config.toml")) # 配置文件
print(f'workdir: {workdir}')
try:
config_var: ContextVar[ConfigFile] = ContextVar('config_var', default=ConfigFile(workdir / "config" / "config.toml")) # 配置文件
except:
print('加载用户配置失败')
runtime_var: ContextVar = ContextVar('runtime_var', default=dict()) # 运行时共享数据
class ConfigContext:
@@ -34,4 +40,4 @@ class ConfigContext:
return self
def __exit__(self, exc_type, exc_val, exc_tb):
config_var.reset(self._token) # type: ignore
config_var.reset(self._token) # type: ignore

View File

@@ -27,5 +27,8 @@ class HeurAMSApp(App):
def on_button_pressed(self, event: Button.Pressed) -> None:
self.exit(event.button.id)
def environment_check():
from heurams.context import working_var
app = HeurAMSApp()
app.run()
app.run()