#!/usr/bin/env pythonr"""Command-line tool to format software release JSON for slapos.Inspired by json.tool from pythonUsage:: format-json infile outfile"""importosimportsysimportjsonimportcollectionsdefmain():iflen(sys.argv)!=3:raiseSystemExit(sys.argv[0]+" infile outfile")withopen(sys.argv[1],'rb')asinfile:try:obj=json.load(infile,object_pairs_hook=collections.OrderedDict)exceptValueError,e:raiseSystemExit(e)withopen(sys.argv[2],'wb')asoutfile:json.dump(obj,outfile,sort_keys=False,indent=2,separators=(',',': '))outfile.write('\n')if__name__=='__main__':main()