Catch invalid category options

If there are invalid options in the category.yaml, the program will not
abort and will instead use an empty dictionary.
This commit is contained in:
Luís Murta 2021-07-06 19:14:29 +01:00
parent 5f0fe38ba8
commit 5af505f962
Signed by: satprog
GPG Key ID: DDF2EFC6179009DC

View File

@ -28,7 +28,12 @@ Options = namedtuple(
) )
cfg = yaml.safe_load(open("categories.yaml")) cfg = yaml.safe_load(open("categories.yaml"))
categories = {k: Options(**v) if v else Options() for k, v in cfg.items()} try:
categories = {k: Options(**v) if v else Options() for k, v in cfg.items()}
except TypeError:
logging.exception("Invalid option in categories.yaml")
categories = {}
groups = { groups = {
group: [ group: [
category for category, options in categories.items() if options.group == group category for category, options in categories.items() if options.group == group