OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2015 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 string | |
7 import sys | |
8 | |
9 FILE_TEMPLATE = \ | |
10 """<?xml version="1.0" encoding="utf-8"?> | |
11 <!-- | |
12 This file is generated. | |
13 Please use 'src/tools/polymer/polymer_grdp_to_txt.py' and | |
14 'src/tools/polymer/txt_to_polymer_grdp.py' to modify it, if possible. | |
15 | |
16 'polymer_grdp_to_txt.py' converts 'polymer_resources.grdp' to a plane list of | |
17 used Polymer components: | |
18 ... | |
19 core-animation/core-animation.html | |
20 core-animation/web-animations.html | |
21 core-collapse/core-collapse-extracted.js | |
22 core-collapse/core-collapse.css | |
23 core-collapse/core-collapse.html | |
24 core-dropdown/core-dropdown-base-extracted.js | |
25 ... | |
26 | |
27 'txt_to_polymer_grdp.py' converts list back to GRDP file. | |
28 | |
29 Usage: | |
30 $ polymer_grdp_to_txt.py polymer_resources.grdp > /tmp/list.txt | |
31 $ vim /tmp/list.txt | |
32 $ txt_to_polymer_grdp.py /tmp/list.txt > polymer_resources.grdp | |
33 --> | |
34 <grit-part> | |
35 %s | |
36 <structure name="IDR_POLYMER_WEB_ANIMATIONS_JS_WEB_ANIMATIONS_NEXT_LITE_MIN_JS " | |
37 file="../../../third_party/web-animations-js/sources/web-animations -next-lite.min.js" | |
38 type="chrome_html" /> | |
39 <structure name="IDR_POLYMER_WEB_ANIMATIONS_JS_WEB_ANIMATIONS_NEXT_LITE_MIN_JS _MAP" | |
40 file="../../../third_party/web-animations-js/sources/web-animations -next-lite.min.js.map" | |
41 type="chrome_html" /> | |
42 </grit-part> | |
43 """ | |
44 | |
45 DEFINITION_TEMPLATE = \ | |
46 """ <structure name="%s" | |
47 file="../../../third_party/polymer/components-chromium/%s" | |
48 type="chrome_html" />""" | |
49 | |
50 def PathToGritId(path): | |
51 table = string.maketrans(string.lowercase + '/.-', string.uppercase + '___') | |
52 return 'IDR_POLYMER_' + path.translate(table) | |
53 | |
Dan Beam
2015/03/16 19:28:10
if __name__ == '__main__':
dzhioev (left Google)
2015/03/17 12:43:18
Done.
| |
54 paths = [p.strip() for p in open(sys.argv[1]) if p.strip()] | |
Dan Beam
2015/03/16 19:28:10
what closes this file?
dzhioev (left Google)
2015/03/17 12:43:18
Fixed.
| |
55 lines = [] | |
56 for path in sorted(paths, key=PathToGritId): | |
57 lines.append(DEFINITION_TEMPLATE % (PathToGritId(path), path)) | |
58 print FILE_TEMPLATE % '\n'.join(lines) | |
OLD | NEW |