From 59ca8b6caf0f3781dc353461ff911f2f6fb158f5 Mon Sep 17 00:00:00 2001 From: Andre Basche Date: Sat, 22 Jul 2023 11:48:40 +0200 Subject: [PATCH] Not loading favorite if base program renamed --- pyhon/command_loader.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyhon/command_loader.py b/pyhon/command_loader.py index 476eeb2..adf34b8 100644 --- a/pyhon/command_loader.py +++ b/pyhon/command_loader.py @@ -188,18 +188,19 @@ class HonCommandLoader: command = favourite.get("command", {}) command_name = command.get("commandName", "") program_name = self._clean_name(command.get("programName", "")) - base: HonCommand = copy( - self.commands[command_name].categories[program_name] - ) + if not (base := self.commands[command_name].categories.get(program_name)): + continue + base_command: HonCommand = copy(base) for data in command.values(): if isinstance(data, str): continue for key, value in data.items(): - if parameter := base.parameters.get(key): + if parameter := base_command.parameters.get(key): with suppress(ValueError): parameter.value = value extra_param = HonParameterFixed("favourite", {"fixedValue": "1"}, "custom") - base.parameters.update(favourite=extra_param) - if isinstance(program := base.parameters["program"], HonParameterProgram): + base_command.parameters.update(favourite=extra_param) + program = base_command.parameters["program"] + if isinstance(program, HonParameterProgram): program.set_value(name) - self.commands[command_name].categories[name] = base + self.commands[command_name].categories[name] = base_command