[enh] bind heritage in config panel

This commit is contained in:
ljf (zamentur) 2023-08-25 20:53:30 +02:00 committed by GitHub
parent b0fe49ae83
commit fde05c0ac2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -108,11 +108,11 @@ _ynh_app_config_apply_one() {
else else
local bind_after="" local bind_after=""
local bind_key_="$(echo "$bind" | cut -d: -f1)" local bind_key_="$(echo "$bind" | cut -d: -f1)"
bind_key_=${bind_key_:-$short_setting}
if [[ "$bind_key_" == *">"* ]]; then if [[ "$bind_key_" == *">"* ]]; then
bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)" bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)"
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)" bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
fi 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/)" 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" 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(): for panel_name, panel in loaded_toml.items():
if not isinstance(panel, dict): continue if not isinstance(panel, dict): continue
bind_panel = panel.get('bind')
for section_name, section in panel.items(): for section_name, section in panel.items():
if not isinstance(section, dict): continue if not isinstance(section, dict): continue
bind_section = section.get('bind', bind_panel)
for name, param in section.items(): for name, param in section.items():
if not isinstance(param, dict): if not isinstance(param, dict):
continue 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([ print(';'.join([
name, name,
param.get('type', 'string'), param.get('type', 'string'),
param.get('bind', 'settings' if param.get('type', 'string') != 'file' else 'null') bind
])) ]))
EOL EOL
) )