exlab_wizard.template.manifest#
Typed, round-trippable model of a Copier copier.yml manifest.
This module owns the two primitives the GUI authoring form and the wizard consume questions through:
TemplateQuestion– one Copier question normalised to the widget family the wizard renders (str/int/float/bool/choice).template_questions()– parse the operator-answerable questions out of a rawcopier.ymlbody (both Copier long- and short-form).
These two used to live in exlab_wizard.ui.pages.templates. They
were moved here so the (non-UI) TemplateManifest model can
reuse them without importing a NiceGUI page module (an import cycle).
ui.pages.templates re-exports them so existing callers keep working.
TemplateManifest mirrors the _exlab_* metadata keys plus
the parsed questions and round-trips copier.yml so the structured
authoring form never hand-writes YAML:
TemplateManifest.from_yaml(m.to_yaml()) == m holds for manifests
built from every supported question kind.
Functions
|
Parse the operator-answerable questions out of a |
Classes
|
A typed, round-trippable model of a Copier |
|
One Copier question parsed from a template's |
- class exlab_wizard.template.manifest.TemplateManifest(exlab_type, exlab_version, exlab_run_scope=None, description='', plugins=<factory>, readme_fields=<factory>, questions=<factory>, min_copier_version='9.0', answers_file='.exlab-answers.yml')[source]#
Bases:
objectA typed, round-trippable model of a Copier
copier.yml.Mirrors the
_exlab_*metadata keys plus the parsedTemplateQuestionlist. Built so the structured authoring form never hand-writes YAML:from_yaml()parses a manifest (string or already-parsed dict) andto_yaml()emits a deterministic, long-formcopier.ymlsuch thatTemplateManifest.from_yaml(m.to_yaml()) == m.- exlab_type#
One of
"project"/"equipment"/"run"(_exlab_type). Not validated here – seeexlab_wizard.template.lint.
- exlab_version#
The required
_exlab_versionstring (§5.7).
- exlab_run_scope#
_exlab_run_scopefor run templates;Noneotherwise (and then never emitted byto_yaml()).
- description#
_exlab_descriptionfree-form text.
- plugins#
Ordered
_exlab_pluginsslug list (§6.2.3); emitted only when non-empty.
- readme_fields#
_exlab_readme.fieldsfield-extension list (§10.3), each a free-form dict.
- questions#
Parsed operator-answerable questions, emitted in long form.
- min_copier_version#
_min_copier_version(defaults"9.0").
- answers_file#
_answers_file(defaults".exlab-answers.yml").
- Parameters:
- classmethod from_yaml(raw)[source]#
Build a
TemplateManifestfrom a manifest body.- Parameters:
raw (
str|dict[str,Any]) – Either a rawcopier.ymlstring (parsed withyaml.safe_load()) or an already-parsed mapping.- Return type:
- Returns:
A
TemplateManifest. Missing_exlab_*/_*keys fall back to the dataclass defaults; questions are parsed viatemplate_questions().
- questions: list[TemplateQuestion]#
- to_yaml()[source]#
Emit a deterministic, long-form
copier.ymlstring.Keys are emitted in a fixed order (Copier metadata first, then each question in long form) with
sort_keys=Falseso the ordering is preserved._exlab_run_scopeis emitted only when notNoneand_exlab_pluginsonly when non-empty. Each question emits{type, help, default, choices, secret}with empty /Nonesub-keys omitted, sofrom_yaml()reconstructs the identical model.- Return type:
- class exlab_wizard.template.manifest.TemplateQuestion(key, kind, default=None, choices=(), help='', secret=False)[source]#
Bases:
objectOne Copier question parsed from a template’s
copier.yml.kindis normalised to the widget family the wizard renders:str/int/float/bool/choice.choicesis populated only forchoicequestions.secretflags a password-stylestrinput.
- exlab_wizard.template.manifest.template_questions(raw_manifest)[source]#
Parse the operator-answerable questions out of a
copier.ymlbody.Handles both Copier question forms:
long form –
key: {type: ..., default: ..., choices: ...}short form –
key: <scalar>(the scalar is the default; the type is inferred from it)
_-prefixed keys (Copier /_exlab_*metadata) are skipped. Questions carrying awhenclause are still returned – the wizard renders them unconditionally for v1.- Parameters:
- Return type: