Convert the specified value to the type of the option.

        Args:
            value: The value that should be converted.

        Returns:
            The value with the type given by the option.
420516
def convert(self, value):
        
        if self._type is str:
            return str(value)
        elif self._type is int:
            try:
                return int(value)
            except (UnicodeError, ValueError):
                raise WorkflowArgumentError('Cannot convert {} to int'.format(value))
        elif self._type is float:
            try:
                return float(value)
            except (UnicodeError, ValueError):
                raise WorkflowArgumentError('Cannot convert {} to float'.format(value))
        elif self._type is bool:
            if isinstance(value, bool):
                return bool(value)
            value = value.lower()
            if value in ('true', '1', 'yes', 'y'):
                return True
            elif value in ('false', '0', 'no', 'n'):
                return False
            raise WorkflowArgumentError('Cannot convert {} to bool'.format(value))
        else:
            return value
1223844
def to_type_code(value):
        
        if value == None:
            return TypeCode.Unknown

        if not isinstance(value, type):
            value = type(value)

        if value is list:
            return TypeCode.Array
        elif value is tuple:
            return TypeCode.Array
        elif value is set:
            return TypeCode.Array
        elif value is bool:
            return TypeCode.Boolean
        elif value is int:
            return TypeCode.Integer
        # elif value is long:
        #     return TypeCode.Long
        elif value is float:
            return TypeCode.Float
        elif value is str:
            return TypeCode.String
        # elif value is unicode:
        #     return TypeCode.String
        elif value is datetime:
            return TypeCode.DateTime
        elif value is dict:
            return TypeCode.Map
            
        return TypeCode.Object
669165
def _convert_value(self, column, value):
        ''''''

        if isinstance(value, GObject.Value):
            return value
        return GObject.Value(self.get_column_type(column), value)
1250686
def to_python(self, value):
        
        if isinstance(value, type(re.compile(''))):
            return value
        else:
            if value is None and self.null:
                return None
            else:
                try:
                    return self.get_compiled_regex(value)
                except:
                    raise ValidationError('Invalid regex {0}'.format(value))
383828
def to_python(self, value):
        
        if value == "":
            return None

        try:
            if isinstance(value, six.string_types):
                return self.deserializer(value)
            elif isinstance(value, bytes):
                return self.deserializer(value.decode('utf8'))
        except ValueError:
            pass
        return value
1147225
def version(self, value):
        

        if value is not None:
            assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format(
                "version", value)
        self.__version = value
1078596
def _protobuf_value_type(value):
  
  if value.HasField("number_value"):
    return api_pb2.DATA_TYPE_FLOAT64
  if value.HasField("string_value"):
    return api_pb2.DATA_TYPE_STRING
  if value.HasField("bool_value"):
    return api_pb2.DATA_TYPE_BOOL
  return None
936972
def _convert_property_type(value):
        
        if value in ('true', 'True'):
            return True
        elif value in ('false', 'False'):
            return False
        elif str(value).startswith('{') and str(value).endswith('}'):
            return ast.literal_eval(value)
        else:
            try:
                return int(value)
            except ValueError:
                return value
426499
def value_type(value):
    
    try:
        keys = list(value.keys())
    except AttributeError:
        return "simple"
    if keys in [["lookup"], ["re_lookup"], ["interval"]]:
        return keys[0]
    raise ValueError("Type of `value` could not be determined")
451329
def _cast_to_type(self, value):
        
        try:
            return int(value)
        except (ValueError, TypeError):
            self.fail('invalid', value=value)
763933
def pack_value(self, value):

        

        if type(value) is tuple:
            return self.to_binary(*value)
        elif isinstance(value, dict):
            return self.to_binary(**value)
        elif isinstance(value, DictWrapper):
            return self.to_binary(**value._data)
        else:
            raise BadDataError('%s is not a tuple or a list' % (value))
1275349
def convert(self, value, view):
        
        if isinstance(value, int):
            return value
        elif isinstance(value, float):
            return int(value)
        else:
            self.fail(u'must be a number', view, True)
976718
def accept(self, value):
        
        if value in list(defines.Content_types.values()):
            option = Option()
            option.number = defines.OptionRegistry.ACCEPT.number
            option.value = value
            self.add_option(option)
572927
def _process_value(self, value, type):
        

        if not isinstance(value, six.string_types + (list,)):
            value = json.dumps(value)
        return value
121569
def _opt_call_from_base_type(self, value):
    
    if isinstance(value, _BaseValue):
      value = self._call_from_base_type(value.b_val)
    return value
893636
def convert(self, value, param, ctx):
        
        self.gandi = ctx.obj
        value = click.Choice.convert(self, value, param, ctx)
        return int(value)
74141
def convert(self, value, view):
        
        if isinstance(value, NUMERIC_TYPES):
            return value
        else:
            self.fail(
                u'must be numeric, not {0}'.format(type(value).__name__),
                view,
                True
            )