I want to search for a key in a nested YAML file. I have the path for the key as user/name/firstname
. I am loading the YAML file using ruamel.yaml
and I have set off the path to the keys.
Now I want to look for the key using the path in the exact same pattern.
I am generating this path using flat_keys = flatten(data , reducer='path')
.
and using processor.set_value(yaml_path,new_value)
to update value. But before updating, I want to check if the key exists in the given path.
sample:
user:
name:
firstname:
lastname:
Is there a way to do that?