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 3# found in the LICENSE file. 4 5import os 6 7from telemetry.core import util 8from trace_viewer import trace_viewer_project 9 10 11def _FindAllFilesRecursive(source_paths, pred): 12 all_filenames = set() 13 for source_path in source_paths: 14 for dirpath, _, filenames in os.walk(source_path): 15 for f in filenames: 16 if f.startswith('.'): 17 continue 18 x = os.path.abspath(os.path.join(dirpath, f)) 19 if pred(x): 20 all_filenames.add(x) 21 return all_filenames 22 23 24class WebComponentsProject(trace_viewer_project.TraceViewerProject): 25 telemetry_path = os.path.abspath(util.GetTelemetryDir()) 26 27 def __init__(self, *args, **kwargs): 28 super(WebComponentsProject, self).__init__(*args, **kwargs) 29 30 exclude_paths = [os.path.join(self.telemetry_path, 'docs'), 31 os.path.join(self.telemetry_path, 'unittest_data'), 32 os.path.join(self.telemetry_path, 'support')] 33 excluded_html_files = _FindAllFilesRecursive( 34 exclude_paths, 35 lambda x: x.endswith('.html')) 36 37 self.non_module_html_files.extend(excluded_html_files) 38 self.non_module_html_files.appendRel(self.telemetry_path, 'results.html') 39 40 self.source_paths.append(self.telemetry_path) 41