Koodu, simple code generator engine written in python.
Koodu is a simple universal code generator. It allows users to generate codes with the same structure in several projects to save time. Koodu allows users to follow the DRY(Don't Repeat Youself) philosophy, i.e. instead of writing the same code several times, write a template once and use it on several models to generate different code efficiently.
Clone this repository and run:
$ python -m pip install .
$ pip install koodu
$ koodu list templates
$ koodu list models
$ koodu generate -t fastapi -m blog -o ./examples/blog
The path to template can be replace directly with build in template such as fastapi
or flask
Koodu can also be used as python library as follows:
import json
from pathlib import Path
from koodu.generator import Generator
with open(Path("./koodu/models/blog.json"), "r", encoding="utf-8") as fp:
model = json.loads(fp.read())
template_path = Path("./koodu/templates/fastapi")
output_path = Path("./examples/blog")
generator = Generator(
model=model,
template_folder=template_path,
output=Path(args.output)
)
for file in generator.render():
file.write()