"""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