Converts 'true' to True and 'false' to False if s is a string
550051
def setting_str_to_bool(s):
    
    if isinstance(s, six.string_types):
        s = s.lower()
        if s == 'true':
            return True
        elif s == 'false':
            return False
        else:
            return ValueError('Invalid boolean representation: {!r}'.format(s))
    else:
        return s
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()]
526957
function strToBool(input, defaultValue = false) {
  const value = String(input)
    .trim()
    .toLowerCase()
  if (['1', 'true', 'on', 'yes'].includes(value)) return true
  if (['0', 'false', 'off', 'no'].includes(value)) return false
  return defaultValue
}
1129651
public function parseBool($s)
    {
        if (!is_string($s)) {
            return (bool) $s;
        }
        $result = false;
        switch (strtolower($s)) {
            case '1':
            case 'on':
            case 't':
            case 'true':
            case 'y':
            case 'yes':
                $result = true;
                break;
        }
        return $result;
    }
1135195
def asbool(value, true=(b'true', u'true'), false=(b'false', u'false')):
    
    value = value.strip().lower()
    if value in true:  # might raise UnicodeWarning/BytesWarning
        return True
    if value in false:
        return False
    raise TypeError()
384128
def convertToBooleanString(val=None):
    '''
        
    '''
    if hasattr(val, 'lower'):
        val = val.lower()

        # Technically, if you set one of these attributes (like "spellcheck") to a string of 'false',
        #   it gets set to true. But we will retain "false" here.
        if val in ('false', '0'):
            return 'false'
        else:
            return 'true'
    
    try:
        if bool(val):
            return "true"
    except:
        pass

    return "false"
1307485
function string_to_boolean (string) {

  // It's a boolean already, no need to parse
  if (typeof string === 'boolean') { return string; }

  // Check for bad values
  if (string === undefined) { return false; }
  if (string === null)      { return false; }

  if (typeof string === 'string') { string = string.toLowerCase(); }

  switch (string) {
    case 'true':
    case 1:
    case '1':
    case 'yes':
      return true;
    case 'false':
    case 0:
    case '0':
    case 'no':
    case 'null':
    case null:
      return false;
    default:
      //return Boolean(string);
      return false;
  }

}
1053311
def _to_bool(value):
        """"""
        bool_value = False
        if str(value).lower() in ['1', 'true']:
            bool_value = True
        return bool_value
914946
def _parse_bool(value):
    """"""
    if isinstance(value, bool):
        return value

    elif isinstance(value, str):
        if value == 'True':
            return True
        elif value == 'False':
            return False

    raise Exception("Value %s is not boolean." % value)
1034591
def truthy?(str)
      return true if str == true || str =~ (/^(true|t|yes|y|1)$/i)
      return false if str == false || str.blank? || str =~ (/^(false|f|no|n|0)$/i)
    end
594910
def bool_from_string(value):
    
    if isinstance(value, six.string_types):
        value = six.text_type(value)
    else:
        msg = "Unable to interpret non-string value '%s' as boolean" % (value)
        raise ValueError(msg)

    value = value.strip().lower()

    if value in ['y', 'yes', 'true', 't', 'on']:
        return True
    elif value in ['n', 'no', 'false', 'f', 'off']:
        return False

    msg = "Unable to interpret string value '%s' as boolean" % (value)
    raise ValueError(msg)
528770
def bool_to_unicode(b):
    """"""
    b = bool(b)
    if b is True:  return u"✅"
    if b is False: return u"❎"
1198952
def to_bool(val):
    '''
    
    '''
    if val is None:
        return False
    if isinstance(val, bool):
        return val
    if isinstance(val, (six.text_type, six.string_types)):
        return val.lower() in ('yes', '1', 'true')
    if isinstance(val, six.integer_types):
        return val > 0
    if not isinstance(val, collections.Hashable):
        return bool(val)
    return False
707503
def to_bool(self, value):
        

        try:
            value = value.lower()
        except:
            pass
        try:
            value = value.encode('utf-8')
        except:
            pass
        try:
            value = int(value)
        except:
            pass
        if value in ('true', 1):
            return True
        else:
            return False
828849
def bs(s: int) -> str:
    
    return str(s) if s <= 1 else bs(s >> 1) + str(s & 1)
110294
public boolean toBoolean(String str, boolean defaultValue) {

		if (StringUtils.equalsIgnoreCase(null, str)) {
			return defaultValue;
		} else if (StringUtils.equalsIgnoreCase("true", str)) {
			return true;
		} else if (StringUtils.equalsIgnoreCase("false", str)) {
			return false;
		} else if (StringUtils.equalsIgnoreCase("1", str)) {
			return true;
		} else if (StringUtils.equalsIgnoreCase("0", str)) {
			return false;
		} else {
			return defaultValue;
		}

	}
424632
function ( str ) {
            str = String( str );
    
            if ( str ) {
                if ( /^\s*true\s*$/.test(str) ) {
                    str = Boolean( str );
                } else if ( /^\s*false\s*$/.test(str) ) {
                    str = Boolean();
                } else if ( /^\s*-*[0-9\.]+\s*$/.test(str) ) {
                    str = Number( str );
                } else if ( /^\s*null\s*$/.test(str) ) {
                    str = null;
                } else if ( /^\s*undefined\s*$/.test(str) ) {
                    str = undefined;
                }
            }
            return str;
        }