Reduced complexity of a property method

Validation.get_formated_data was needlesly complex
Now it relies more on dictionaries it already used.

Couldn't find any other uses of Validation._col_keys,
might be candidate for further changes, or reversion.

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: Ied557010b31b83fbb823476c6ea4900ee7d9c581
This commit is contained in:
Jiri Podivin 2021-01-22 15:22:25 +01:00
parent a0db6e4892
commit da0c5e906a
1 changed files with 10 additions and 7 deletions

View File

@ -69,7 +69,12 @@ class Validation(object):
"""
_col_keys = ['ID', 'Name', 'Description', 'Groups']
_col_names = {
'id': 'ID',
'name': 'Name',
'description': 'Description',
'groups': 'Groups'
}
def __init__(self, validation_path):
self.dict = self._get_content(validation_path)
@ -278,15 +283,13 @@ class Validation(object):
"""
data = {}
metadata = self.get_metadata
if metadata:
for key in metadata.keys():
if key in map(str.lower, self._col_keys):
for k in self._col_keys:
if key == k.lower():
output_key = k
data[output_key] = self.get_metadata.get(key)
if key in self._col_names.keys():
data[self._col_names[key]] = metadata[key]
else:
# Get all other values:
data[key] = self.get_metadata.get(key)
data[key] = metadata[key]
return data