Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yaml with comments #191

Closed
podhmo opened this issue Aug 16, 2022 · 1 comment · Fixed by #195
Closed

yaml with comments #191

podhmo opened this issue Aug 16, 2022 · 1 comment · Fixed by #195

Comments

@podhmo
Copy link
Owner

podhmo commented Aug 16, 2022

@podhmo
Copy link
Owner Author

podhmo commented Aug 16, 2022

use ruamel.yaml and some settings

import sys
import io
from ruamel.yaml import YAML

code = ""

yaml = YAML()
yaml.preserve_quotes = True
yaml.indent(mapping=2, sequence=2, offset=2)
d = yaml.load(io.StringIO(code))
yaml.dump(d, sys.stdout)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant