From 25682cdfe998a21ddc8bde0d848a40525005f524 Mon Sep 17 00:00:00 2001 From: Michael Schwarz Date: Mon, 8 Sep 2014 21:03:02 +0200 Subject: [PATCH] setup.py: Added function to print fatal errors. --- setup.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index a95fafc3..04b2f2ac 100755 --- a/setup.py +++ b/setup.py @@ -1148,13 +1148,13 @@ class ArgParser(): optqueue.append(arg_opt) argqueue.append(arg[arg.index('=') + 1:]) else: - sys.stderr.write('%s: fatal: unrecognised option %s. see --help or the manual\n' % (self.__program, arg)) + self.print_fatal('Unrecognized option {}. Use the help command or consult the manual.', arg) exit(-1) elif (arg in self.optmap) and (self.optmap[arg][1] == ARGUMENTED): optqueue.append(arg) get = True else: - sys.stderr.write('%s: fatal: unrecognised option %s. see --help or the manual\n' % (self.__program, arg)) + self.print_fatal('Unrecognized option {}. Use the help command or consult the manual.', arg) exit(-1) else: self.files.append(arg) @@ -1168,9 +1168,12 @@ class ArgParser(): if (opt not in self.opts) or (self.opts[opt] is None): self.opts[opt] = [arg] else: - sys.stderr.write('%s: fatal: duplicate option %s\n' % (self.__program, arg)) + self.print_fatal('duplicate option {}', arg) exit(-1) + def print_fatal(self, message, *args): + sys.stderr.write('{}: fatal: {}\n'.format(self.__program, message.format(*args))) + def usage(self): ''' Print a short usage message.