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:
parent
a0db6e4892
commit
da0c5e906a
|
@ -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):
|
def __init__(self, validation_path):
|
||||||
self.dict = self._get_content(validation_path)
|
self.dict = self._get_content(validation_path)
|
||||||
|
@ -278,15 +283,13 @@ class Validation(object):
|
||||||
"""
|
"""
|
||||||
data = {}
|
data = {}
|
||||||
metadata = self.get_metadata
|
metadata = self.get_metadata
|
||||||
|
|
||||||
if metadata:
|
if metadata:
|
||||||
for key in metadata.keys():
|
for key in metadata.keys():
|
||||||
if key in map(str.lower, self._col_keys):
|
if key in self._col_names.keys():
|
||||||
for k in self._col_keys:
|
data[self._col_names[key]] = metadata[key]
|
||||||
if key == k.lower():
|
|
||||||
output_key = k
|
|
||||||
data[output_key] = self.get_metadata.get(key)
|
|
||||||
else:
|
else:
|
||||||
# Get all other values:
|
# Get all other values:
|
||||||
data[key] = self.get_metadata.get(key)
|
data[key] = metadata[key]
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
Loading…
Reference in New Issue