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