aboutsummaryrefslogtreecommitdiff
path: root/tools/interface_generator/bin/templates.py
blob: 9f7539e9d473a4a399c6454cecef1937ab6778c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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