1 # This file is part of the LibreOffice project.
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/.
7 # This file incorporates work covered by the following license notice:
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 .
21 infile_name
= sys
.argv
[1]
22 id_out_name
= sys
.argv
[2]
23 name_out_name
= sys
.argv
[3]
28 with
open(infile_name
) as infile
:
31 # check for valid characters
32 if not re
.match(r
'[A-Z][a-zA-Z0-9]*$', line
):
33 sys
.exit("Error: invalid character in property '{}'".format(line
))
34 props
[line
] = "PROP_" + line
36 # generate output files
38 idfile
= open(id_out_name
, 'w')
39 namefile
= open(name_out_name
, 'w')
42 for token
in sorted(props
.keys()):
43 idfile
.write("const sal_Int32 {} = {};\n".format(props
[token
], i
))
44 namefile
.write("/* {} */ \"{}\",\n".format(i
, token
))
47 idfile
.write("const sal_Int32 PROP_COUNT = {};\n".format(i
))
48 idfile
.write("const sal_Int32 PROP_INVALID = -1;\n" )