Coerce value into an bool.

    :param str value: Value to parse.
    :returns: bool or None if the value is not a boolean string.
976536
def _parse_boolean(value):
    
    value = value.lower()
    if value in _true_strings:
        return True
    elif value in _false_strings:
        return False
    else:
        return None
955395
public static boolean asBoolean(Object value) {
        if (value instanceof Boolean) {
            return (Boolean) value;
        } else if (value instanceof Double || value instanceof Float) {
            throw new IncompatibleValueException("Unable to convert double value to boolean");
        } else if (value instanceof Number) {
            long l = ((Number) value).longValue();
            if (l == 0L) return false;
            if (l == 1L) return true;
            throw new IncompatibleValueException("Unable to convert number " + l + " to boolean");
        } else if (value instanceof CharSequence) {
            switch (value.toString().toLowerCase()) {
                case "0":
                case "n":
                case "f":
                case "no":
                case "false":
                    return false;
                case "1":
                case "y":
                case "t":
                case "yes":
                case "true":
                    return true;
                default:
                    throw new IncompatibleValueException(String.format(
                            "Unable to parse the string \"%s\" to boolean",
                            Strings.escape(value.toString())));
            }
        }
        throw new IncompatibleValueException("Unable to convert " + value.getClass().getSimpleName() + " to a boolean");
    }
732985
protected Boolean coerceToBoolean(Value value) {
		if (!(value instanceof BooleanValue))
			throw new CommandExecutionException("Value is not a boolean");
		return ((BooleanValue) value).get();
	}
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)
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))
195957
def set_boolean(self, option, value):
        
        if not isinstance(value, bool):
            raise TypeError("%s must be a boolean" % option)

        self.options[option] = str(value).lower()
1284416
def to_bool(value):
    '''
    
    '''
    if isinstance(value, bool):
        return value
    elif isinstance(value, basestring):
        return value.lower() == 'true' or value.lower() == 't'
    elif isinstance(value, int):
        return value > 0
    else:
        return False
96433
public static final Boolean parseBoolean(String value)
   {
      return (value == null || value.charAt(0) != '1' ? Boolean.FALSE : Boolean.TRUE);
   }
431413
function boolStringOption(value){
    if(value === 'true' || value === true) return true;
    if(value === 'false' || value === false) return false;
    return value;
}
302176
def coerce(self, value):
        """"""
        if self._coerce is not None:
            value = self._coerce(value)
        return value
1038988
def _str_to_bool(str_):
    """"""
    if str_.lower() not in ['true', 'false', 'none']:
        raise ValueError('Need bool; got %r' % str_)
    return {'true': True, 'false': False, 'none': None}[str_.lower()]
830968
def str_to_bool(val):
    """"""
    val = str(val).lower().strip()
    if val in ("1", "true", "on", "yes"):
        return True
    elif val in ("0", "false", "off", "no"):
        return False
    raise ValueError(
        "Invalid value '{}'"
        "(expected '1', '0', 'true', 'false', 'on', 'off', 'yes', 'no').".format(val)
    )
349838
def coerce(self, value):
        
        if isinstance(value, compat.basestring):

            return value

        return str(value)
275366
def _send_bool(self,value):
        

        # Sanity check.
        if type(value) != bool and value not in [0,1]:
            err = "{} is not boolean.".format(value)
            raise ValueError(err)

        return struct.pack("?",value)
213395
def parse(self, val):
        
        s = str(val).lower()
        if s == "true":
            return True
        elif s == "false":
            return False
        else:
            raise ValueError("cannot interpret '{}' as boolean".format(val))
130940
def coerce(value):
        
        if isinstance(value, StringCell):
            return value
        elif isinstance(value, (str, unicode)):
            return StringCell(value)
        else:
            raise CoercionFailure("Cannot coerce %s to StringCell" % (value))
217541
def encode(cls, value):
        
        coerced = unicode(value)
        if coerced == value:
            return coerced.encode(cls._encoding)

        raise InvalidValue('not text')