comparison python/utils.py @ 181:42142c5223ce

minor error management addition
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Wed, 23 Nov 2011 15:57:42 -0500
parents f03fe3d6d0c8
children c06379f25ab8
comparison
equal deleted inserted replaced
180:3a4eef37384f 181:42142c5223ce
29 from numpy.core.fromnumeric import all 29 from numpy.core.fromnumeric import all
30 optionValues, args = getopt.getopt(cliArgs[1:], 'h', ['help']+options+optionalOptions) 30 optionValues, args = getopt.getopt(cliArgs[1:], 'h', ['help']+options+optionalOptions)
31 optionValues = dict(optionValues) 31 optionValues = dict(optionValues)
32 32
33 if '--help' in optionValues.keys() or '-h' in optionValues.keys(): 33 if '--help' in optionValues.keys() or '-h' in optionValues.keys():
34 print(helpMessage) 34 print(helpMessage+
35 '\n - Compulsory options: '+' '.join([opt.replace('=','') for opt in options])+
36 '\n - Non-compulsory options: '+' '.join([opt.replace('=','') for opt in optionalOptions]))
35 sys.exit() 37 sys.exit()
36 38
37 missingArgument = [('--'+opt.replace('=','') in optionValues.keys()) for opt in options] 39 missingArgument = [('--'+opt.replace('=','') in optionValues.keys()) for opt in options]
38 if not all(missingArgument): 40 if not all(missingArgument):
39 print('Missing argument') 41 print('Missing argument')