check_template

check_template(template: str, forms: frozenset[str] | None)

Checks a name template against the grammar of the omk vocabulary: literal text, {root}, {root:FORM} with FORM one of forms, {{ and }}. forms is None when the collection has no root, so no placeholder is allowed.

>>> check_template("{root:ascii}maj7", frozenset({"ascii"}))
>>> check_template("{root!r}", frozenset({"ascii"}))
Traceback (most recent call last):
...
ValueError: '{root!r}' is not a name template: only {root}, {root:FORM}, {{ and }} may use braces.

Raises

Name Type Description
ValueError if the template breaks the grammar, uses {root} with no root, or names a display form the root does not have.