get file name from data ruamel data struxture
ruamel.yaml is a YAML 1.2 parser/emitter for Python
Brought to you by:
anthon
Is it possible to retrieve the file name from the data structure of a parsed yaml file?
In my application I am parsing multiple yaml files.
To the detailed plausibility checking is happening somewhere deep down in the program structure.
At that points I am using the data[key]. lc. to get point to the collection where e.g. an entire is missing, where I am informing the user.
It would be very helpfull to get the filename of the original yaml form the ruamel data object to display it here
This is not a bug report, so you should post this question on stackoverflow as per the help text.
The data structure contained doesn't include the filename. There is of course no obligation to load from a file in the first place.
It is trivial to graft the filename on the root-level object as an attribute after the data is loaded and returned. Alternatively you could use ruamel.yaml.base, which keeps the filename in the
._pathattribute where you can access the.dataattribute for the root of the content (loaded only when accessed).