diff --git a/tools/oneclick/base/common_dict_file.py b/tools/oneclick/base/common_dict_file.py index a624aeba4d42780469276198ac32b35e366373bf..05c4c10a43774ad388b5df18fce89a8fa43a59e5 100644 --- a/tools/oneclick/base/common_dict_file.py +++ b/tools/oneclick/base/common_dict_file.py @@ -115,6 +115,19 @@ class CommonDictFile: self.filePathNames.pop(k) self.dicts.remove(the_dict) self.nof_dicts -= 1 + + def remove_all_but_the_dict_from_list(self, the_dict): + """Remove all dicts from the internal list of dicts from the available dictionary files, except the_dict.""" + k = self.dicts.index(the_dict) + filePath = self.filePaths[k] + filePathName = self.filePathNames[k] + self.filePaths = [] + self.filePaths.append(filePath) + self.filePathNames = [] + self.filePathNames.append(filePathName) + self.dicts = [] + self.dicts.append(the_dict) + self.nof_dicts = 1 def find_all_dict_file_paths(self, rootDir=None): """Recursively search the rootDir tree to find the paths to all fileName files.""" @@ -279,6 +292,15 @@ class CommonDictFile: key_values.append(None) return cm.unlistify(key_values) + def get_key_value(self, key, dict=None): + """Get the value of a key from a single dict or None in case the key does not exist.""" + if dict==None: dict=self.dicts[0] + if key in dict: + key_value = dict[key] + else: + key_value = None + return key_value + def get_dicts(self, key, values=None, dicts=None): """Get all dictionaries in dicts that contain the key with a value specified in values. If values==None then get all dictionaries in dicts that contain the key.