| OLD | NEW |
| 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 Loading... |
| 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) |
| OLD | NEW |