mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-26 15:54:15 +01:00
OP-910: fix line endings and whitespaces (didn't work on Linux)
This commit is contained in:
parent
6756f52044
commit
a7d1e2b298
9
ground/.gitattributes
vendored
9
ground/.gitattributes
vendored
@ -3,6 +3,9 @@
|
|||||||
# http://wiki.openpilot.org/display/Doc/Coding+Style
|
# http://wiki.openpilot.org/display/Doc/Coding+Style
|
||||||
#
|
#
|
||||||
|
|
||||||
|
*.pri text eol=crlf
|
||||||
|
*.pro text eol=crlf
|
||||||
|
|
||||||
*.c text eol=crlf
|
*.c text eol=crlf
|
||||||
*.cpp text eol=crlf
|
*.cpp text eol=crlf
|
||||||
*.h text eol=crlf
|
*.h text eol=crlf
|
||||||
@ -13,9 +16,9 @@
|
|||||||
*.qml text eol=crlf
|
*.qml text eol=crlf
|
||||||
*.pluginspec text eol=crlf
|
*.pluginspec text eol=crlf
|
||||||
|
|
||||||
*.pri text eol=crlf
|
|
||||||
*.pro text eol=crlf
|
|
||||||
|
|
||||||
*.h.template text eol=crlf
|
*.h.template text eol=crlf
|
||||||
*.c.template text eol=crlf
|
*.c.template text eol=crlf
|
||||||
*.cpp.template text eol=crlf
|
*.cpp.template text eol=crlf
|
||||||
|
*.qml.template text eol=crlf
|
||||||
|
|
||||||
|
*.py text eol=lf
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#
|
#
|
||||||
# Helper function to generate a QML list of contributors
|
# Helper function to generate a QML list of contributors
|
||||||
#
|
#
|
||||||
# (c) 2013, The OpenPilot Team, http://www.openpilot.org
|
# (c) 2013, The OpenPilot Team, http://www.openpilot.org
|
||||||
# See also: The GNU Public License (GPL) Version 3
|
# See also: The GNU Public License (GPL) Version 3
|
||||||
#
|
#
|
||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def create_qml_file(args):
|
def create_qml_file(args):
|
||||||
"""This function reads input and template files and writes output QML file"""
|
"""This function reads input and template files and writes output QML file"""
|
||||||
|
|
||||||
assert args.infile is not None
|
assert args.infile is not None
|
||||||
assert args.outfile is not None
|
assert args.outfile is not None
|
||||||
assert args.template is not None
|
assert args.template is not None
|
||||||
|
|
||||||
with open(args.infile, "rt") as input_file:
|
with open(args.infile, "rt") as input_file:
|
||||||
names = input_file.readlines()
|
names = input_file.readlines()
|
||||||
|
|
||||||
names_list = ""
|
names_list = ""
|
||||||
for name in names:
|
for name in names:
|
||||||
if name.strip():
|
if name.strip():
|
||||||
names_list += " ListElement { name: \"" + name.strip() + "\" }\n"
|
names_list += " ListElement { name: \"" + name.strip() + "\" }\n"
|
||||||
|
|
||||||
with open(args.template, "rt") as template_file, open(args.outfile, "wt") as output_file:
|
with open(args.template, "rt") as template_file, open(args.outfile, "wt") as output_file:
|
||||||
template = template_file.read()
|
template = template_file.read()
|
||||||
output_file.write(template.replace("${LIST_ELEMENTS}\n", names_list))
|
output_file.write(template.replace("${LIST_ELEMENTS}", names_list.rstrip()))
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Helper function to generate a QML list of contributors"""
|
"""Helper function to generate a QML list of contributors"""
|
||||||
|
|
||||||
parser = optparse.OptionParser(description = main.__doc__);
|
parser = optparse.OptionParser(description = main.__doc__);
|
||||||
|
|
||||||
parser.add_option('--infile', action='store',
|
parser.add_option('--infile', action='store',
|
||||||
help='name of input file, one name per line');
|
help='name of input file, one name per line');
|
||||||
parser.add_option('--outfile', action='store',
|
parser.add_option('--outfile', action='store',
|
||||||
help='name of output QML file');
|
help='name of output QML file');
|
||||||
parser.add_option('--template', action='store',
|
parser.add_option('--template', action='store',
|
||||||
help='name of QML template file');
|
help='name of QML template file');
|
||||||
(args, positional_args) = parser.parse_args()
|
(args, positional_args) = parser.parse_args()
|
||||||
|
|
||||||
if (len(positional_args) != 0) or (len(sys.argv) == 1):
|
if (len(positional_args) != 0) or (len(sys.argv) == 1):
|
||||||
parser.error("incorrect number of arguments, try --help for help")
|
parser.error("incorrect number of arguments, try --help for help")
|
||||||
|
|
||||||
return create_qml_file(args)
|
return create_qml_file(args)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user