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.

     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/.
     5 import sys
     7 mappings = {}
     9 propFile = open(sys.argv[1], "r");
    11 for line in propFile:
    12   line = line.strip()
    13   if not line.startswith('#'):
    14     parts = line.split("=", 1)
    15     if len(parts) == 2 and len(parts[0]) > 0:
    16       mappings[parts[0].strip()] = parts[1].strip()
    18 propFile.close()
    20 keys = mappings.keys()
    21 keys.sort()
    23 hFile = open(sys.argv[2], "w");
    25 hFile.write("// This is a generated file. Please do not edit.\n")
    26 hFile.write("// Please edit the corresponding .properties file instead.\n")
    28 first = 1
    29 for key in keys:
    30   if first:
    31     first = 0
    32   else:
    33     hFile.write(',\n')
    34   hFile.write('{ "%s", "%s", (const char*)NS_INT32_TO_PTR(%d) }' 
    35               % (key, mappings[key], len(mappings[key])));
    36 hFile.write('\n')
    37 hFile.flush()
    38 hFile.close()

mercurial