-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3ba6bc
commit 893078c
Showing
1 changed file
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
import sys, json, yaml | ||
"""Convert a YAML file to JSON.""" | ||
|
||
with open(sys.argv[1], mode='r', encoding='utf-8') as f_in: | ||
with open(sys.argv[2], mode='w', encoding='utf-8') as f_out: | ||
json.dump(yaml.safe_load(f_in.read()), f_out, indent=2, separators=(',', ': ')) | ||
import json | ||
import sys | ||
|
||
import yaml | ||
|
||
yaml_filename = sys.argv[1] | ||
json_filename = sys.argv[2] | ||
|
||
with open(yaml_filename, mode="r", encoding="utf-8") as f_in: | ||
with open(json_filename, mode="w", encoding="utf-8") as f_out: | ||
contents = yaml.safe_load(f_in.read()) | ||
json.dump(contents, f_out, indent=2, separators=(",", ": ")) |