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