michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: import sys michael@0: michael@0: mappings = {} michael@0: michael@0: propFile = open(sys.argv[1], "r"); michael@0: michael@0: for line in propFile: michael@0: line = line.strip() michael@0: if not line.startswith('#'): michael@0: parts = line.split("=", 1) michael@0: if len(parts) == 2 and len(parts[0]) > 0: michael@0: mappings[parts[0].strip()] = parts[1].strip() michael@0: michael@0: propFile.close() michael@0: michael@0: keys = mappings.keys() michael@0: keys.sort() michael@0: michael@0: hFile = open(sys.argv[2], "w"); michael@0: michael@0: hFile.write("// This is a generated file. Please do not edit.\n") michael@0: hFile.write("// Please edit the corresponding .properties file instead.\n") michael@0: michael@0: first = 1 michael@0: for key in keys: michael@0: if first: michael@0: first = 0 michael@0: else: michael@0: hFile.write(',\n') michael@0: hFile.write('{ "%s", "%s", (const char*)NS_INT32_TO_PTR(%d) }' michael@0: % (key, mappings[key], len(mappings[key]))); michael@0: hFile.write('\n') michael@0: hFile.flush() michael@0: hFile.close() michael@0: