gm_json.py: add ability to load JSON file from a string, not just a local file

This will make it easier to read JSON files from new sources (HTTP, etc.)

R=scroggo@google.com

Review URL: https://codereview.chromium.org/15934018

git-svn-id: http://skia.googlecode.com/svn/trunk@9431 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gm_json.py b/gm/gm_json.py
index 04c0d6a..6ba3a26 100644
--- a/gm/gm_json.py
+++ b/gm/gm_json.py
@@ -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)