Core: auto alias (#1022)

* Test: check that default templates can be parsed into Option objects
This commit is contained in:
Fabian Dill
2022-09-16 00:32:30 +02:00
committed by GitHub
parent 156e9e0e43
commit af11fa5150
13 changed files with 70 additions and 38 deletions

View File

@@ -26,13 +26,18 @@ class AssembleOptions(abc.ABCMeta):
attrs["name_lookup"].update({option_id: name for name, option_id in new_options.items()})
options.update(new_options)
# apply aliases, without name_lookup
aliases = {name[6:].lower(): option_id for name, option_id in attrs.items() if
name.startswith("alias_")}
assert "random" not in aliases, "Choice option 'random' cannot be manually assigned."
# auto-alias Off and On being parsed as True and False
if "off" in options:
options["false"] = options["off"]
if "on" in options:
options["true"] = options["on"]
options.update(aliases)
# auto-validate schema on __init__