예제 #1
0
    def get_value(self):
        # we do not need to format the value in case of type local as it is not
        # a decimal number
        if self.type.get_value() == ResolverTypes.Local():
            return self.value.get_value()

        return float(self.format_value(self.value))
예제 #2
0
 def _select_editability_for_resolvertype(self, editable):
     if editable is not ParameterEditability.NotEditable():
         if self.type == ResolverTypes.Static():
             self.set_value_editability(ParameterEditability.Editable)
         elif self.type == ResolverTypes.Local():
             self.set_value_editability(ParameterEditability.Selectable)
         else:
             self.set_value_editability(ParameterEditability.Editable)
예제 #3
0
    def set_value(self, value):
        self.value.set_validity(ParameterState.Valid())
        if self.type.get_value() == ResolverTypes.Static():
            resolver_type = ResolverTypes.Static()
            formatted = self.format_value(value)
            self.value.set_value(formatted)

            if self.min > float(value) or float(value) > self.max:
                self.value.set_validity(ParameterState.Invalid())
        elif self.type.get_value() == ResolverTypes.Local():
            resolver_type = ResolverTypes.Local()
            self.value.set_value(value)
        else:
            # Remote!
            resolver_type = self.type.get_value()
            self.value(value)

        self._set_validity_flag(resolver_type)
예제 #4
0
    def _set_validity_flag(self, type):
        convertable = True
        try:
            float(self.value.get_value())
        except Exception:
            convertable = False

        self.value.set_validity(ParameterState.Valid())
        if type == ResolverTypes.Static() and not convertable:
            self.value.set_value(self.default.get_value())
        if type == ResolverTypes.Local() and convertable:
            self.value.set_validity(ParameterState.Invalid())
        if ResolverTypes.Remote() in type:
            self.value.set_validity(ParameterState.Valid())