diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2016-12-31 17:23:45 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2016-12-31 17:36:37 -0500 |
commit | 1a9eb561f2ae2ddccf68bdaada064c302442fb52 (patch) | |
tree | f7b9ab3e3b77a6909442200971db5ea7c140bb15 /buildstream/_yaml.py | |
parent | 2de72acdfdc13675389f24c73cb713132f81ef78 (diff) | |
download | buildstream-1a9eb561f2ae2ddccf68bdaada064c302442fb52.tar.gz |
_yaml.py: Added _yaml utility dump() to go with load()
Diffstat (limited to 'buildstream/_yaml.py')
-rw-r--r-- | buildstream/_yaml.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index fa7aa3569..2ad45c78e 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -179,6 +179,19 @@ def load(filename, shortname=None): return node_decorated_copy(shortname, contents) +# Dumps a previously loaded YAML node to a file +# +# Args: +# node (dict): A node previously loaded with _yaml.load() above +# filename (str): The YAML file to load +# +# +def dump(node, filename): + + with open(filename, 'w') as f: + yaml.round_trip_dump(node, f) + + # node_decorated_copy() # # Create a copy of a loaded dict tree decorated with Provenance |