- 为 pam_deploy_graph 生产代码补充中文模块、类、函数/方法文档字符串 - 将原有英文说明和主要英文异常提示改为中文 - 新增当前整体逻辑结构流程图文档,覆盖模块结构、执行链路、action 路由、人工确认和 checkpoint 续跑 - 新增 Linux 自带运行环境打包脚本,使用 PyInstaller 生成解压即用目录和 tar.gz - 新增 Linux 打包说明,包含构建命令、运行方式、依赖说明和包大小评估 - 同步 README,补充流程图、打包方式、产物路径和大小预估 - 更新相关测试断言以匹配中文错误提示
28 lines
789 B
Python
28 lines
789 B
Python
"""从 JSON 或 config.txt 风格文件读取部署参数。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
|
|
def load_params_file(path: str | Path) -> dict[str, Any]:
|
|
"""自动识别 JSON/config.txt 格式,并返回参数字典。"""
|
|
config_path = Path(path)
|
|
text = config_path.read_text(encoding="utf-8")
|
|
stripped = text.lstrip()
|
|
if stripped.startswith("{"):
|
|
return json.loads(text)
|
|
|
|
values: dict[str, Any] = {}
|
|
for raw_line in text.splitlines():
|
|
line = raw_line.strip()
|
|
if not line or line.startswith("#"):
|
|
continue
|
|
if "=" not in line:
|
|
continue
|
|
key, value = line.split("=", 1)
|
|
values[key.strip()] = value.strip()
|
|
return values
|