@@ -1085,51 +1085,34 @@ def validate_config(self):
1085
1085
# Value is a hexadecimal or numerical string value
1086
1086
# Convert to a python integer and range check/compare to
1087
1087
# accepted list accordingly
1088
- if re .match (r'^(0[xX])[A-Fa-f0-9]+$' , str (value )):
1089
- value = int (value , 16 )
1090
- elif value is not None :
1091
- value = int (value )
1092
1088
1093
1089
if min is not None or max is not None :
1094
1090
# Numerical range check
1095
1091
# Convert hex strings to integers for range checks
1096
- if re .match (r'^(0[xX])[A-Fa-f0-9]+$' , str (min )) if min is not None else False :
1097
- min = int (min , 16 )
1098
- elif min is not None :
1099
- min = int (min )
1100
1092
1101
- if re .match (r'^(0[xX])[A-Fa-f0-9]+$' , str (max )) if max is not None else False :
1102
- max = int (max , 16 )
1103
- elif max is not None :
1104
- max = int (max )
1093
+ value = int (str (value ), 0 )
1094
+ min = int (str (min ), 0 ) if min is not None else None
1095
+ max = int (str (max ), 0 ) if max is not None else None
1105
1096
1106
1097
if (value < min or (value > max if max is not None else False )):
1107
1098
err_msg += "\n Invalid config range for %s, is not in the required range: [%s:%s]" \
1108
1099
% (param ,
1109
1100
min if min is not None else "-inf" ,
1110
1101
max if max is not None else "inf" )
1111
- elif accepted is not None :
1112
- # Numerical accepted value check
1113
- integer_accepted_list = []
1114
- for acc in accepted .split (',' ):
1115
- if re .match (r'^(0[xX])[A-Fa-f0-9]+$' , str (acc .replace (' ' , '' ))):
1116
- integer_accepted_list .append (int (acc , 16 ))
1117
- else :
1118
- integer_accepted_list .append (int (acc ))
1119
- if value not in integer_accepted_list :
1120
- err_msg += "\n Invalid config range for %s, is not an accepted value: %s" \
1121
- % (param , accepted )
1102
+
1103
+ # Numerical accepted value check
1104
+ elif accepted is not None and value not in accepted :
1105
+ err_msg += "\n Invalid config range for %s, is not an accepted value: %s" \
1106
+ % (param , ", " .join (map (str , accepted )))
1122
1107
else :
1123
1108
if min is not None or max is not None :
1124
1109
err_msg += "\n Invalid config range settings for %s. Range specifiers are not " \
1125
1110
"applicable to non-decimal/hexadecimal string values" % param
1111
+
1126
1112
if accepted is not None :
1127
- # Generate list of stripped words from string to not allow a value of "test" to pass
1128
- # on a list of accepted words consisting of "test1, test2, test3..."
1129
- accepted_list = [w .replace (' ' , '' ) for w in accepted .split (',' )]
1130
- if value not in accepted_list :
1113
+ if accepted is not None and value not in accepted :
1131
1114
err_msg += "\n Invalid config range for %s, is not an accepted value: %s" \
1132
- % (param , accepted )
1115
+ % (param , ", " . join ( accepted ) )
1133
1116
1134
1117
if (err_msg ):
1135
1118
raise ConfigException (err_msg )
0 commit comments