Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Unified Diff: tools/jsondiff.py

Issue 20654006: download and rebaseline images using server (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/skpdiff/diff_viewer.js » ('j') | tools/skpdiff/diff_viewer.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/jsondiff.py
diff --git a/tools/jsondiff.py b/tools/jsondiff.py
index dd89c6d8dc7d54f6a37ff872d7d0d9bba37e8c57..34808b1cbc0dc351ba8d771f21ad1706909262ae 100755
--- a/tools/jsondiff.py
+++ b/tools/jsondiff.py
@@ -54,8 +54,8 @@ class GMDiffer(object):
else:
return open(filepath, 'r').read()
- def _GetExpectedResults(self, filepath):
- """Returns the dictionary of expected results from a JSON file,
+ def _GetExpectedResults(self, contents):
+ """Returns the dictionary of expected results from a JSON string,
in this form:
{
@@ -75,7 +75,6 @@ class GMDiffer(object):
returned dictionary.
"""
result_dict = {}
- contents = self._GetFileContentsAsString(filepath)
json_dict = gm_json.LoadFromString(contents)
all_expectations = json_dict[gm_json.JSONKEY_EXPECTEDRESULTS]
for test_name in all_expectations.keys():
@@ -96,8 +95,8 @@ class GMDiffer(object):
result_dict[test_name] = digest_pair[1]
return result_dict
- def _GetActualResults(self, filepath):
- """Returns the dictionary of actual results from a JSON file,
+ def _GetActualResults(self, contents):
+ """Returns the dictionary of actual results from a JSON string,
in this form:
{
@@ -116,7 +115,6 @@ class GMDiffer(object):
returned dictionary.
"""
result_dict = {}
- contents = self._GetFileContentsAsString(filepath)
json_dict = gm_json.LoadFromString(contents)
all_result_types = json_dict[gm_json.JSONKEY_ACTUALRESULTS]
for result_type in all_result_types.keys():
@@ -152,11 +150,26 @@ class GMDiffer(object):
If newfile is not specified, then 'new' is the actual results within
oldfile.
"""
- old_results = self._GetExpectedResults(oldfile)
+ old_results = self._GetExpectedResults(self._GetFileContentsAsString(oldfile))
epoger 2013/08/02 14:33:06 I think it would be a bit cleaner to have this met
Zach Reizner 2013/08/02 21:30:58 Done.
if newfile:
- new_results = self._GetExpectedResults(newfile)
+ new_results = self._GetExpectedResults(self._GetFileContentsAsString(newfile))
else:
- new_results = self._GetActualResults(oldfile)
+ new_results = self._GetActualResults(self._GetFileContentsAsString(oldfile))
+ return self._DictionaryDiff(old_results, new_results)
+
+ def GenerateDiffDictFromStrings(self, oldjson, newjson=None):
+ """Generate a dictionary showing the diffs:
+ old = expectations within oldjson
+ new = expectations within newjson
+
+ If newfile is not specified, then 'new' is the actual results within
+ oldfile.
+ """
+ old_results = self._GetExpectedResults(oldjson)
+ if newjson:
+ new_results = self._GetExpectedResults(newjson)
+ else:
+ new_results = self._GetActualResults(oldjson)
return self._DictionaryDiff(old_results, new_results)
« no previous file with comments | « no previous file | tools/skpdiff/diff_viewer.js » ('j') | tools/skpdiff/diff_viewer.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698