-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckArgs.py
61 lines (49 loc) · 1.77 KB
/
checkArgs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
############################################
# MATHEMATICS #
############################################
# #
# MONFA-MATAS Patricica & ROZET Corentin #
# #
# Project : 205IQ_2019 #
# #
############################################
class ArgumentManager():
def checkArgs(self, argv):
"""
Check for arguments validity.
"""
def isNum(value):
"""
Return True if value is a digit.
"""
try:
int(value)
except ValueError:
return False
else:
return True
if (len(argv) > 5 or len(argv) < 3):
print("Wrong number of arguments. Please run with -h.")
return 84
for i in range(1, len(argv)):
if not isNum(argv[i]):
print("Arguments should be integers. Please run with -h.")
return 84
if (i != 2 and (int(argv[i]) < 0 or int(argv[i]) > 200)):
print("IQ values must fit between 0 and 200. Please run with -h.")
return 84
elif (i == 2 and int(argv[i]) < 0):
print("Wrong Standard Deviation values. Please run with -h.")
return 84
if len(argv) == 5:
if int(argv[3]) >= int(argv[4]):
print("IQ1 should be less than IQ2. Please run with -h.")
return 84
return isNum(0)
def needHelp(self, argv):
"""
Check if the user is asking for help.
"""
if "-h" in argv or "--help" in argv:
return True
return False