Dump a Python object to a YAML-formatted string. :type yaml: ruamel.yaml.YAML :param yaml: An instance of ruamel.yaml.YAML. :type data: object :param data: A Python object that can be dumped to YAML.
(yaml, data)
| 476 | |
| 477 | |
| 478 | def dump_yaml_to_str(yaml, data): |
| 479 | """Dump a Python object to a YAML-formatted string. |
| 480 | |
| 481 | :type yaml: ruamel.yaml.YAML |
| 482 | :param yaml: An instance of ruamel.yaml.YAML. |
| 483 | |
| 484 | :type data: object |
| 485 | :param data: A Python object that can be dumped to YAML. |
| 486 | """ |
| 487 | stream = StringIO() |
| 488 | yaml.dump(data, stream) |
| 489 | return stream.getvalue() |
| 490 | |
| 491 | |
| 492 | class SafeLineBreakEmitter(ruamel.yaml.emitter.Emitter): |