summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/tracing/tracing_build/merge_traces.py
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/catapult/tracing/tracing_build/merge_traces.py')
-rw-r--r--chromium/third_party/catapult/tracing/tracing_build/merge_traces.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/chromium/third_party/catapult/tracing/tracing_build/merge_traces.py b/chromium/third_party/catapult/tracing/tracing_build/merge_traces.py
index df1029a8805..5294a7ea412 100644
--- a/chromium/third_party/catapult/tracing/tracing_build/merge_traces.py
+++ b/chromium/third_party/catapult/tracing/tracing_build/merge_traces.py
@@ -10,6 +10,7 @@ import argparse
import codecs
import collections
import gzip
+import io
import itertools
import json
import logging
@@ -93,11 +94,12 @@ class IdMap(object):
assert 'id' not in items # ID is set according to the path.
for key, value in items.items():
value_set = self._items[key]
- if (isinstance(value, collections.Iterable) and
+ if (isinstance(value, collections.abc.Iterable) and
not isinstance(value, StringTypes)):
value_set.update(value)
else:
value_set.add(value)
+ return None
def MapEntry(self, source, path):
"""Map an source-specific entry ID path to a canonical entry ID path.
@@ -288,9 +290,8 @@ class IdMap(object):
cls_name = type(self).__name__
if self._depth == 0:
return '%s root' % cls_name
- else:
- return '%s %s entry(%s)' % (cls_name, self.LEVELS[self._depth - 1].name,
- self._items)
+ return '%s %s entry(%s)' % (cls_name, self.LEVELS[self._depth - 1].name,
+ self._items)
class ProcessIdMap(IdMap):
@@ -310,19 +311,18 @@ def LoadTrace(filename):
logging.info('Loading trace %r...', filename)
if filename.endswith(HTML_FILENAME_SUFFIX):
return LoadHTMLTrace(filename)
- elif filename.endswith(GZIP_FILENAME_SUFFIX):
+ if filename.endswith(GZIP_FILENAME_SUFFIX):
with gzip.open(filename, 'rb') as f:
return json.load(f)
- else:
- with open(filename, 'r') as f:
- return json.load(f)
+ with open(filename, 'r') as f:
+ return json.load(f)
def LoadHTMLTrace(filename):
"""Load a trace from a vulcanized HTML trace file."""
trace_components = collections.defaultdict(list)
- with open(filename) as file_handle:
+ with io.open(filename, 'r', encoding='utf-8') as file_handle:
for sub_trace in html2trace.ReadTracesFromHTMLFile(file_handle):
for name, component in TraceAsDict(sub_trace).items():
trace_components[name].append(component)
@@ -406,8 +406,7 @@ def MergeComponents(component_name, components_by_filename):
"""Merge a component of multiple JSON traces into a single component."""
if component_name == 'traceEvents':
return MergeTraceEvents(components_by_filename)
- else:
- return MergeGenericTraceComponents(component_name, components_by_filename)
+ return MergeGenericTraceComponents(component_name, components_by_filename)
def MergeTraceEvents(events_by_filename):
@@ -645,7 +644,7 @@ def MergeGenericTraceComponents(component_name, components_by_filename):
provided value (in some trace).
"""
components = list(components_by_filename.values())
- first_component = next(components)
+ first_component = next(iter(components))
if not all(c == first_component for c in components):
logging.warning(
'Values of trace component %r differ across the provided traces. '