From 5af505f9628f270654de94f6392997f9119ca498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Murta?= Date: Tue, 6 Jul 2021 19:14:29 +0100 Subject: [PATCH] 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. --- pfbudget/categories.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pfbudget/categories.py b/pfbudget/categories.py index 128df97..e045c32 100644 --- a/pfbudget/categories.py +++ b/pfbudget/categories.py @@ -28,7 +28,12 @@ Options = namedtuple( ) 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 = { group: [ category for category, options in categories.items() if options.group == group