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

Unified Diff: gm/gm_json.py

Issue 15934018: gm_json.py: add ability to load JSON file from a string, not just a local file (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 6 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 | « gm/display_json_results.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gm_json.py
===================================================================
--- gm/gm_json.py (revision 9428)
+++ gm/gm_json.py (working copy)
@@ -23,12 +23,19 @@
JSONKEY_ACTUALRESULTS_NOCOMPARISON = 'no-comparison'
JSONKEY_ACTUALRESULTS_SUCCEEDED = 'succeeded'
-def Load(filepath):
+def LoadFromString(file_contents):
"""Loads the JSON summary written out by the GM tool.
Returns a dictionary keyed by the values listed as JSONKEY_ constants
above."""
- # In the future, we should add a version number to the JSON file to ensure
+ # TODO(epoger): we should add a version number to the JSON file to ensure
# that the writer and reader agree on the schema (raising an exception
# otherwise).
- json_dict = json.load(open(filepath))
+ json_dict = json.loads(file_contents)
return json_dict
+
+def LoadFromFile(file_path):
+ """Loads the JSON summary written out by the GM tool.
+ Returns a dictionary keyed by the values listed as JSONKEY_ constants
+ above."""
+ file_contents = open(file_path, 'r').read()
+ return LoadFromString(file_contents)
« no previous file with comments | « gm/display_json_results.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698