3 # Helper function to generate a QML list of contributors
5 # (c) 2013, The OpenPilot Team, http://www.openpilot.org
6 # See also: The GNU Public License (GPL) Version 3
12 def create_qml_file(args
):
13 """This function reads input and template files and writes output QML file"""
15 assert args
.infile
is not None
16 assert args
.outfile
is not None
17 assert args
.template
is not None
19 with
open(args
.infile
, "rt") as input_file
:
20 names
= input_file
.readlines()
25 names_list
+= " ListElement { name: \"" + name
.strip() + "\" }\r\n"
27 with
open(args
.template
, "rb") as template_file
:
28 template
= template_file
.read()
30 with
open(args
.outfile
, "wb") as output_file
:
31 output_file
.write(template
.replace("${LIST_ELEMENTS}", names_list
.rstrip()))
36 """Helper function to generate a QML list of contributors"""
38 parser
= optparse
.OptionParser(description
= main
.__doc
__);
40 parser
.add_option('--infile', action
='store',
41 help='name of input file, one name per line');
42 parser
.add_option('--outfile', action
='store',
43 help='name of output QML file');
44 parser
.add_option('--template', action
='store',
45 help='name of QML template file');
46 (args
, positional_args
) = parser
.parse_args()
48 if (len(positional_args
) != 0) or (len(sys
.argv
) == 1):
49 parser
.error("incorrect number of arguments, try --help for help")
51 return create_qml_file(args
)
53 if __name__
== "__main__":