James Feist | 678715a | 2018-12-11 15:34:43 -0800 | [diff] [blame] | 1 | #!/usr/bin/python3 |
| 2 | # all arguments to this script are considered as json files |
| 3 | # and attempted to be formatted alphabetically |
| 4 | |
| 5 | import json |
| 6 | from sys import argv |
| 7 | |
| 8 | for file in argv[1:]: |
Patrick Williams | a3db66b | 2022-12-04 16:27:08 -0600 | [diff] [blame] | 9 | print("formatting file {}".format(file)) |
| 10 | with open(file) as f: |
| 11 | j = json.load(f) |
James Feist | 678715a | 2018-12-11 15:34:43 -0800 | [diff] [blame] | 12 | |
Patrick Williams | a3db66b | 2022-12-04 16:27:08 -0600 | [diff] [blame] | 13 | with open(file, "w") as f: |
| 14 | f.write( |
| 15 | json.dumps(j, indent=4, sort_keys=True, separators=(",", ": ")) |
| 16 | ) |