diff options
Diffstat (limited to 'tools/interface_generator/bin/templates.py')
-rw-r--r-- | tools/interface_generator/bin/templates.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/interface_generator/bin/templates.py b/tools/interface_generator/bin/templates.py new file mode 100644 index 0000000..9f7539e --- /dev/null +++ b/tools/interface_generator/bin/templates.py @@ -0,0 +1,19 @@ +"""template helper functions""" + +from pathlib import Path +import re + + +TEMPLATE_PATTERN = re.compile(r"^[^_]\S+\.mako$") + + +def get_templates_dir(name="templates") -> Path: + """get the templates directory""" + return Path(__file__).parent / name + + +def get_templates(path: Path) -> list[Path]: + """list templates in given path""" + result = list(path.glob("*.mako")) + result = [item for item in result if TEMPLATE_PATTERN.match(item.name)] + return result |