1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/locale/src/props2arrays.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,39 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +import sys 1.9 + 1.10 +mappings = {} 1.11 + 1.12 +propFile = open(sys.argv[1], "r"); 1.13 + 1.14 +for line in propFile: 1.15 + line = line.strip() 1.16 + if not line.startswith('#'): 1.17 + parts = line.split("=", 1) 1.18 + if len(parts) == 2 and len(parts[0]) > 0: 1.19 + mappings[parts[0].strip()] = parts[1].strip() 1.20 + 1.21 +propFile.close() 1.22 + 1.23 +keys = mappings.keys() 1.24 +keys.sort() 1.25 + 1.26 +hFile = open(sys.argv[2], "w"); 1.27 + 1.28 +hFile.write("// This is a generated file. Please do not edit.\n") 1.29 +hFile.write("// Please edit the corresponding .properties file instead.\n") 1.30 + 1.31 +first = 1 1.32 +for key in keys: 1.33 + if first: 1.34 + first = 0 1.35 + else: 1.36 + hFile.write(',\n') 1.37 + hFile.write('{ "%s", "%s", (const char*)NS_INT32_TO_PTR(%d) }' 1.38 + % (key, mappings[key], len(mappings[key]))); 1.39 +hFile.write('\n') 1.40 +hFile.flush() 1.41 +hFile.close() 1.42 +