添加 openclaw-deploy/render.py
This commit is contained in:
28
openclaw-deploy/render.py
Normal file
28
openclaw-deploy/render.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import json
|
||||
import os
|
||||
from jinja2 import Template
|
||||
|
||||
# 自动创建输出目录
|
||||
output_dir = "application"
|
||||
if not os.path.exists(output_dir):
|
||||
os.makedirs(output_dir)
|
||||
|
||||
# 读取模板
|
||||
with open("template/template.yaml", "r", encoding="utf-8") as f:
|
||||
template = Template(f.read())
|
||||
|
||||
# 读取多个用户配置
|
||||
with open("global.json", "r", encoding="utf-8") as f:
|
||||
users = json.load(f)
|
||||
|
||||
# 循环批量生成
|
||||
for user in users:
|
||||
rendered_yaml = template.render(**user)
|
||||
filename = os.path.join(output_dir, f"{user['user_id']}.yaml")
|
||||
|
||||
with open(filename, "w", encoding="utf-8") as f:
|
||||
f.write(rendered_yaml)
|
||||
|
||||
print(f"✅ 已生成:{filename}")
|
||||
|
||||
print(f"\n🎉 全部生成完成!共 {len(users)} 个文件")
|
||||
Reference in New Issue
Block a user