scripts: extract_dts_include: convert inherited 'id' to 'node_type'

During yaml collapse step, convert inherited 'id' key to 'node_type'.
With this new 'node_type', it's is more easy to apply common treatment
to all bindings that include the same base yaml file but might not
have similar bindings/constraint naming convention.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2017-11-22 13:26:04 +01:00 committed by Anas Nashif
commit 1ee8eeaccc

View file

@ -477,15 +477,20 @@ def dict_merge(dct, merge_dct):
else:
dct[k] = merge_dct[k]
def yaml_traverse_inherited(node):
""" Recursive overload procedure inside ``node``
``inherits`` section is searched for and used as node base when found.
Base values are then overloaded by node values
Additionally, 'id' key of 'inherited' dict is converted to 'node_type'
:param node:
:return: node
"""
if 'inherits' in node.keys():
if 'id' in node['inherits'].keys():
node['inherits']['node_type'] = node['inherits']['id']
node['inherits'].pop('id')
if 'inherits' in node['inherits'].keys():
node['inherits'] = yaml_traverse_inherited(node['inherits'])
dict_merge(node['inherits'], node)