aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/jsondiff.py
diff options
context:
space:
mode:
authorGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-16 18:56:32 +0000
committerGravatar epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-07-16 18:56:32 +0000
commit61822a25d33c18c0bd0397774451fc6ada58c310 (patch)
treedd4778f741c3f558764d54f6fb5f8a92bc6ff222 /tools/jsondiff.py
parent50df63148630ab1bf953789cb425ef068b8ab713 (diff)
svndiff.py: add ability to compare before-and-after JSON files, not just raw images
This should complete step 3 of https://goto.google.com/ChecksumTransitionDetail ! R=borenet@google.com Review URL: https://codereview.chromium.org/19112002 git-svn-id: http://skia.googlecode.com/svn/trunk@10113 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tools/jsondiff.py')
-rwxr-xr-xtools/jsondiff.py38
1 files changed, 23 insertions, 15 deletions
diff --git a/tools/jsondiff.py b/tools/jsondiff.py
index a1ca257572..dd89c6d8dc 100755
--- a/tools/jsondiff.py
+++ b/tools/jsondiff.py
@@ -11,6 +11,8 @@ found in the LICENSE file.
Gathers diffs between 2 JSON expectations files, or between actual and
expected results within a single JSON actual-results file,
and generates an old-vs-new diff dictionary.
+
+TODO(epoger): Fix indentation in this file (2-space indents, not 4-space).
'''
# System-level imports
@@ -158,18 +160,24 @@ class GMDiffer(object):
return self._DictionaryDiff(old_results, new_results)
-# main...
-parser = argparse.ArgumentParser()
-parser.add_argument('old',
- help='Path to JSON file whose expectations to display on ' +
- 'the "old" side of the diff. This can be a filepath on ' +
- 'local storage, or a URL.')
-parser.add_argument('new', nargs='?',
- help='Path to JSON file whose expectations to display on ' +
- 'the "new" side of the diff; if not specified, uses the ' +
- 'ACTUAL results from the "old" JSON file. This can be a ' +
- 'filepath on local storage, or a URL.')
-args = parser.parse_args()
-differ = GMDiffer()
-diffs = differ.GenerateDiffDict(oldfile=args.old, newfile=args.new)
-json.dump(diffs, sys.stdout, sort_keys=True, indent=2)
+def _Main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument(
+ 'old',
+ help='Path to JSON file whose expectations to display on ' +
+ 'the "old" side of the diff. This can be a filepath on ' +
+ 'local storage, or a URL.')
+ parser.add_argument(
+ 'new', nargs='?',
+ help='Path to JSON file whose expectations to display on ' +
+ 'the "new" side of the diff; if not specified, uses the ' +
+ 'ACTUAL results from the "old" JSON file. This can be a ' +
+ 'filepath on local storage, or a URL.')
+ args = parser.parse_args()
+ differ = GMDiffer()
+ diffs = differ.GenerateDiffDict(oldfile=args.old, newfile=args.new)
+ json.dump(diffs, sys.stdout, sort_keys=True, indent=2)
+
+
+if __name__ == '__main__':
+ _Main()