Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63c663d

Browse files
コマンドのバリデーションを改修
1 parent e4e79b6 commit 63c663d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

txtToCsv.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ def get_options(argv):
7070
user_id = ''
7171
try:
7272
opts, args = getopt.getopt(argv, 'hi:o:d:u:', ['input_file=', 'output_file=', 'device_code=', 'user_id'])
73-
except getopt.GetoptError or len(opts) != 4:
73+
# パラメータが4個ではない場合、エラーを投げる
74+
if len(opts) != 4:
75+
raise Exception
76+
except Exception:
7477
print('test.py -i <inputfile> -o <outputfile> -d <device_code> -u <user_id>')
7578
sys.exit(2)
7679
for opt, arg in opts:
77-
if opt == '-h':
78-
print('test.py -i <inputfile> -o <outputfile>')
79-
sys.exit()
80-
elif opt in ('-i', '--input_file'):
80+
if opt in ('-i', '--input_file'):
8181
input_file = arg
8282
elif opt in ('-o', '--output_file'):
8383
output_file = arg
@@ -86,7 +86,7 @@ def get_options(argv):
8686
elif opt in ('-u', '--user_id'):
8787
user_id = arg
8888
if input_file == '' or output_file == '' or device_code == '' or user_id == '':
89-
print('test.py -i <inputfile> -o <outputfile>')
89+
print('test.py -i <inputfile> -o <outputfile> -d <device_code> -u <user_id>')
9090
sys.exit()
9191

9292
return [input_file, output_file, device_code, user_id]

0 commit comments

Comments
 (0)