Chromium Code Reviews| 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 |
| index 6aeaefb9caf2981f8047255883dabfc59664a348..7ed3e5aa890b518041770a274455d185907eaf05 100755 |
| --- a/tools/polymer/txt_to_polymer_grdp.py |
| +++ b/tools/polymer/txt_to_polymer_grdp.py |
| @@ -18,13 +18,6 @@ FILE_TEMPLATE = \ |
| 'polymer_grdp_to_txt.py' converts 'polymer_resources.grdp' to a plane list of |
| used Polymer components. v1.0 elements are marked with 'v1.0 ' prefix: |
|
dzhioev (left Google)
2015/06/26 05:52:41
Records are not prepended by 'v1.0' as far as I ca
michaelpg
2015/06/26 07:36:46
Done.
|
| ... |
| - 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 |
| - ... |
| v1.0 iron-iron-iconset/iron-iconset-extracted.js |
|
dzhioev (left Google)
2015/06/26 05:52:41
ditto
michaelpg
2015/06/26 07:36:46
Done.
|
| v1.0 iron-iron-iconset/iron-iconset.html |
| ... |
| @@ -37,9 +30,6 @@ FILE_TEMPLATE = \ |
| $ txt_to_polymer_grdp.py /tmp/list.txt > polymer_resources.grdp |
| --> |
| <grit-part> |
| - <!-- Polymer 0.5 (TODO: Remove by M45 branch point) --> |
| -%(v_0_5)s |
| - |
| <!-- Polymer 1.0 --> |
| %(v_1_0)s |
| <structure name="IDR_POLYMER_1_0_WEB_ANIMATIONS_JS_WEB_ANIMATIONS_NEXT_LITE_MIN_JS" |
| @@ -49,43 +39,32 @@ FILE_TEMPLATE = \ |
| """ |
| -DEFINITION_TEMPLATE_0_5 = \ |
| -""" <structure name="%s" |
| - file="../../../third_party/polymer/components-chromium/%s" |
| - type="chrome_html" />""" |
| - |
| DEFINITION_TEMPLATE_1_0 = \ |
| """ <structure name="%s" |
| file="../../../third_party/polymer/v1_0/components-chromium/%s" |
| type="chrome_html" />""" |
| -def PathToGritId(path, is_1_0): |
| +def PathToGritId(path): |
| table = string.maketrans(string.lowercase + '/.-', string.uppercase + '___') |
| - return 'IDR_POLYMER_' + ('1_0_' if is_1_0 else '') + path.translate(table) |
| + return 'IDR_POLYMER_1_0_' + path.translate(table) |
| def SortKey(record): |
| - return (record[1], PathToGritId(record[0], record[1])) |
| + return (record, PathToGritId(record)) |
| def ParseRecord(record): |
| - record = record.strip() |
| - v_1_0_prefix = 'v1.0 ' |
| - if record.startswith(v_1_0_prefix): |
| - return (record[len(v_1_0_prefix):], True) |
| - else: |
| - return (record, False) |
| + return record.strip() |
| def main(argv): |
| with open(argv[1]) as f: |
| records = [ParseRecord(r) for r in f if not r.isspace()] |
| - lines = { 'v_0_5': [], 'v_1_0': [] } |
| - for (path, is_1_0) in sorted(set(records), key=SortKey): |
| - template = DEFINITION_TEMPLATE_1_0 if is_1_0 else DEFINITION_TEMPLATE_0_5 |
| - lines['v_1_0' if is_1_0 else 'v_0_5'].append( |
| - template % (PathToGritId(path, is_1_0), path)) |
| - print FILE_TEMPLATE % { 'v_0_5': '\n'.join(lines['v_0_5']), |
| - 'v_1_0': '\n'.join(lines['v_1_0']) } |
| + lines = { 'v_1_0': [] } |
| + for path in sorted(set(records), key=SortKey): |
| + template = DEFINITION_TEMPLATE_1_0 |
| + lines['v_1_0'].append( |
| + template % (PathToGritId(path), path)) |
| + print FILE_TEMPLATE % { 'v_1_0': '\n'.join(lines['v_1_0']) } |
| if __name__ == '__main__': |
| sys.exit(main(sys.argv)) |