1 #!/usr/bin/env python 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 4 # found in the LICENSE file. 5 6 import argparse 7 import json 8 import os 9 import string 10 import sys 11 12 sys.path.insert( 13 1, 14 os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')) 15 from tracing.metrics import discover 16 import tracing_project 17 18 19 def Main(): 20 all_registered_metrics = set(discover.DiscoverMetrics( 21 ['/tracing/metrics/all_metrics.html'])) 22 all_modules = list( 23 '/' + rel_path for rel_path in 24 tracing_project.TracingProject().FindAllMetricsModuleRelPaths()) 25 all_possible_metrics = set(discover.DiscoverMetrics(all_modules)) 26 unregistered_metrics = all_possible_metrics - all_registered_metrics 27 if unregistered_metrics: 28 print ('These metrics are unregistered: %s. Please import their modules in ' 29 'tracing/tracing/metrics/all_metrics.html' % 30 ', '.join(unregistered_metrics)) 31 return 1 32 uppercased_metrics = [] 33 for m in all_possible_metrics: 34 if str.isupper(m[0]): 35 uppercased_metrics.append(m) 36 if uppercased_metrics: 37 print ('These metrics must be renamed to start with a lower-case: %s' % 38 uppercased_metrics) 39 return 1 40 return 0 41 42 if __name__ == '__main__': 43 sys.exit(Main()) 44