saveyaml#

saveyaml(filename=None, obj=None, folder=None, die=True, keepnone=False, dumpall=False, sanitizepath=True, **kwargs)[source]#

Convenience function for saving to a YAML file.

Parameters:
  • filename (str) – the file to save (if empty, return string representation of the YAML instead)

  • obj (anything) – the object to save

  • folder (str) – folder if not part of the filename

  • die (bool) – whether or not to raise an exception if saving an empty object

  • indent (int) – indentation to use for saved YAML

  • keepnone (bool) – allow sc.saveyaml(None) to return ‘null’ rather than raising an exception

  • dumpall (bool) – if True, treat a list input as separate YAML pages

  • sanitizepath (bool) – whether to sanitize the path prior to saving

  • kwargs (dict) – passed to yaml.dump()

Returns:

The filename saved to

Examples:

yaml = {'foo':'bar', 'data':[1,2,3]}
sc.saveyaml('my-file.yaml', yaml) # Save to file

string = sc.saveyaml(obj=yaml) # Export to string