OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 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. | |
5 | |
6 """Replaces "Chrome Remote Desktop" with "Chromoting" in GRD files""" | |
7 | |
8 import sys | |
9 from optparse import OptionParser | |
10 import xml.dom.minidom as minidom | |
11 | |
12 def update_xml_node(element): | |
13 for child in element.childNodes: | |
14 if child.nodeType == minidom.Node.ELEMENT_NODE: | |
15 update_xml_node(child) | |
16 elif child.nodeType == minidom.Node.TEXT_NODE: | |
17 child.replaceWholeText( | |
18 child.data.replace("Chrome Remote Desktop", "Chromoting")) | |
19 | |
20 def remove_official_branding(input, output): | |
21 xml = minidom.parse(input) | |
22 | |
23 # Remove all translations. | |
24 for translations in xml.getElementsByTagName("translations"): | |
25 for translation in xml.getElementsByTagName("translation"): | |
26 translations.removeChild(translation) | |
27 | |
28 # Update branding. | |
29 update_xml_node(xml) | |
30 | |
31 out = file(output, "w") | |
32 out.write(xml.toxml(encoding = "UTF-8")) | |
33 out.close() | |
34 | |
35 def main(): | |
36 usage = 'Usage: remove_official_branding <input.grd> <output.grd>' | |
37 parser = OptionParser(usage=usage) | |
38 options, args = parser.parse_args() | |
39 if len(args) != 2: | |
40 parser.error('two positional arguments expected') | |
41 | |
42 return remove_official_branding(args[0], args[1]) | |
43 | |
44 if __name__ == '__main__': | |
45 sys.exit(main()) | |
46 | |
OLD | NEW |