From a7d1e2b29844f95dd7848cd37ce927196aedcac6 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 5 Jun 2013 23:21:54 +0300 Subject: [PATCH] OP-910: fix line endings and whitespaces (didn't work on Linux) --- ground/.gitattributes | 9 +- .../src/plugins/coreplugin/authorsdialog.py | 104 +++++++++--------- 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/ground/.gitattributes b/ground/.gitattributes index 0417f63e1..42263f54b 100644 --- a/ground/.gitattributes +++ b/ground/.gitattributes @@ -3,6 +3,9 @@ # http://wiki.openpilot.org/display/Doc/Coding+Style # +*.pri text eol=crlf +*.pro text eol=crlf + *.c text eol=crlf *.cpp text eol=crlf *.h text eol=crlf @@ -13,9 +16,9 @@ *.qml text eol=crlf *.pluginspec text eol=crlf -*.pri text eol=crlf -*.pro text eol=crlf - *.h.template text eol=crlf *.c.template text eol=crlf *.cpp.template text eol=crlf +*.qml.template text eol=crlf + +*.py text eol=lf diff --git a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.py b/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.py index 1f4910e6a..27cc98290 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.py +++ b/ground/openpilotgcs/src/plugins/coreplugin/authorsdialog.py @@ -1,52 +1,52 @@ -#!/usr/bin/env python -# -# Helper function to generate a QML list of contributors -# -# (c) 2013, The OpenPilot Team, http://www.openpilot.org -# See also: The GNU Public License (GPL) Version 3 -# - -import optparse -import sys - -def create_qml_file(args): - """This function reads input and template files and writes output QML file""" - - assert args.infile is not None - assert args.outfile is not None - assert args.template is not None - - with open(args.infile, "rt") as input_file: - names = input_file.readlines() - - names_list = "" - for name in names: - if name.strip(): - names_list += " ListElement { name: \"" + name.strip() + "\" }\n" - - with open(args.template, "rt") as template_file, open(args.outfile, "wt") as output_file: - template = template_file.read() - output_file.write(template.replace("${LIST_ELEMENTS}\n", names_list)) - - return 0 - -def main(): - """Helper function to generate a QML list of contributors""" - - parser = optparse.OptionParser(description = main.__doc__); - - parser.add_option('--infile', action='store', - help='name of input file, one name per line'); - parser.add_option('--outfile', action='store', - help='name of output QML file'); - parser.add_option('--template', action='store', - help='name of QML template file'); - (args, positional_args) = parser.parse_args() - - if (len(positional_args) != 0) or (len(sys.argv) == 1): - parser.error("incorrect number of arguments, try --help for help") - - return create_qml_file(args) - -if __name__ == "__main__": - sys.exit(main()) +#!/usr/bin/env python +# +# Helper function to generate a QML list of contributors +# +# (c) 2013, The OpenPilot Team, http://www.openpilot.org +# See also: The GNU Public License (GPL) Version 3 +# + +import optparse +import sys + +def create_qml_file(args): + """This function reads input and template files and writes output QML file""" + + assert args.infile is not None + assert args.outfile is not None + assert args.template is not None + + with open(args.infile, "rt") as input_file: + names = input_file.readlines() + + names_list = "" + for name in names: + if name.strip(): + names_list += " ListElement { name: \"" + name.strip() + "\" }\n" + + with open(args.template, "rt") as template_file, open(args.outfile, "wt") as output_file: + template = template_file.read() + output_file.write(template.replace("${LIST_ELEMENTS}", names_list.rstrip())) + + return 0 + +def main(): + """Helper function to generate a QML list of contributors""" + + parser = optparse.OptionParser(description = main.__doc__); + + parser.add_option('--infile', action='store', + help='name of input file, one name per line'); + parser.add_option('--outfile', action='store', + help='name of output QML file'); + parser.add_option('--template', action='store', + help='name of QML template file'); + (args, positional_args) = parser.parse_args() + + if (len(positional_args) != 0) or (len(sys.argv) == 1): + parser.error("incorrect number of arguments, try --help for help") + + return create_qml_file(args) + +if __name__ == "__main__": + sys.exit(main())