From 8d4f4204a768b46712badfbda196bcdf5a11e933 Mon Sep 17 00:00:00 2001 From: wwya Date: Wed, 1 Apr 2026 19:18:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20openclaw-deploy/render.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- openclaw-deploy/render.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 openclaw-deploy/render.py diff --git a/openclaw-deploy/render.py b/openclaw-deploy/render.py new file mode 100644 index 0000000..3c769fa --- /dev/null +++ b/openclaw-deploy/render.py @@ -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)} 个文件") \ No newline at end of file