koji_habitude.templates
koji_habitude.template
Template loading and Jinja2 expansion system for koji object templates.
- author:
Christopher O’Brien <obriencj@gmail.com>
- license:
GNU General Public License v3
- ai-assistant:
Claude 3.5 Sonnet via Cursor
- class koji_habitude.templates.MultiTemplate
Bases:
TemplateA MultiTemplate is a template that generates multiple YAML documents.
- model_config: ClassVar[ConfigDict] = {'validate_by_alias': True, 'validate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class koji_habitude.templates.Template(*, __file__: str | None = None, __line__: int | None = None, __trace__: ~typing.List[~typing.Dict[str, ~typing.Any]] | None = <factory>, name: str, type: str | None = None, defaults: ~typing.Dict[str, ~typing.Any] = <factory>, file: str | None = None, content: str | None = None, model: ~koji_habitude.templates.TemplateModelDefinition | None = None, description: str | None = None)
Bases:
BaseModel,IdentifiableMixin,LocalMixinA Template allows for the expansion of some YAML data into zero or more YAML docs, via Jinja2
- property base_path: Path | None
The base path for the template file, used for resolving relative paths
- get_missing()
Return the set of variable names which are referenced in the Jinja2 template, but which are not defined in the defaults
- model_config: ClassVar[ConfigDict] = {'validate_by_alias': True, 'validate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(_Template__context: Any)
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- render_and_load(data: Dict[str, Any]) Iterator[Dict[str, Any]]
Render the template with the given data and yield the resulting YAML documents
- render_call(call: TemplateCall)
- template_model: TemplateModelDefinition | None
- property undeclared
The list of variable names which are referenced in the Jinja2 template, but which are not defined in the defaults
- class koji_habitude.templates.TemplateCall(*, __file__: str | None = None, __line__: int | None = None, __trace__: ~typing.List[~typing.Dict[str, ~typing.Any]] | None = <factory>, type: str)
-
Represents a YAML doc that needs to be expanded into zero or more new docs via a Template.
- model_config: ClassVar[ConfigDict] = {'validate_by_alias': True, 'validate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class koji_habitude.templates.TemplateFieldDefinition(*, type: str, alias: str | None = None, description: str | None = None, default: Any | None = None, required: bool = True, validation: ValidationRule | None = None, array_item_type: TemplateFieldDefinition | None = None, object_fields: Dict[str, TemplateFieldDefinition] | None = None, object_type_name: str | None = None, reference_type: str | None = None)
Bases:
SubModelDefines a Field in a TemplateModel
- array_item_type: TemplateFieldDefinition | None
- model_config: ClassVar[ConfigDict] = {'validate_by_alias': True, 'validate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(_TemplateFieldDefinition__context: Any)
Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.
- object_fields: Dict[str, TemplateFieldDefinition] | None
- validation: ValidationRule | None
- class koji_habitude.templates.TemplateModelDefinition(*, name: str = 'model', description: str | None = None, fields: ~typing.Dict[str, ~koji_habitude.templates.TemplateFieldDefinition] = <factory>)
Bases:
SubModelYAML definition for creating a Pydantic model for template data validation
- fields: Dict[str, TemplateFieldDefinition]
- model_config: ClassVar[ConfigDict] = {'validate_by_alias': True, 'validate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class koji_habitude.templates.ValidationRule(*, min_length: int | None = None, max_length: int | None = None, min_value: float | None = None, max_value: float | None = None, regex: Pattern | None = None, enum: List[Any] | None = None)
Bases:
SubModelValidation rules for a DynamicFieldDefinition
- model_config: ClassVar[ConfigDict] = {'validate_by_alias': True, 'validate_by_name': True}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].