aboutsummaryrefslogtreecommitdiff
path: root/tools/interface_generator/bin/interface_generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/interface_generator/bin/interface_generator.py')
-rwxr-xr-xtools/interface_generator/bin/interface_generator.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/interface_generator/bin/interface_generator.py b/tools/interface_generator/bin/interface_generator.py
index 04553e3..0534709 100755
--- a/tools/interface_generator/bin/interface_generator.py
+++ b/tools/interface_generator/bin/interface_generator.py
@@ -8,7 +8,7 @@ from argparse import ArgumentParser
from pathlib import Path
import sys
from mako.lookup import TemplateLookup
-from interface_definition import parse as parse_interface
+from interface_definition import InterfaceDefinition
from templates import get_templates, get_templates_dir
PROG = {
@@ -17,14 +17,16 @@ PROG = {
}
-def generate_file(template: Path, templates: Path, output, kwargs):
+def generate_file(
+ template: Path, templates: Path, output, interface: InterfaceDefinition
+):
"""generate file using a tempalte and write it to the output location"""
lookup = TemplateLookup(directories=[".", templates.absolute()])
mako_template = lookup.get_template(str(template.relative_to(templates)))
- result = mako_template.render(**kwargs, PROG=PROG)
+ output_name = template.stem.replace("interface", interface.name)
+ print(f"{interface.name} via {template.name} => {output_name}")
- output_name = template.stem.replace("interface", kwargs["name"])
- print(f'{kwargs["name"]} via {template.name} => {output_name}')
+ result = mako_template.render(**interface.into_dict(), PROG=PROG)
if isinstance(output, Path):
# print(f"writing to {(output / output_name).absolute()}")
@@ -72,7 +74,7 @@ def main():
args = parser.parse_args()
# print(args)
- interface = parse_interface(args)
+ interface = InterfaceDefinition(args.interface, args.license)
# print(interface)
for template in get_templates(args.templates):