Template helpers for generating CCProxy plugin scaffolds.
PluginTemplateType
Bases: str, Enum
Supported plugin template variants.
build_plugin_scaffold
build_plugin_scaffold(
plugin_name,
description,
version,
template_type,
*,
include_tests=False,
)
Return a mapping of relative file paths to scaffold contents.
Source code in ccproxy/templates/plugin_scaffold.py
| def build_plugin_scaffold(
plugin_name: str,
description: str,
version: str,
template_type: PluginTemplateType,
*,
include_tests: bool = False,
) -> dict[str, str]:
"""Return a mapping of relative file paths to scaffold contents."""
pascal_name = _to_pascal_case(plugin_name)
ctx = TemplateContext(
plugin_name=plugin_name,
pascal_name=pascal_name,
description=description,
version=version,
)
builders: dict[
PluginTemplateType, Callable[[TemplateContext, bool], dict[str, str]]
] = {
PluginTemplateType.SYSTEM: _build_system_template,
PluginTemplateType.PROVIDER: _build_provider_template,
PluginTemplateType.AUTH: _build_auth_template,
}
builder = builders.get(template_type)
if builder is None:
raise ValueError(f"Unsupported template type: {template_type}")
return builder(ctx, include_tests)
|