OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 from itertools import chain | |
7 from os import path as os_path | |
6 import sys | 8 import sys |
7 import xml.sax | 9 import xml.sax |
8 | 10 |
9 | 11 |
10 class PathsExtractor(xml.sax.ContentHandler): | 12 class PathsExtractor(xml.sax.ContentHandler): |
11 | 13 |
12 def __init__(self): | 14 def __init__(self): |
13 self.paths = [] | 15 self.paths = [] |
14 | 16 |
17 # Following elements are not used anymore, but are unfortunately downloaded | |
michaelpg
2017/06/07 05:44:07
Can you clarify what your purpose is in adding thi
dpapad
2017/06/07 17:19:14
What I had in mind was that if someone runs 1,2,3
dpapad
2017/06/07 20:44:45
Resolved per offline discussion with michaelpg@, b
| |
18 # because they co-reside in the same GitHub repository with elements that | |
19 # are still used. Adding them in this blacklist will prevent such elements | |
20 # from being included in the final polymer_resources.grdp file. | |
21 blacklisted_elements = [ | |
22 'paper-material' | |
23 ] | |
24 | |
25 self.blacklist = list(chain(*map( | |
26 lambda dep: map( | |
27 lambda suffix: dep + suffix, ['.html', '-extracted.js']), | |
28 blacklisted_elements))) | |
29 | |
15 def startElement(self, name, attrs): | 30 def startElement(self, name, attrs): |
16 if name != 'structure': | 31 if name != 'structure': |
17 return | 32 return |
18 path = attrs['file'] | 33 path = attrs['file'] |
19 if path.startswith('../../../third_party/web-animations-js'): | 34 if path.startswith('../../../third_party/web-animations-js'): |
20 return | 35 return |
21 prefix_1_0 = '../../../third_party/polymer/v1_0/components-chromium/' | 36 prefix_1_0 = '../../../third_party/polymer/v1_0/components-chromium/' |
22 if path.startswith(prefix_1_0): | 37 if path.startswith(prefix_1_0): |
38 if os_path.basename(path) in self.blacklist: | |
39 return | |
23 self.paths.append(path[len(prefix_1_0):]) | 40 self.paths.append(path[len(prefix_1_0):]) |
24 else: | 41 else: |
25 raise Exception("Unexpected path %s." % path) | 42 raise Exception("Unexpected path %s." % path) |
26 | 43 |
27 def main(argv): | 44 def main(argv): |
28 xml_handler = PathsExtractor() | 45 xml_handler = PathsExtractor() |
29 xml.sax.parse(argv[1], xml_handler) | 46 xml.sax.parse(argv[1], xml_handler) |
30 print '\n'.join(sorted(xml_handler.paths)) | 47 print '\n'.join(sorted(xml_handler.paths)) |
31 | 48 |
32 | 49 |
33 if __name__ == '__main__': | 50 if __name__ == '__main__': |
34 sys.exit(main(sys.argv)) | 51 sys.exit(main(sys.argv)) |
OLD | NEW |