@@ -0,0 +1,1741 @@
+#!/usr/bin/python%0A%0A'''%0ACopyright 2013 Google Inc.%0A%0AUse of this source code is governed by a BSD-style license that can be%0Afound in the LICENSE file.%0A'''%0A%0A'''%0ARewrites a JSON file to use Python's standard JSON pretty-print format,%0Aso that subsequent runs of rebaseline.py will generate useful diffs%0A(only the actual checksum differences will show up as diffs, not obscured%0Aby format differences).%0A%0AShould not modify the JSON contents in any meaningful way.%0A'''%0A%0A# System-level imports%0Aimport argparse%0Aimport os%0Aimport sys%0A%0A# Imports from within Skia%0A#%0A# We need to add the 'gm' directory, so that we can import gm_json.py within%0A# that directory.  That script allows us to parse the actual-results.json file%0A# written out by the GM tool.%0A# Make sure that the 'gm' dir is in the PYTHONPATH, but add it at the *end*%0A# so any dirs that are already in the PYTHONPATH will be preferred.%0A#%0A# This assumes that the 'gm' directory has been checked out as a sibling of%0A# the 'tools' directory containing this script, which will be the case if%0A# 'trunk' was checked out as a single unit.%0AGM_DIRECTORY = os.path.realpath(%0A    os.path.join(os.path.dirname(os.path.dirname(__file__)), 'gm'))%0Aif GM_DIRECTORY not in sys.path:%0A    sys.path.append(GM_DIRECTORY)%0Aimport gm_json%0A%0Adef Reformat(filename):%0A  print 'Reformatting file %25s...' %25 filename%0A  gm_json.WriteToFile(gm_json.LoadFromFile(filename), filename)%0A%0Adef _Main():%0A  parser = argparse.ArgumentParser(description='Reformat JSON files in-place.')%0A  parser.add_argument('filenames', metavar='FILENAME', nargs='+',%0A                      help='file to reformat')%0A  args = parser.parse_args()%0A  for filename in args.filenames:%0A    Reformat(filename)%0A  sys.exit(0)%0A%0Aif __name__ == '__main__':%0A    _Main()%0A

add reformat-json.py script