LibreOffice Module oox (master) 1
properties.py
Go to the documentation of this file.
1# This file is part of the LibreOffice project.
2#
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6#
7# This file incorporates work covered by the following license notice:
8#
9# Licensed to the Apache Software Foundation (ASF) under one or more
10# contributor license agreements. See the NOTICE file distributed
11# with this work for additional information regarding copyright
12# ownership. The ASF licenses this file to you under the Apache
13# License, Version 2.0 (the "License"); you may not use this file
14# except in compliance with the License. You may obtain a copy of
15# the License at http://www.apache.org/licenses/LICENSE-2.0 .
16#
17
18import sys, re
19
20infile_name = sys.argv[1]
21id_out_name = sys.argv[2]
22name_out_name = sys.argv[3]
23
24# parse input file
25
26props = {}
27with open(infile_name) as infile:
28 for line in infile:
29 line = line.strip()
30 # check for valid characters
31 if not re.match(r'[A-Z][a-zA-Z0-9]*$', line):
32 sys.exit("Error: invalid character in property '{}'".format(line))
33 props[line] = "PROP_" + line
34
35# generate output files
36
37idfile = open(id_out_name, 'w')
38namefile = open(name_out_name, 'w')
39
40i = 0;
41for token in sorted(props.keys()):
42 idfile.write("const sal_Int32 {} = {};\n".format(props[token], i))
43 namefile.write("/* {} */ \"{}\",\n".format(i, token))
44 i += 1
45
46idfile.write("const sal_Int32 PROP_COUNT = {};\n".format(i))
47idfile.write("const sal_Int32 PROP_INVALID = -1;\n" )
48
49idfile.close()
50namefile.close()