From fde05c0ac2af8c2009be9952f7819604f9d56b6a Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Fri, 25 Aug 2023 20:53:30 +0200 Subject: [PATCH] [enh] bind heritage in config panel --- helpers/config | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/helpers/config b/helpers/config index 77f118c5f..6c6285cf6 100644 --- a/helpers/config +++ b/helpers/config @@ -108,11 +108,11 @@ _ynh_app_config_apply_one() { else local bind_after="" local bind_key_="$(echo "$bind" | cut -d: -f1)" - bind_key_=${bind_key_:-$short_setting} if [[ "$bind_key_" == *">"* ]]; then bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)" bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)" fi + bind_key_=${bind_key_:-$short_setting} local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)" ynh_backup_if_checksum_is_different --file="$bind_file" @@ -139,15 +139,31 @@ loaded_toml = toml.loads(file_content, _dict=OrderedDict) for panel_name, panel in loaded_toml.items(): if not isinstance(panel, dict): continue + bind_panel = panel.get('bind') for section_name, section in panel.items(): if not isinstance(section, dict): continue + bind_section = section.get('bind', bind_panel) for name, param in section.items(): if not isinstance(param, dict): continue + + bind = param.get('bind') + + if not bind: + if bind_section: + bind = bind_section + else: + bind = 'settings' if param.get('type', 'string') != 'file' else 'null' + elif bind[-1] == ":" and bind_section and ":" in bind_section: + regex, bind_file = bind_section.split(":") + if ">" in bind: + bind = bind + bind_file + else: + bind = regex + bind + bind_file print(';'.join([ name, param.get('type', 'string'), - param.get('bind', 'settings' if param.get('type', 'string') != 'file' else 'null') + bind ])) EOL )