Browse Source

feat: config path

Signed-off-by: QuentinN42 <quentin@lieumont.fr>
master
QuentinN42 7 months ago
parent
commit
ec4e98c270
Signed by untrusted user: number42 GPG Key ID: 2CD7D563712B3A50
  1. 15
      builder/__main__.py
  2. 19
      config.json

15
builder/__main__.py

@ -1,16 +1,27 @@
"""Jinja2 generator."""
from jinja2 import Environment, FileSystemLoader # type: ignore
from json import load
from os import getenv
from jinja2 import Environment, FileSystemLoader # type: ignore
BASE_PATH = 'config.json'
env = Environment(loader=FileSystemLoader('builder/templates'))
def get_congig_path():
if (path := getenv('CONFIG_PATH')):
return path
return BASE_PATH
def get_arguments() -> dict:
return {"a": "b"}
with open(get_congig_path(), encoding='utf-8') as f:
return load(f)
def render(file: str, args: dict) -> str:
"""Render a template file."""
print(args)
template = env.get_template(file)
return template.render(args)

19
config.json

@ -0,0 +1,19 @@
[
{
"name": "Cat1",
"items": [
{
"name": "Item1",
"description": "Description of Item1",
"url": "http://www.example.com/item1",
"image": "http://www.example.com/item1.png"
},
{
"name": "Item2",
"description": "Description of Item2",
"url": "http://www.example.com/item2",
"image": "http://www.example.com/item2.png"
}
]
}
]
Loading…
Cancel
Save