Browse Source

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
changes/84/771984/3
Jiri Podivin 6 months ago
committed by Gael Chamoulaud
parent
commit
3d766c2861
  1. 17
      validations_libs/validation.py

17
validations_libs/validation.py

@ -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)
@ -273,15 +278,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
Loading…
Cancel
Save