1cf3c1e67SAndrew Jeffery#!/usr/bin/python3
2cf3c1e67SAndrew Jeffery# all arguments to this script are considered as json files
3cf3c1e67SAndrew Jeffery# and attempted to be formatted alphabetically
4cf3c1e67SAndrew Jeffery
5cf3c1e67SAndrew Jefferyimport json
6cf3c1e67SAndrew Jefferyfrom sys import argv
7cf3c1e67SAndrew Jeffery
8cf3c1e67SAndrew Jefferyfor file in argv[1:]:
9cf3c1e67SAndrew Jeffery    print("formatting file {}".format(file))
10cf3c1e67SAndrew Jeffery    with open(file) as f:
11cf3c1e67SAndrew Jeffery        j = json.load(f)
12cf3c1e67SAndrew Jeffery
13*a3db66b3SPatrick Williams    with open(file, "w") as f:
14*a3db66b3SPatrick Williams        f.write(
15*a3db66b3SPatrick Williams            json.dumps(j, indent=4, sort_keys=True, separators=(",", ": "))
16*a3db66b3SPatrick Williams        )
17