Compare commits
2 Commits
e10915689a
...
b13de416ca
| Author | SHA1 | Date | |
|---|---|---|---|
|
b13de416ca
|
|||
|
961f3640a4
|
@@ -1,3 +1,4 @@
|
||||
PyYAML==6.0.3
|
||||
requests==2.32.5
|
||||
Jinja2==3.1.6
|
||||
GitPython==3.1.45
|
||||
|
||||
23
tools/render
23
tools/render
@@ -4,18 +4,27 @@
|
||||
|
||||
import functools
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
import git
|
||||
import requests
|
||||
import yaml
|
||||
from jinja2 import Environment, FileSystemLoader, StrictUndefined, Template
|
||||
|
||||
NODES = pathlib.Path("nodes")
|
||||
SCHEMATICS = pathlib.Path("schematics")
|
||||
RENDERED = pathlib.Path("rendered")
|
||||
PATCHES = Environment(loader=FileSystemLoader("patches"), undefined=StrictUndefined)
|
||||
TEMPLATES = Environment(loader=FileSystemLoader("templates"), undefined=StrictUndefined)
|
||||
REPO = git.Repo(".", search_parent_directories=True)
|
||||
assert REPO.working_dir is not None
|
||||
|
||||
ROOT = pathlib.Path(REPO.working_dir)
|
||||
|
||||
NODES = ROOT.joinpath("nodes")
|
||||
SCHEMATICS = ROOT.joinpath("schematics")
|
||||
RENDERED = ROOT.joinpath("rendered")
|
||||
PATCHES = Environment(
|
||||
loader=FileSystemLoader(ROOT.joinpath("patches")), undefined=StrictUndefined
|
||||
)
|
||||
TEMPLATES = Environment(
|
||||
loader=FileSystemLoader(ROOT.joinpath("templates")), undefined=StrictUndefined
|
||||
)
|
||||
|
||||
|
||||
def node_encoder(node: dict):
|
||||
@@ -113,7 +122,7 @@ def main():
|
||||
# Quick and dirty way to resolve all the templates using a custom encoder
|
||||
final_nodes.append(json.loads(json.dumps(node, cls=node_encoder(node))))
|
||||
|
||||
with open("config.yaml") as fyaml:
|
||||
with open(ROOT.joinpath("config.yaml")) as fyaml:
|
||||
config = yaml.safe_load(fyaml)
|
||||
|
||||
RENDERED.mkdir(exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user