in src/cfnlint/template.py [0:0]
def get_object_without_nested_conditions(self, obj, path):
"""
Get a list of object values without conditions included.
Evaluates deep into the object removing any nested conditions as well
"""
results = []
scenarios = self.get_condition_scenarios_below_path(path)
if not isinstance(obj, (dict, list)):
return results
if not scenarios:
if isinstance(obj, dict):
if len(obj) == 1:
if obj.get('Ref') == 'AWS::NoValue':
return results
return [{
'Scenario': None,
'Object': obj
}]
def get_value(value, scenario): # pylint: disable=R0911
""" Get the value based on the scenario resolving nesting """
if isinstance(value, dict):
if len(value) == 1:
if 'Fn::If' in value:
if_values = value.get('Fn::If')
if len(if_values) == 3:
if_path = scenario.get(if_values[0], None)
if if_path is not None:
if if_path:
return get_value(if_values[1], scenario)
return get_value(if_values[2], scenario)
elif value.get('Ref') == 'AWS::NoValue':
return None
new_object = {}
for k, v in value.items():
new_object[k] = get_value(v, scenario)
return new_object
if isinstance(value, list):
new_list = []
for item in value:
new_value = get_value(item, scenario)
if new_value is not None:
new_list.append(get_value(item, scenario))
return new_list
return value
for scenario in scenarios:
results.append({
'Scenario': scenario,
'Object': get_value(obj, scenario)
})
return results