From 9e06f1142e83b49e2a1e6684edb7e57e8597145f Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 19 May 2025 19:08:32 +0200 Subject: [PATCH] fix: user_data better support for follower variable --- src/rougail/user_datas.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/rougail/user_datas.py b/src/rougail/user_datas.py index e96252f3c..2c08222ea 100644 --- a/src/rougail/user_datas.py +++ b/src/rougail/user_datas.py @@ -218,6 +218,9 @@ class UserDatas: if not isinstance(value, list) or index >= len(value): continue value = value[index] + option_without_index = self.config.option(path) + else: + option_without_index = option if option.isleader(): len_leader = len(option.value.get()) if len_leader: @@ -225,21 +228,26 @@ class UserDatas: option.value.pop(idx) try: option.value.set(value) - option.information.set( - "loaded_from", _("loaded from {0}").format(self.values[path]["source"]) - ) value_is_set = True + except Exception: + if path != option.path(): + self.values[option.path()] = self.values.pop(path) + else: + if "source" in self.values[path]: + option_without_index.information.set( + "loaded_from", _("loaded from {0}").format(self.values[path]["source"]) + ) # value is correctly set, remove variable to the set if index is not None: # if it's a follower waiting for all followers are sets self.values[path]["values"][index] = undefined - if set(self.values[path]["values"]) == {undefined}: + for tmp_value in self.values[path]["values"]: + if tmp_value != undefined: + break + else: self.values.pop(path) else: self.values.pop(path) - except Exception: - if path != option.path(): - self.values[option.path()] = self.values.pop(path) if not value_is_set: break