New submission from Harshini <nvoru...@qti.qualcomm.com>:
I observed that the indentation is not preserved when I load and dump a YAML file using round_trip_dump from ruamel.yaml. For example, I have an input file with the data: Inventory: - name: Apples count: 10 vendors: - - vendor_name: xyz boxes: 2 - name: Bananas number: 20 vendors: - - vendor_name: abc boxes: 1 - vendor_name: xyz boxes: 4 I wrote a simple script that just loads and dumps the same data into a new YAML file: import sys import os import ruamel.yaml yaml = ruamel.yaml.YAML() input_file = sys.argv[1] output_yaml = r"data_output.yaml" output = open(output_yaml, 'w+') with open(input_file, 'r') as f: data = yaml.load(f) ruamel.yaml.round_trip_dump(data, output) I would expect the output yaml to be the same as the input yaml but what is see is: Inventory: - name: Apples count: 10 vendors: - - vendor_name: xyz boxes: 2 - name: Bananas number: 20 vendors: - - vendor_name: abc boxes: 1 - vendor_name: xyz boxes: 4 It is missing the indentation under Inventory as there should be a tab before "- name" . ---------- components: Library (Lib) files: input.yaml messages: 413502 nosy: nvorugan priority: normal severity: normal status: open title: Indentation now preserved with ruamel.yaml.round_trip_dump type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file50629/input.yaml _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46792> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com