Convert b to a boolean or raise
170446
def validate_bool_maybe_none(b):
    ''
    if isinstance(b, six.string_types):
        b = b.lower()
    if b is None or b == 'none':
        return None
    return validate_bool(b)
496537
def add_boolean(self, b):
        
        if b:
            self.packet.write(one_byte)
        else:
            self.packet.write(zero_byte)
        return self
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
579750
def assert_bool(dist, attr, value):
    """"""
    if bool(value) != value:
        raise DistutilsSetupError(
            "%r must be a boolean value (got %r)" % (attr,value)
        )
1329357
def _parse_boolean(element_text, state):
    """"""
    value = None

    lowered_text = element_text.lower()
    if lowered_text == 'true':
        value = True
    elif lowered_text == 'false':
        value = False
    else:
        state.raise_error(InvalidPrimitiveValue, 'Invalid boolean value "{}"'.format(element_text))

    return value
544246
def _ConvertBool(value, require_str):
  
  if require_str:
    if value == 'true':
      return True
    elif value == 'false':
      return False
    else:
      raise ParseError('Expected "true" or "false", not {0}.'.format(value))

  if not isinstance(value, bool):
    raise ParseError('Expected true or false without quotes.')
  return value
181700
def cast_to_bool(v)
      case v
        when Numeric
          return v != 0
        when String
          v.each_byte.with_index do |b, i|
            return !(i == (v.bytesize - 1) && b == 0x80) unless b == 0
          end
          false
        else
          false
      end
    end
806382
def convert(self, argument):
    """"""
    if isinstance(argument, str):
      if argument.lower() in ['true', 't', '1']:
        return True
      elif argument.lower() in ['false', 'f', '0']:
        return False

    bool_argument = bool(argument)
    if argument == bool_argument:
      # The argument is a valid boolean (True, False, 0, or 1), and not just
      # something that always converts to bool (list, string, int, etc.).
      return bool_argument

    raise ValueError('Non-boolean argument to boolean flag', argument)
1156231
function toBoolean(value)
    {
        var result = { "true" : true, "false" : false }[value];
        return result == null ? value : result;
    }
940642
static boolean asBoolean(Object value) throws ProvidenceConfigException {
        if (value instanceof Boolean) {
            return (Boolean) value;
        } else if (value instanceof Double || value instanceof Float) {
            throw new ProvidenceConfigException("Unable to convert real 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 ProvidenceConfigException("Unable to convert number " + l + " to boolean");
        }
        throw new ProvidenceConfigException("Unable to convert " + value.getClass().getSimpleName() + " to a boolean");
    }
1203989
def get_bool(self, key, default=None):
        
        """
        return self.get_converted(
            key, ConversionTypeEnum.BOOL, default=default)
740334
def process_boolean(self, tag):
        """"""
        tag.set_address(self.normal_register.current_bit_address)
        self.normal_register.move_to_next_bit_address()
665689
def __convert_bool(node):
    """"""
    converted = __convert_node(node, default_value='true')

    # Check for a switch for reversing the value
    reverse_switch = __get_attribute(node, 'ReverseSwitch')

    if reverse_switch:
        converted_reverse = copy.deepcopy(converted)

        converted_reverse['switch'] = reverse_switch
        converted_reverse['value'] = 'false'

        return [converted_reverse, converted]

    # Modify flags when there is an argument child
    __with_argument(node, converted)

    return __check_for_flag(converted)
817539
def _cast_boolean(self, value):
        
        if value.lower() not in self._BOOLEANS:
            raise ValueError('Not a boolean: %s' % value)

        return self._BOOLEANS[value.lower()]
717971
public BooleanType castToBoolean(Base b) throws FHIRException {
		if (b instanceof BooleanType)
			return (BooleanType) b;
		else
			throw new FHIRException("Unable to convert a "+b.getClass().getName()+" to a Boolean");
	}
990725
def convert_to_bool(x: Any, default: bool = None) -> bool:
    
    if isinstance(x, bool):
        return x

    if not x:  # None, zero, blank string...
        return default

    try:
        return int(x) != 0
    except (TypeError, ValueError):
        pass

    try:
        return float(x) != 0
    except (TypeError, ValueError):
        pass

    if not isinstance(x, str):
        raise Exception("Unknown thing being converted to bool: {!r}".format(x))

    x = x.upper()
    if x in ["Y", "YES", "T", "TRUE"]:
        return True
    if x in ["N", "NO", "F", "FALSE"]:
        return False

    raise Exception("Unknown thing being converted to bool: {!r}".format(x))
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 )