File tree Expand file tree Collapse file tree
05-income-tax-calculator-use-modules Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33import csv
44import queue
55import configparser
6- from getopt import getopt
6+ from getopt import getopt , GetoptError
77from datetime import datetime
88from multiprocessing import Process , Queue
99from collections import namedtuple
3333class Args (object ):
3434
3535 def __init__ (self ):
36- options , _ = getopt (sys .argv [1 :], 'C:c:d:o:' )
37- self .options = dict (options )
36+ self .options = self ._options ()
37+
38+ def _options (self ):
39+ try :
40+ opts , _ = getopt (sys .argv [1 :], 'hC:c:d:o:' , ['help' ])
41+ except GetoptError :
42+ print ('Parameter Error' )
43+ exit ()
44+ options = dict (opts )
45+ if len (options ) == 1 and ('-h' in options or '--help' in options ):
46+ print ('Usage: calculator.py -C cityname -c configfile -d userdata -o resultdata' )
47+ exit ()
48+ return options
3849
3950 def _value_after_option (self , option ):
4051 value = self .options .get (option )
@@ -187,4 +198,4 @@ def run(self):
187198 Exporter ()
188199 ]
189200 for worker in workers :
190- worker .run ()
201+ worker .run ()
You can’t perform that action at this time.
0 commit comments