setup.py: Added function to print fatal errors.

This commit is contained in:
Michael Schwarz 2014-09-08 21:03:02 +02:00
parent 8cc55723de
commit 25682cdfe9

View file

@ -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.