diff options
author | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-09-03 11:03:13 +0200 |
---|---|---|
committer | Shyamnath Premnadh <Shyamnath.Premnadh@qt.io> | 2024-09-05 16:17:20 +0200 |
commit | 0b08eacaaa8fd1c6ca50ab339ee93a9621b8999a (patch) | |
tree | dd7a6f9dea45599ee38212cfa64bdb9070dbe79d /sources/pyside-tools | |
parent | 5e913b5975be387721124d72841efce46274def7 (diff) |
Deployment: Change the order of set_or_fetch function
- The value provided through cli is prioritized over the value in the
config file.
- Update the docstring for the set_or_fetch function.
- Additionally, fix an error on run_qmlimportscanner() where the first
argument was passed as a list instead of a tuple.
Pick-to: 6.7
Task-number: PYSIDE-1612
Change-Id: I6afb25c8e88f7ee2fb4a88539d2b8b3170dcdd00
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside-tools')
-rw-r--r-- | sources/pyside-tools/deploy_lib/config.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sources/pyside-tools/deploy_lib/config.py b/sources/pyside-tools/deploy_lib/config.py index 180c4f7e5..c400348ec 100644 --- a/sources/pyside-tools/deploy_lib/config.py +++ b/sources/pyside-tools/deploy_lib/config.py @@ -171,16 +171,22 @@ class Config(BaseConfig): def set_or_fetch(self, config_property_val, config_property_key, config_property_group="app"): """ - If the value corresponding to the key exists in the config file, then return it. - Otherwise, set the value to the config file and return it. - Otherwise, raise an exception + Set the configuration value if provided, otherwise fetch the existing value. + Raise an exception if neither is available. + + :param value: The value to set if provided. + :param key: The configuration key. + :param group: The configuration group (default is "app"). + :return: The configuration value. + :raises RuntimeError: If no value is provided and no existing value is found. """ existing_value = self.get_value(config_property_group, config_property_key) - if existing_value: - return existing_value - elif config_property_val: + + if config_property_val: self.set_value(config_property_group, config_property_key, str(config_property_val)) return config_property_val + elif existing_value: + return existing_value else: raise RuntimeError( f"[DEPLOY] No value for {config_property_key} specified in config file or as cli" |