scripts: add yaml-normalize.py

This commit is contained in:
Dan Bungert 2022-08-29 13:47:04 -06:00
parent 68b92f1022
commit b9f75059be
1 changed files with 22 additions and 0 deletions

22
scripts/yaml-normalize.py Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/python3
# Run the input file through ruamel yaml to obtain a more consistent result.
import argparse
from ruamel.yaml import YAML
parser = argparse.ArgumentParser()
parser.add_argument('infile', help='yaml file to normalize')
args = parser.parse_args()
yaml = YAML()
yaml.default_flow_style = False
yaml.pure = True
yaml.indent(mapping=2, sequence=2, offset=2)
with open(args.infile, 'r') as fp:
data = yaml.load(fp)
with open(args.infile, 'w') as fp:
yaml.dump(data, fp)