exlab_wizard.template.lint#
Single source of truth for template (copier.yml) validation.
The §5.1 checks that used to live inline in
exlab_wizard.template.copier_driver.TemplateEngine.resolve() are
factored out here so resolve-time and author-time validation share one
rule set. The GUI authoring form calls lint_template() /
lint_manifest_dict() to gate saves; TemplateEngine.resolve
calls lint_manifest_dict() and re-raises its ERROR findings as the
existing TemplateLoadError / TemplateCoreFieldRedeclaredError.
Findings are returned as LintFinding (a small, lint-specific
shape) rather than the validator’s run-output Finding – the latter
carries rule / run_path / offending_path / offending_kind
fields that are meaningless for a copier.yml.
Two tiers:
error– the manifest/template is unusable; a save is refused andresolveraises.warn– the manifest is usable but deviates from convention; a save proceeds with a banner.
lint_manifest_dict() validates an already-parsed manifest mapping
(no file I/O). lint_template() adds the file-level checks
(copier.yml existence / readability / YAML-parse) and a Jinja2
syntax check across every *.jinja file under the template root.
Functions
|
Return |
|
Validate an already-parsed |
|
Validate a template directory end-to-end. |
Classes
|
One template-validation finding. |
- class exlab_wizard.template.lint.LintFinding(code, message, severity, path=None)[source]#
Bases:
objectOne template-validation finding.
- code#
Stable machine code (e.g.
"template_type_missing").
- message#
Human-readable description (carries the same wording
TemplateEngine.resolvehistorically raised, so the re-raised exceptions are message-identical).
- severity#
"error"(refuse / raise) or"warn"(proceed).
- path#
Relative path of the offending file for file-scoped findings (e.g. a
*.jinjawith a syntax error);Nonefor manifest-level findings.
- exlab_wizard.template.lint.has_errors(findings)[source]#
Return
Trueif any finding hasseverity == "error".- Parameters:
findings (
list[LintFinding])- Return type:
- exlab_wizard.template.lint.lint_manifest_dict(manifest, manifest_path)[source]#
Validate an already-parsed
copier.ymlmapping.Ports the §5.1 metadata checks out of
TemplateEngine.resolveand_extract_readme_fields. Does not check file existence or YAML-parse the file – those are file-level and handled bylint_template(). Messages match the wordingTemplateEngine.resolvehistorically raised so re-raised exceptions are byte-identical.
- exlab_wizard.template.lint.lint_template(template_dir)[source]#
Validate a template directory end-to-end.
Runs the file-level checks (
copier.ymlexistence, readability, YAML-parse), then delegates the manifest checks tolint_manifest_dict(), then parses every*.jinjafile undertemplate_dirwith Jinja2 and reports syntax errors.- Parameters:
template_dir (
Path) – The template root (directory containingcopier.yml).- Return type:
- Returns:
All findings (ERROR + WARN). A fatal
copier.ymlproblem short-circuits the manifest checks (but the Jinja scan still runs).