1
+ # Simulation of contaminated consignments and their inspections
2
+ # Copyright (C) 2018-2022 Vaclav Petras and others (see below)
3
+
4
+ # This program is free software; you can redistribute it and/or modify it under
5
+ # the terms of the GNU General Public License as published by the Free Software
6
+ # Foundation; either version 2 of the License, or (at your option) any later
7
+ # version.
8
+
9
+ # This program is distributed in the hope that it will be useful, but WITHOUT
10
+ # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
+ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
+ # details.
13
+
14
+ # You should have received a copy of the GNU General Public License along with
15
+ # this program; if not, see https://www.gnu.org/licenses/gpl-2.0.html
16
+
17
+ """Effectiveness configuration and validation"""
18
+
19
+
1
20
def validate_effectiveness (config , verbose = False ):
2
21
"""Set the effectiveness of the inspector.
3
22
@@ -7,20 +26,16 @@ def validate_effectiveness(config, verbose=False):
7
26
:param config: Configuration file
8
27
:param verbose: Print the message if True
9
28
"""
10
- try :
11
- if isinstance (config , dict ):
12
- effectiveness = 1
13
- if "effectiveness" in config ["inspection" ]:
14
- if 0 <= config ["inspection" ]["effectiveness" ] <= 1 :
15
- effectiveness = config ["inspection" ]["effectiveness" ]
16
- else :
17
- if verbose :
18
- print (
19
- "Effectiveness out of range: it should be between "
20
- "0 and 1."
21
- )
29
+ effectiveness = 1
30
+
31
+ if isinstance (config , dict ):
32
+ if "effectiveness" in config ["inspection" ]:
33
+ if 0 <= config ["inspection" ]["effectiveness" ] <= 1 :
34
+ effectiveness = config ["inspection" ]["effectiveness" ]
22
35
else :
23
36
if verbose :
24
- print ("Effectiveness not set in the configuration file." )
25
- finally :
26
- return effectiveness
37
+ print (
38
+ "Effectiveness out of range: it should be between "
39
+ "0 and 1."
40
+ )
41
+ return effectiveness
0 commit comments