| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. | 2 # Copyright 2016 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 import argparse | 6 import argparse |
| 7 import codecs | 7 import codecs |
| 8 import json | 8 import json |
| 9 import sys | 9 import sys |
| 10 import os | 10 import os |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 parser.add_argument('--json', nargs='+', default=[], | 28 parser.add_argument('--json', nargs='+', default=[], |
| 29 help='Zero or more HistogramSet JSON file paths (input).') | 29 help='Zero or more HistogramSet JSON file paths (input).') |
| 30 parser.add_argument('--mapresults', nargs='+', default=[], | 30 parser.add_argument('--mapresults', nargs='+', default=[], |
| 31 help='Zero or more map results JSON file paths (input).') | 31 help='Zero or more map results JSON file paths (input).') |
| 32 args = parser.parse_args() | 32 args = parser.parse_args() |
| 33 | 33 |
| 34 histograms = [] | 34 histograms = [] |
| 35 | 35 |
| 36 for html_path in args.html: | 36 for html_path in args.html: |
| 37 histograms.extend(results_renderer.ReadExistingResults( | 37 histograms.extend(results_renderer.ReadExistingResults( |
| 38 open(html_path, 'r'))) | 38 open(html_path, 'r').read())) |
| 39 | 39 |
| 40 for json_path in args.json: | 40 for json_path in args.json: |
| 41 histograms.extend(json.load(open(json_path, 'r'))) | 41 histograms.extend(json.load(open(json_path, 'r'))) |
| 42 | 42 |
| 43 for json_path in args.mapresults: | 43 for json_path in args.mapresults: |
| 44 for filename, results in json.load(open(json_path, 'r')).iteritems(): | 44 for filename, results in json.load(open(json_path, 'r')).iteritems(): |
| 45 for histogram in results['pairs']['histograms']: | 45 for histogram in results['pairs']['histograms']: |
| 46 histogram['diagnostics']['iteration']['storyUrl'] = filename | 46 histogram['diagnostics']['iteration']['storyUrl'] = filename |
| 47 histograms.append(histogram) | 47 histograms.append(histogram) |
| 48 | 48 |
| 49 open(args.html_path, 'a').close() # Create file if it doesn't exist. | 49 open(args.html_path, 'a').close() # Create file if it doesn't exist. |
| 50 with codecs.open(args.html_path, | 50 with codecs.open(args.html_path, |
| 51 mode='r+', encoding='utf-8') as output_stream: | 51 mode='r+', encoding='utf-8') as output_stream: |
| 52 results_renderer.RenderHTMLView(histograms, output_stream) | 52 results_renderer.RenderHTMLView(histograms, output_stream) |
| 53 | 53 |
| 54 if __name__ == '__main__': | 54 if __name__ == '__main__': |
| 55 sys.exit(main()) | 55 sys.exit(main()) |
| OLD | NEW |