OLD | NEW |
1 #!/usr/bin/python2 | 1 #!/usr/bin/python2 |
2 | 2 |
3 # Copyright 2016 The Chromium Authors. All rights reserved. | 3 # Copyright 2016 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Identifies Polymer elements that downloaded but not used by Chrome. | 7 """Identifies Polymer elements that downloaded but not used by Chrome. |
8 | 8 |
9 Only finds "first-order" unused elements; re-run after removing unused elements | 9 Only finds "first-order" unused elements; re-run after removing unused elements |
10 to check if other elements have become unused. | 10 to check if other elements have become unused. |
11 """ | 11 """ |
12 | 12 |
13 import os | 13 import os |
14 import re | 14 import re |
15 import subprocess | 15 import subprocess |
16 | 16 |
17 | 17 |
18 class UnusedElementsDetector(object): | 18 class UnusedElementsDetector(object): |
19 """Finds unused Polymer elements.""" | 19 """Finds unused Polymer elements.""" |
20 | 20 |
21 # Unused elements to ignore because we plan to use them soon. | 21 # Unused elements to ignore because we plan to use them soon. |
22 __WHITELIST = ( | 22 __WHITELIST = ( |
23 # TODO(dschuyler): Use element or remove from whitelist. | |
24 'app-route', | |
25 # Necessary for closure. | 23 # Necessary for closure. |
26 'polymer-externs', | 24 'polymer-externs', |
27 ) | 25 ) |
28 | 26 |
29 def __init__(self): | 27 def __init__(self): |
30 polymer_dir = os.path.dirname(os.path.realpath(__file__)) | 28 polymer_dir = os.path.dirname(os.path.realpath(__file__)) |
31 self.__COMPONENTS_DIR = os.path.join(polymer_dir, 'components-chromium') | 29 self.__COMPONENTS_DIR = os.path.join(polymer_dir, 'components-chromium') |
32 | 30 |
33 @staticmethod | 31 @staticmethod |
34 def __StripHtmlComments(filename): | 32 def __StripHtmlComments(filename): |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 # scripts). | 148 # scripts). |
151 if re.search('/%s' % element_dir, | 149 if re.search('/%s' % element_dir, |
152 self.__StripComments( | 150 self.__StripComments( |
153 os.path.join(dirpath, filename))): | 151 os.path.join(dirpath, filename))): |
154 return True | 152 return True |
155 return False | 153 return False |
156 | 154 |
157 | 155 |
158 if __name__ == '__main__': | 156 if __name__ == '__main__': |
159 UnusedElementsDetector().Run() | 157 UnusedElementsDetector().Run() |
OLD | NEW |