|
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 import sys |
|
6 |
|
7 mappings = {} |
|
8 |
|
9 propFile = open(sys.argv[1], "r"); |
|
10 |
|
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() |
|
17 |
|
18 propFile.close() |
|
19 |
|
20 keys = mappings.keys() |
|
21 keys.sort() |
|
22 |
|
23 hFile = open(sys.argv[2], "w"); |
|
24 |
|
25 hFile.write("// This is a generated file. Please do not edit.\n") |
|
26 hFile.write("// Please edit the corresponding .properties file instead.\n") |
|
27 |
|
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() |
|
39 |