Using pyYaml to create input file for a small db migration project, I did not found any place describing the exhaustive list of keyword attributes that yaml.dump method accepts. Here is a first guess :
I found some information in the cyaml.py file of python-yaml. Some of them are described on the PyYAML documentation page (http://pyyaml.org/wiki/PyYAMLDocumentation). I’m not a YAML expert thus, please comment to correct misunderstandings or errors in my description.
Valid keywords for the method def dump(data, stream=None, Dumper=Dumper, **kwds) in python-yaml :
default_style : indicates the style of the scalar. Possible values are None, '', '\'', '"', '|', '>'.
default_flow_style : indicates if a collection is block or flow. The possible values are None, True, False.
canonical : if True export tag type to the output file
indent : sets the preferred indentation
width : set the preferred line width
allow_unicode : allow unicode in output file
line_break : specify the line break you need
encoding : output encoding, defaults to utf-8
explicit_start : if True, adds an explicit start using “—”
explicit_end: if True, adds an explicit end using “—”
version : version of the YAML parser, tuple (major, minor), supports only major version 1
tags : I didn’t find any information about this parameter … and no time to test it ;-). Comments are welcome !
Yeah, got the same problem. Big documentation, but no informations >.<
Hey, thanks for taking the time to write this down — it was enough for me to figure out that setting default_flow_style = False will cause each field to go on a separate line, as I needed.
More undocumented surprises…
By default yaml.load will resolve any of these as booleans!
yes|Yes|YES|no|No|NO|true|True|TRUE|false|False|FALSE|on|On|ON|off|Off|OFF
OK, that’s because pyyaml supports only the older 1.1 specs…
[…] piuttosto scarsa – non ancora, di un documento di parametri per la funzione dump. Ho trovato https://dpinte.wordpress.com/2008/10/31/pyaml-dump-option/. Tuttavia, sono ancora mancanti le informazioni di cui ho bisogno. (Ho iniziato a guardare la […]
I am genuinely delighted to glance ɑt thіs blog posts wһich inncludes lotfs of useful informati᧐n, thankѕ for providing
such informatiоn.
Ask relationship question
pyYaml dump options | Things and thoughts
Digital Marketing
pyYaml dump options | Things and thoughts
[…] Better documentation for to_nice_yaml can be found here. […]
[…] is pretty poor – does not even document the parameters to the dump function. I found https://dpinte.wordpress.com/2008/10/31/pyaml-dump-option/. However, I’m still missing the information I need. (I started to look at the source, but it […]
[…] Better documentation for to_nice_yaml can be found here. […]
[…] Source: https://dpinte.wordpress.com/2008/10/31/pyaml-dump-option/ […]