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
4 # found in the LICENSE file.
6 from __future__
import with_statement
12 """<?xml version="1.0" encoding="utf-8"?>
14 This file is generated.
15 Please use 'src/tools/polymer/polymer_grdp_to_txt.py' and
16 'src/tools/polymer/txt_to_polymer_grdp.py' to modify it, if possible.
18 'polymer_grdp_to_txt.py' converts 'polymer_resources.grdp' to a plane list of
19 used Polymer components:
21 iron-iron-iconset/iron-iconset-extracted.js
22 iron-iron-iconset/iron-iconset.html
25 'txt_to_polymer_grdp.py' converts list back to GRDP file.
28 $ polymer_grdp_to_txt.py polymer_resources.grdp > /tmp/list.txt
30 $ txt_to_polymer_grdp.py /tmp/list.txt > polymer_resources.grdp
35 <structure name="IDR_POLYMER_1_0_WEB_ANIMATIONS_JS_WEB_ANIMATIONS_NEXT_LITE_MIN_JS"
36 file="../../../third_party/web-animations-js/sources/web-animations-next-lite.min.js"
42 DEFINITION_TEMPLATE_1_0
= \
43 """ <structure name="%s"
44 file="../../../third_party/polymer/v1_0/components-chromium/%s"
45 type="chrome_html" />"""
48 def PathToGritId(path
):
49 table
= string
.maketrans(string
.lowercase
+ '/.-', string
.uppercase
+ '___')
50 return 'IDR_POLYMER_1_0_' + path
.translate(table
)
53 return (record
, PathToGritId(record
))
56 def ParseRecord(record
):
60 with
open(argv
[1]) as f
:
61 records
= [ParseRecord(r
) for r
in f
if not r
.isspace()]
62 lines
= { 'v_1_0': [] }
63 for path
in sorted(set(records
), key
=SortKey
):
64 template
= DEFINITION_TEMPLATE_1_0
65 lines
['v_1_0'].append(
66 template
% (PathToGritId(path
), path
))
67 print FILE_TEMPLATE
% { 'v_1_0': '\n'.join(lines
['v_1_0']) }
69 if __name__
== '__main__':
70 sys
.exit(main(sys
.argv
))