def yaml_save_roundtrip(filename, data, create_backup=False):
"""
Dump yaml using the RoundtripDumper and correct linespacing in output file
:param filename: name of the yaml file to save to
:param data: data structure to save
"""
if not EDITING_ENABLED:
return
sdata = yaml.dump(data, Dumper=yaml.RoundTripDumper, version=yaml_version, indent=indent_spaces, block_seq_indent=block_seq_indent, width=12288, allow_unicode=True)
# with open(filename+'_raw'+YAML_FILE, 'w') as outfile:
# outfile.write( sdata )
if create_backup:
if os.path.isfile(filename+YAML_FILE):
shutil.copy2(filename+YAML_FILE, filename+'.bak')
sdata = _format_yaml_dump2( sdata )
with open(filename+YAML_FILE, 'w') as outfile:
outfile.write( sdata )
评论列表
文章目录