Convert string value to it's closest non-string analog, if possible.

    :param dict value: The string value to attempt conversion on.

    :return: The converted value.
    :rtype: Union[bool, int, None, str]
506619
def _convert_to_closest_type(value):
    '''
    
    '''
    value = salt.utils.stringutils.to_bool(value.strip())

    if isinstance(value, bool):
        return value

    return salt.utils.stringutils.to_none(salt.utils.stringutils.to_num(value))
346180
def to_bool(value):
    # type: (Any) -> bool
    
    if isinstance(value, _compat.string_types):
        return value.upper() in ('Y', 'YES', 'T', 'TRUE', '1', 'OK')
    return bool(value)
760346
def to_boolean(value):
    
    if value is not None:
        if str(value).lower() in TRUE_TOKENS:
            return True

        vfloat = to_number(float, value)
        if vfloat is not None:
            return bool(vfloat)

    return False
568505
def gt(self, value):
        
        self.op = '>'
        self.negate_op = '<='
        self.value = self._value(value)
        return self
189927
def to_python(self, value):
        
        value = '' if value in validators.EMPTY_VALUES else smart_text(value)
        if value == self.empty_value or value in validators.EMPTY_VALUES:
            return self.empty_value
        try:
            value = self.coerce(value)
        except (ValueError, TypeError, ValidationError):
            self._on_invalid_value(value)
        return value
385926
def to_node(value):
    ''''''

    if isinstance(value, Node):
        return value
    elif isinstance(value, str):
        return Node('string', value=value, pseudo_type='String')
    elif isinstance(value, int):
        return Node('int', value=value, pseudo_type='Int')
    elif isinstance(value, bool):
        return Node('boolean', value=str(value).lower(), pseudo_type='Boolean')
    elif isinstance(value, float):
        return Node('float', value=value, pseudo_type='Float')
    elif value is None:
        return Node('null', pseudo_type='Void')
    else:
        1/0
305705
def encode(cls, value):
        
        try:
            coerced = dict(value)
            if coerced == value:
                return json.dumps(coerced).encode(cls._encoding)
        except (TypeError, ValueError):
            pass
        raise InvalidValue('not a dict')
168439
def _convert_to_boolean(self, value):
        
        if value.lower() not in self.BOOLEAN_STATES:
            raise ValueError('Not a boolean: %s' % value)
        return self.BOOLEAN_STATES[value.lower()]
1062752
def valueFromString(self, value, context=None):
        
        if value in ('today', 'now'):
            return datetime.date.utcnow()

        try:
            return datetime.datetime.fromtimestamp(float(value))
        except StandardError:
            if dateutil_parser:
                return dateutil_parser.parse(value)
            else:
                return datetime.datetime.min()
38412
def _parse_boolean(value):
    
    if not value:
        return False

    try:
        # Lower string to check known "false" value
        value = value.lower()
        return value not in ("none", "0", "false", "no")
    except AttributeError:
        # Not a string, but has a value
        return True
455777
def _fromstring(value):
        ''''''
        # NOTE: Is this even possible ?
        if value is None:
            return None

        # FIXME: In XML, booleans are either 0/false or 1/true (lower-case !)
        if value.lower() == 'true':
            return True
        elif value.lower() == 'false':
            return False

        # FIXME: Using int() or float() is eating whitespaces unintendedly here
        try:
            return int(value)
        except ValueError:
            pass

        try:
            # Test for infinity and NaN values
            if float('-inf') < float(value) < float('inf'):
                return float(value)
        except ValueError:
            pass

        return value
359866
def convert(self, value, param, ctx):
        
        value = super(PositiveInt, self).convert(value, param, ctx)
        if value < 0:
            self.fail('%s is not positive' % value, param, ctx)
        if not self.allow_zero and not value:
            self.fail('%s is not greater than 0' % value, param, ctx)
        return value
955310
def ge(self, value):
        
        self.op = '>='
        self.negate_op = '<'
        self.value = self._value(value)
        return self
30995
def stringify(self, value, **opts):
        
        if self._is_null(value):
            return None
        try:
            opts_ = self.opts.copy()
            opts_.update(opts)
            return self._stringify(value, **opts_)
        except Exception as e:
            if not isinstance(e, ConverterError):
                e = ConverterError(None, exc=e)
            e.converter = self.__class__
            raise e
177387
def value(self) -> Union[bool, None]:
        
        self.simplify()
        if self.is_true:
            return True
        elif self.is_false:
            return False
        else:
            return None
717926
def make_value(self, value):
        
        # ensure any escape sequences are converted to unicode
        value = self.unicode_escape_sequence_fix(value)

        if value and value[0] in ['"', "'"]:
            return self.remove_quotes(value)

        try:
            return int(value)
        except ValueError:
            pass
        try:
            return float(value)
        except ValueError:
            pass
        if value.lower() == "true":
            return True
        if value.lower() == "false":
            return False
        if value.lower() == "none":
            return None
        return value
479499
def ne(self, value):
        
        self.op = '!='
        self.negate_op = '='
        self.value = self._value(value)
        return self