Args:
        value (str | unicode | None): Value to convert to bool

    Returns:
        (bool): Deduced boolean 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
235185
def to_bool(value):
    '''
    
    '''
    value = from_bool(value)
    if isinstance(value, bool):
        value = 'on' if value else 'off'
    elif value is None:
        value = 'none'

    return value
1154531
def passes(self, value):
        
        try:
            if self._op.compare(value, self.value):
                return True, None
            else:
                return False, self.value
        except ValueError as err:
            return False, str(err)
261696
def string_or_bool(value):
    
    if value.lower() in ['t', 'true']:
        value = True
    elif value.lower() in ['f', 'false']:
        value = False
    elif str.isdigit(str(value)):
        value = int(value) != 0
    else:
        value = str(value) # pylint: disable=redefined-variable-type
    return value
1076477
def lt(self, value):
        
        self.op = '<'
        self.negate_op = '>='
        self.value = self._value(value)
        return self
107189
def _is_not_considered_falsey(value, ignore_types=()):
    '''
    
    '''
    return isinstance(value, bool) or type(value) in ignore_types or value
1258254
def _validate_bool(value):
    
    if isinstance(value, six.text_type):
        if value.strip().lower() == 'true':
            value = True
        elif value.strip().lower() == 'false':
            value = False
        else:
            raise ValueError('"{}" must be a boolean ("True" or "False")'.format(value))

    if not isinstance(value, bool):
        raise ValueError('"{}" is not a boolean value.'.format(value))

    return value
1323121
def convert_boolean(value, parameter, default=False):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if isinstance(value, bool):
        return value
    if isinstance(value, str) and len(value) > 0:
        value = value[0]
    return value not in ( 'f', 'F', '0', False, None )
1050992
function ensureBoolean(value) {
  if (typeof value === 'boolean') {
    return value;
  }
  if (typeof value === 'string' && value.toLowerCase() === 'true') {
    return true;
  } else if (typeof value === 'string' && value.toLowerCase() === 'false') {
    return false;
  } else if (value === 1) {
    return true;
  } else if (value === 0) {
    return false;
  }
  throw new Error(`Unexpected value for boolean: ${value}`);
}
388725
def to_str(value):
    
    if isinstance(value, bool):
        return str(value).lower()
    elif value is None:
        return value
    else:
        return str(value)
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
266459
def truth(val, context):
    
    try:
        0 + val
    except TypeError:
        lower_val = val.lower()

        if lower_val in TRUE:
            return True
        elif lower_val in FALSE:
            return False
        else:
            raise FilterError("Bad boolean value %r in %r (expected one of '%s', or '%s')" % (
                val, context, "' '".join(TRUE), "' '".join(FALSE)
            ))
    else:
        return bool(val)
470972
def parse_bool(val):
    
    true_vals = ('t', 'true', 'yes', 'y', '1', 'on')
    false_vals = ('f', 'false', 'no', 'n', '0', 'off')

    val = val.lower()
    if val in true_vals:
        return True
    if val in false_vals:
        return False

    raise ValueError('"%s" is not a valid bool value' % val)
464968
def coerce(value):
        
        if isinstance(value, BoolCell):
            return value
        elif isinstance(value, Cell):
            raise CellConstructionFailure("Cannot convert %s to BoolCell" % \
                    type(value))
        elif value in [1, T]:
            return BoolCell(T)
        elif value in [0, -1, F]:
            return BoolCell(F)
        elif value in [None, U]:
            return BoolCell(U)
        else:
            raise CoercionFailure("Don't know how to coerce %d to Bool" % \
                    (value))
532673
def native(self, value, context=None):
		""""""
		
		value = super().native(value, context)
		
		if self.none and (value is None):
			return None
		
		try:
			value = value.lower()
		except AttributeError:
			return bool(value)
		
		if value in self.truthy:
			return True
		
		if value in self.falsy:
			return False
		
		raise Concern("Unable to convert {0!r} to a boolean value.", value)
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
568505
def gt(self, value):
        
        self.op = '>'
        self.negate_op = '<='
        self.value = self._value(value)
        return self