File: yaml_to_json.py

package info (click to toggle)
python-trame 3.12.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 101,620 kB
  • sloc: python: 13,515; sh: 183; javascript: 93; makefile: 7
file content (18 lines) | stat: -rwxr-xr-x 341 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3

import json
import sys

import yaml

if len(sys.argv) < 3:
    sys.exit("Usage: <script> <input_yaml> <output_json>")

input_file = sys.argv[1]
output_file = sys.argv[2]

with open(input_file, "r") as rf:
    input_dict = yaml.safe_load(rf)

with open(output_file, "w") as wf:
    json.dump(input_dict, wf, indent=2)