From a3e24f2693dba2f23ab5c7c66ad4027baff859e4 Mon Sep 17 00:00:00 2001 From: Valery Sinelnikov Date: Fri, 6 Oct 2023 11:30:17 +0400 Subject: [PATCH] Added the ability to query a dictionary across multiple dconf paths --- gpoa/storage/dconf_registry.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gpoa/storage/dconf_registry.py b/gpoa/storage/dconf_registry.py index 6a2677c..64e6d95 100644 --- a/gpoa/storage/dconf_registry.py +++ b/gpoa/storage/dconf_registry.py @@ -93,6 +93,9 @@ class Dconf_registry(): @staticmethod def get_matching_keys(path): + if path[0] != '/': + path = '/' + path + try: process = subprocess.Popen(['dconf', 'list', path], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) @@ -176,13 +179,13 @@ class Dconf_registry(): @classmethod - def get_dictionary_from_dconf(self, startswith): + def get_dictionary_from_dconf(self, *startswith_list): output_dict = {} - dconf_dict = self.get_key_values(self.get_matching_keys(startswith)) - - for key, value in dconf_dict.items(): - keys_tmp = key.split('/') - output_dict.setdefault('/'.join(keys_tmp[0:-1])[1:], {})[keys_tmp[-1]] = value + for startswith in startswith_list: + dconf_dict = self.get_key_values(self.get_matching_keys(startswith)) + for key, value in dconf_dict.items(): + keys_tmp = key.split('/') + update_dict(output_dict.setdefault('/'.join(keys_tmp[0:-1])[1:], {}), {keys_tmp[-1]: value}) return output_dict