From be5096d6527b2c6f5a9ed18be736744b4e25fd03 Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Sat, 16 Dec 2023 13:47:48 +0100 Subject: [PATCH] Add deletion function to ruamel.yaml dicts --- npbackup/configuration.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/npbackup/configuration.py b/npbackup/configuration.py index 89da1ff..929e836 100644 --- a/npbackup/configuration.py +++ b/npbackup/configuration.py @@ -83,8 +83,22 @@ def s(self, path, value, sep='.'): data = data[key] data[lastkey] = value +def d(self, path, sep='.'): + """ + Deletion for dot notation in a dict/OrderedDict + d.d('my.array.keys') + """ + data = self + keys = path.split(sep) + lastkey = keys[-1] + for key in keys[:-1]: + data = data[key] + data.pop(lastkey) + + ordereddict.g = g ordereddict.s = s +ordereddict.d = d # NPF-SEC-00003: Avoid password command divulgation ENCRYPTED_OPTIONS = [ @@ -354,11 +368,6 @@ def get_repo_config(full_config: dict, repo_name: str = 'default', eval_variable # In other cases, just keep repo confg _config_inheritance.s(key, False) - - - - - return _repo_config, _config_inheritance return _inherit_group_settings(_repo_config, _group_config, _config_inheritance)