fix: fallback to given value if not parseable

This commit is contained in:
Manuel Schmid 2024-06-06 18:20:14 +02:00
parent c4faf2ae6c
commit beab2b9d48
No known key found for this signature in database
GPG Key ID: 32C4F7569B40B84B
2 changed files with 9 additions and 5 deletions

View File

@ -209,8 +209,9 @@ def get_config_item_or_set_default(key, default_value, validator, disable_empty_
v = os.getenv(key)
if v is not None:
v = try_parse_bool(v)
print(f"Environment: {key} = {v}")
config_dict[key] = try_parse_bool(v)
config_dict[key] = v
if key not in config_dict:
config_dict[key] = default_value

View File

@ -29,7 +29,10 @@ def get_files_from_folder(folder_path, extensions=None, name_filter=None):
def try_parse_bool(value: str) -> str | bool:
value_eval = literal_eval(value.strip().title())
if type(value_eval) is bool:
return value_eval
return value
try:
value_eval = literal_eval(value.strip().title())
if type(value_eval) is bool:
return value_eval
return value
except ValueError | TypeError:
return value