exlab_wizard.ui.pages.templates#
Template manager page (Frontend Spec §4 step 2, §5 step 2).
Two operations the wizards depend on:
list_templates()– scanconfig.paths.templates_dirfor Copier templates (directories containing acopier.yml) and return a small summary per template. The project / run wizards call this to populate their “pick a template” step.create_template()– scaffold a new minimal Copier template undertemplates_dir: acopier.ymlcarrying the_exlab_*manifest keys plus one rendered content file. The result is immediately loadable byTemplateEngine.
list_templates / create_template are pure (no NiceGUI) so they
are unit-testable; render_template_manager() is the NiceGUI view.
Functions
|
Scaffold a new minimal Copier template under |
|
Return the templates under |
|
Render one Copier question as a bound NiceGUI widget. |
|
Render the template manager: existing-template list + create form. |
Classes
|
One row in the template list. |
- class exlab_wizard.ui.pages.templates.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.
- class exlab_wizard.ui.pages.templates.TemplateSummary(name, path, template_type, run_scope, description)[source]#
Bases:
objectOne row in the template list.
nameis the template directory name (what the wizards store asselected_template);pathis its absolute location;template_type/run_scope/descriptioncome from the_exlab_*keys incopier.yml.
- exlab_wizard.ui.pages.templates.create_template(templates_dir, *, name, template_type, description='', run_scope=None)[source]#
Scaffold a new minimal Copier template under
templates_dir.Writes
<templates_dir>/<name>/copier.ymlplus one content file. Returns the new template’s root directory. RaisesValueErroron an empty / duplicate name, an unknowntemplate_type, or a run template missing itsrun_scope.The scaffold logic lives in
exlab_wizard.template.authoring.create_template_dir()(the non-UI authoring service); this thin wrapper preserves the historical page-level signature and is imported lazily to avoid an import cycle.
- exlab_wizard.ui.pages.templates.list_templates(templates_dir, *, template_type=None)[source]#
Return the templates under
templates_dir, optionally filtered.A template is any immediate sub-directory containing a
copier.yml. Malformed manifests are skipped with a WARN rather than failing the whole scan. Whentemplate_typeis given, only templates whose_exlab_typematches are returned.- Parameters:
- Return type:
- exlab_wizard.ui.pages.templates.render_question_field(question, answers, *, testid_prefix)[source]#
Render one Copier question as a bound NiceGUI widget.
The widget two-way binds into
answers[question.key]; the entry is seeded with the question’s default so a never-touched field still contributes its default to the render.testid_prefixnamespaces thedata-testid(f"{prefix}-{key}").
- exlab_wizard.ui.pages.templates.render_template_manager(*, templates, on_create=None, on_back=None, on_edit=None, locations=None, on_location_change=None)[source]#
Render the template manager: existing-template list + create form.
on_createis invoked with(name, template_type, description, run_scope)when the operator submits the create form;run_scopeisNonefor non-run templates.on_edit(optional) is invoked with a template name when the operator clicks that row’s Edit button – the caller routes it to the template editor page.locations(optional) is a[(label, value), ...]scope list (at minimum("Global", ...)plus one entry per configured equipment / project); when given, a selector is rendered at the top andon_location_change(value)is invoked when the operator switches scope (the caller re-renders the manager scoped to that location). All three new parameters are optional and defaultNoneso existing callers keep working unchanged.
- exlab_wizard.ui.pages.templates.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: