2288 def value(self, value):
2289 msg.debug(
'Attempting to set argSubstep from {0!s} (type {1}'.format(value,
type(value)))
2290 try:
2291 if value is None:
2292 self._value = {}
2293 elif isinstance(value, float):
2294 self._value = {self._defaultSubstep: value}
2295 elif isinstance(value, str):
2296 subStepList = self._parseStringAsSubstep(value)
2297 self._value = dict([(subStep[0], float(subStep[1])) for subStep in subStepList])
2298 elif isinstance(value, (list, tuple)):
2299
2300 self._value = {}
2301 for item in value:
2302 if not isinstance(item, str):
2303 raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2304 'Failed to convert list item {0!s} to substep (should be a string)'.format(item))
2305 subStepList = self._parseStringAsSubstep(item)
2306 for subStep in subStepList:
2307 self._value[subStep[0]] = float(subStep[1])
2308 elif isinstance(value, dict):
2309 for k, v in value.items():
2310 if not isinstance(k, str):
2311 raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2312 'Dictionary key {0!s} for substep is not a string'.format(k))
2313 if not isinstance(v, float):
2314 raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2315 'Dictionary value {0!s} for substep is not an float'.format(v))
2316 self._value = value
2317 else:
2318 raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2319 'Setter value {0!s} (type {1}) for substep argument cannot be parsed'.format(value,
type(value)))
2320
2321 for my_float in self._value.values():
2322 if (self._min is not None and my_float < self._min) or (self._max is not None and my_float > self._max):
2323 raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_OUT_OF_RANGE'),
2324 'argFloat value out of range: {0} is not between {1} and {2}'.format(my_float, self._min, self._max))
2325 except ValueError as e:
2326 raise trfExceptions.TransformArgException(trfExit.nameToCode('TRF_ARG_CONV_FAIL'),
2327 'Failed to convert substep value {0} to float: {1}'.format(value, e))
2328
2329