Chromium Code Reviews| Index: tools/polymer/polymer_grdp_to_txt.py |
| diff --git a/tools/polymer/polymer_grdp_to_txt.py b/tools/polymer/polymer_grdp_to_txt.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..f9c8735720cc981b8713e8dd2a7dc3402919362d |
| --- /dev/null |
| +++ b/tools/polymer/polymer_grdp_to_txt.py |
| @@ -0,0 +1,34 @@ |
| +#!/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. |
| + |
| +import sys |
| +import xml.sax |
| + |
| + |
| +class PathsExtractor(xml.sax.ContentHandler): |
| + |
| + def __init__(self): |
| + self.paths = [] |
| + |
| + def startElement(self, name, attrs): |
| + if name != 'structure': |
| + return |
| + path = attrs['file'] |
| + if path.startswith('../../../third_party/web-animations-js'): |
| + return |
| + prefix = '../../../third_party/polymer/components-chromium/' |
| + if not path.startswith(prefix): |
| + raise Exception("Unexpected path %s." % path) |
| + self.paths.append(path[len(prefix):]) |
| + |
| + |
| +def main(argv): |
| + xml_handler = PathsExtractor() |
| + xml.sax.parse(sys.argv[1], xml_handler) |
|
dzhioev (left Google)
2015/03/17 18:26:46
Should be just "argv[1]". Fixed in the next patchs
|
| + print '\n'.join(sorted(xml_handler.paths)) |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main(sys.argv)) |
|
Dan Beam
2015/03/17 16:37:53
I don't think this is the way you're supposed to u
dzhioev (left Google)
2015/03/17 18:26:46
I don't see what is wrong.
main() can optionally r
Dan Beam
2015/03/17 18:37:53
i guess None is 0-ish, yeah, but there's nothing t
dzhioev (left Google)
2015/03/18 16:38:05
Probably such construction is idiomatic in Python.
|