Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Unified Diff: tools/polymer/txt_to_polymer_grdp.py

Issue 984553002: Added helper scripts for modifying polymer_resources.grdp. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: newline Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..150d040231279074c75c05f1de780e69649bfbfd
--- /dev/null
+++ b/tools/polymer/txt_to_polymer_grdp.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# Copyright (c) 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.
+
+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)
+
Dan Beam 2015/03/16 19:28:10 if __name__ == '__main__':
dzhioev (left Google) 2015/03/17 12:43:18 Done.
+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.
+lines = []
+for path in sorted(paths, key=PathToGritId):
+ lines.append(DEFINITION_TEMPLATE % (PathToGritId(path), path))
+print FILE_TEMPLATE % '\n'.join(lines)

Powered by Google App Engine
This is Rietveld 408576698