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

Side by Side Diff: gm/gm_json.py

Issue 18348018: rebaseline.py: if expectations dir contains JSON format results, update those instead of image files (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: ready_for_review 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tools/rebaseline.py » ('j') | tools/rebaseline.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Schema of the JSON summary file written out by the GM tool. 6 """Schema of the JSON summary file written out by the GM tool.
7 7
8 This must be kept in sync with the kJsonKey_ constants in gm_expectations.cpp ! 8 This must be kept in sync with the kJsonKey_ constants in gm_expectations.cpp !
9 """ 9 """
10 10
(...skipping 27 matching lines...) Expand all
38 # otherwise). 38 # otherwise).
39 json_dict = json.loads(file_contents) 39 json_dict = json.loads(file_contents)
40 return json_dict 40 return json_dict
41 41
42 def LoadFromFile(file_path): 42 def LoadFromFile(file_path):
43 """Loads the JSON summary written out by the GM tool. 43 """Loads the JSON summary written out by the GM tool.
44 Returns a dictionary keyed by the values listed as JSONKEY_ constants 44 Returns a dictionary keyed by the values listed as JSONKEY_ constants
45 above.""" 45 above."""
46 file_contents = open(file_path, 'r').read() 46 file_contents = open(file_path, 'r').read()
47 return LoadFromString(file_contents) 47 return LoadFromString(file_contents)
48
49 def WriteToFile(json_dict, file_path):
50 """Writes the JSON summary in json_dict out to file_path."""
51 with open(file_path, 'w') as outfile:
52 json.dump(json_dict, outfile, sort_keys=True, indent=2)
OLDNEW
« no previous file with comments | « no previous file | tools/rebaseline.py » ('j') | tools/rebaseline.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698