I use the load_yaml_guess_indent(f, preserve_quotes=True)
to read a YAML file, then modify it and write it back. I noticed long lines are getting wrapped when they are written back. (A line break is inserted after 80-85 characters.) Is there a parameter I can pass to stop this from happening?
These are the parameters you can hand in to round_trip_dump()
:
def round_trip_dump(data, stream=None, Dumper=RoundTripDumper,
default_style=None, default_flow_style=None,
canonical=None, indent=None, width=None,
allow_unicode=None, line_break=None,
encoding=enc, explicit_start=None, explicit_end=None,
version=None, tags=None, block_seq_indent=None,
top_level_colon_align=None, prefix_colon=None):
The one you are looking for is width
If you are using the new (ruamel.yaml >= 0.15
) API, most of these parameters directly translate to attributes on the YAML instance you create, so in that case you would do:
yaml = ruamel.yaml.YAML()
yaml.width = 4096 # or some other big enough value to prevent line-wrap
yaml.dump(data, stream=your_stream)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With