intl/locale/src/props2arrays.py

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 4
michael@0 5 import sys
michael@0 6
michael@0 7 mappings = {}
michael@0 8
michael@0 9 propFile = open(sys.argv[1], "r");
michael@0 10
michael@0 11 for line in propFile:
michael@0 12 line = line.strip()
michael@0 13 if not line.startswith('#'):
michael@0 14 parts = line.split("=", 1)
michael@0 15 if len(parts) == 2 and len(parts[0]) > 0:
michael@0 16 mappings[parts[0].strip()] = parts[1].strip()
michael@0 17
michael@0 18 propFile.close()
michael@0 19
michael@0 20 keys = mappings.keys()
michael@0 21 keys.sort()
michael@0 22
michael@0 23 hFile = open(sys.argv[2], "w");
michael@0 24
michael@0 25 hFile.write("// This is a generated file. Please do not edit.\n")
michael@0 26 hFile.write("// Please edit the corresponding .properties file instead.\n")
michael@0 27
michael@0 28 first = 1
michael@0 29 for key in keys:
michael@0 30 if first:
michael@0 31 first = 0
michael@0 32 else:
michael@0 33 hFile.write(',\n')
michael@0 34 hFile.write('{ "%s", "%s", (const char*)NS_INT32_TO_PTR(%d) }'
michael@0 35 % (key, mappings[key], len(mappings[key])));
michael@0 36 hFile.write('\n')
michael@0 37 hFile.flush()
michael@0 38 hFile.close()
michael@0 39

mercurial