confighelper: don't overwrite option tracking

Its possible for any component to request a configuration
option from another component.  Don't overwrite the
inital value stored.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2022-07-25 12:26:47 -04:00
parent a178a6cd01
commit e264fa82b2
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 9 additions and 8 deletions

View File

@ -151,14 +151,15 @@ class ConfigHelper:
f"configuration, see {help} for detailed documentation." f"configuration, see {help} for detailed documentation."
) )
self._check_option(option, val, above, below, minval, maxval) self._check_option(option, val, above, below, minval, maxval)
if ( if option not in self.parsed[section]:
val is None or if (
isinstance(val, (int, float, bool, str, dict, list)) val is None or
): isinstance(val, (int, float, bool, str, dict, list))
self.parsed[section][option] = val ):
else: self.parsed[section][option] = val
# If the item cannot be encoded to json serialize to a string else:
self.parsed[section][option] = str(val) # If the item cannot be encoded to json serialize to a string
self.parsed[section][option] = str(val)
return val return val
def _check_option(self, def _check_option(self,