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

Side by Side Diff: tools/telemetry/telemetry/results/csv_pivot_table_output_formatter.py

Issue 739623005: [Telemetry] Resolve errors due to new pylint checker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ready to land Created 6 years, 1 month 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
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import csv 5 import csv
6 6
7 from telemetry.results import output_formatter 7 from telemetry.results import output_formatter
8 from telemetry.value import scalar 8 from telemetry.value import scalar
9 9
10 10
(...skipping 17 matching lines...) Expand all
28 28
29 def __init__(self, output_stream, trace_tag=''): 29 def __init__(self, output_stream, trace_tag=''):
30 super(CsvPivotTableOutputFormatter, self).__init__(output_stream) 30 super(CsvPivotTableOutputFormatter, self).__init__(output_stream)
31 self._trace_tag = trace_tag 31 self._trace_tag = trace_tag
32 32
33 def Format(self, page_test_results): 33 def Format(self, page_test_results):
34 csv_writer = csv.writer(self.output_stream) 34 csv_writer = csv.writer(self.output_stream)
35 35
36 # Observe trace_tag. Use comma to split up the trace tag. 36 # Observe trace_tag. Use comma to split up the trace tag.
37 tag_values = self._trace_tag.split(',') 37 tag_values = self._trace_tag.split(',')
38 tag_values = filter(lambda x: x, tag_values) # filter empty list entries 38 tag_values = [x for x in tag_values if x] # filter empty list entries
39 tag_headers = ['trace_tag_%d' % i for i in range(len(tag_values))] 39 tag_headers = ['trace_tag_%d' % i for i in range(len(tag_values))]
40 40
41 # Write header. 41 # Write header.
42 csv_writer.writerow(self.FIELDS + tag_headers) 42 csv_writer.writerow(self.FIELDS + tag_headers)
43 43
44 # Write all values. Each row contains a value + page-level metadata. 44 # Write all values. Each row contains a value + page-level metadata.
45 for run in page_test_results.all_page_runs: 45 for run in page_test_results.all_page_runs:
46 run_index = page_test_results.all_page_runs.index(run) 46 run_index = page_test_results.all_page_runs.index(run)
47 page_dict = { 47 page_dict = {
48 'page': run.page.display_name, 48 'page': run.page.display_name,
49 'page_set': run.page.page_set.Name(), 49 'page_set': run.page.page_set.Name(),
50 'run_index': run_index, 50 'run_index': run_index,
51 } 51 }
52 for value in run.values: 52 for value in run.values:
53 if isinstance(value, scalar.ScalarValue): 53 if isinstance(value, scalar.ScalarValue):
54 value_dict = { 54 value_dict = {
55 'name': value.name, 55 'name': value.name,
56 'value': value.value, 56 'value': value.value,
57 'units': value.units, 57 'units': value.units,
58 } 58 }
59 value_dict.update(page_dict.items()) 59 value_dict.update(page_dict.items())
60 csv_writer.writerow( 60 csv_writer.writerow(
61 [value_dict[field] for field in self.FIELDS] + tag_values) 61 [value_dict[field] for field in self.FIELDS] + tag_values)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698