| Index: tools/polymer/txt_to_polymer_grdp.py
|
| diff --git a/tools/polymer/txt_to_polymer_grdp.py b/tools/polymer/txt_to_polymer_grdp.py
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..c8ee510c75865bcae2283df88fc6b1ce79c3e12e
|
| --- /dev/null
|
| +++ b/tools/polymer/txt_to_polymer_grdp.py
|
| @@ -0,0 +1,69 @@
|
| +#!/usr/bin/env python
|
| +# Copyright 2015 The Chromium Authors. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +from __future__ import with_statement
|
| +import string
|
| +import sys
|
| +
|
| +
|
| +FILE_TEMPLATE = \
|
| +"""<?xml version="1.0" encoding="utf-8"?>
|
| +<!--
|
| + This file is generated.
|
| + Please use 'src/tools/polymer/polymer_grdp_to_txt.py' and
|
| + 'src/tools/polymer/txt_to_polymer_grdp.py' to modify it, if possible.
|
| +
|
| + 'polymer_grdp_to_txt.py' converts 'polymer_resources.grdp' to a plane list of
|
| + used Polymer components:
|
| + ...
|
| + core-animation/core-animation.html
|
| + core-animation/web-animations.html
|
| + core-collapse/core-collapse-extracted.js
|
| + core-collapse/core-collapse.css
|
| + core-collapse/core-collapse.html
|
| + core-dropdown/core-dropdown-base-extracted.js
|
| + ...
|
| +
|
| + 'txt_to_polymer_grdp.py' converts list back to GRDP file.
|
| +
|
| + Usage:
|
| + $ polymer_grdp_to_txt.py polymer_resources.grdp > /tmp/list.txt
|
| + $ vim /tmp/list.txt
|
| + $ txt_to_polymer_grdp.py /tmp/list.txt > polymer_resources.grdp
|
| +-->
|
| +<grit-part>
|
| +%s
|
| + <structure name="IDR_POLYMER_WEB_ANIMATIONS_JS_WEB_ANIMATIONS_NEXT_LITE_MIN_JS"
|
| + file="../../../third_party/web-animations-js/sources/web-animations-next-lite.min.js"
|
| + type="chrome_html" />
|
| + <structure name="IDR_POLYMER_WEB_ANIMATIONS_JS_WEB_ANIMATIONS_NEXT_LITE_MIN_JS_MAP"
|
| + file="../../../third_party/web-animations-js/sources/web-animations-next-lite.min.js.map"
|
| + type="chrome_html" />
|
| +</grit-part>
|
| +"""
|
| +
|
| +
|
| +DEFINITION_TEMPLATE = \
|
| +""" <structure name="%s"
|
| + file="../../../third_party/polymer/components-chromium/%s"
|
| + type="chrome_html" />"""
|
| +
|
| +
|
| +def PathToGritId(path):
|
| + table = string.maketrans(string.lowercase + '/.-', string.uppercase + '___')
|
| + return 'IDR_POLYMER_' + path.translate(table)
|
| +
|
| +
|
| +def main(argv):
|
| + with open(argv[1]) as f:
|
| + paths = [p.strip() for p in f if not p.isspace()]
|
| + lines = []
|
| + for path in sorted(paths, key=PathToGritId):
|
| + lines.append(DEFINITION_TEMPLATE % (PathToGritId(path), path))
|
| + print FILE_TEMPLATE % '\n'.join(lines)
|
| +
|
| +
|
| +if __name__ == '__main__':
|
| + sys.exit(main(sys.argv))
|
|
|