1# This Source Code Form is subject to the terms of the Mozilla Public 2# License, v. 2.0. If a copy of the MPL was not distributed with this 3# file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 6def main(header, propFile): 7 mappings = {} 8 9 with open(propFile, "r") as f: 10 for line in f: 11 line = line.strip() 12 if not line.startswith("#"): 13 parts = line.split("=", 1) 14 if len(parts) == 2 and len(parts[0]) > 0: 15 mappings[parts[0].strip()] = parts[1].strip() 16 17 keys = mappings.keys() 18 19 header.write("// This is a generated file. Please do not edit.\n") 20 header.write("// Please edit the corresponding .properties file instead.\n") 21 22 entries = [ 23 '{ "%s", "%s", %d }' % (key, mappings[key], len(mappings[key])) 24 for key in sorted(keys) 25 ] 26 header.write(",\n".join(entries) + "\n") 27