How to use the pyaml.pprint function in pyaml

To help you get started, we’ve selected a few pyaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mk-fg / pretty-yaml / pyaml / __main__.py View on Github external
help='Replace specified path with prettified version in-place.')
	parser.add_argument('-w', '--width', type=int, metavar='chars',
		help='Max line width hint to pass to pyyaml for the dump.'
			' Only used to format scalars and collections (e.g. lists).')
	opts = parser.parse_args(argv or sys.argv[1:])

	src = open(opts.path) if opts.path else sys.stdin
	try: data = yaml.safe_load(src)
	finally: src.close()

	pyaml_kwargs = dict()
	if opts.width: pyaml_kwargs['width'] = opts.width
	if opts.replace and opts.path:
		with safe_replacement(opts.path) as tmp:
			pyaml.pprint(data, file=tmp, **pyaml_kwargs)
	else: pyaml.pprint(data, **pyaml_kwargs)
github mk-fg / pretty-yaml / pyaml / __main__.py View on Github external
parser.add_argument('-r', '--replace', action='store_true',
		help='Replace specified path with prettified version in-place.')
	parser.add_argument('-w', '--width', type=int, metavar='chars',
		help='Max line width hint to pass to pyyaml for the dump.'
			' Only used to format scalars and collections (e.g. lists).')
	opts = parser.parse_args(argv or sys.argv[1:])

	src = open(opts.path) if opts.path else sys.stdin
	try: data = yaml.safe_load(src)
	finally: src.close()

	pyaml_kwargs = dict()
	if opts.width: pyaml_kwargs['width'] = opts.width
	if opts.replace and opts.path:
		with safe_replacement(opts.path) as tmp:
			pyaml.pprint(data, file=tmp, **pyaml_kwargs)
	else: pyaml.pprint(data, **pyaml_kwargs)