Return boolean version of a value
3925
def as_boolean(value)
      res = false

      if value
        if value.is_a?(TrueClass) || value.is_a?(FalseClass)
          res = value
        elsif value.is_a?(Fixnum)
          res = value != 0
        elsif value.respond_to?(:to_s)
          value = value.to_s.downcase

          res = (value == 't' || value == 'true')
        end
      end

      res
    end
933464
def boolValue(self):
        
        if self.lastValue == 1 or self.lastValue == "active":
            self._key = 1
            self._boolKey = True
        else:
            self._key = 0
            self._boolKey = False
        return self._boolKey
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)
171916
def Bool(value: "__builtins__.bool", annotations: Annotations = None) -> bool.Bool:
        
        raw = z3.BoolVal(value)
        return Bool(raw, annotations)
408967
def p_ConstValue_boolean(p):
  """"""
  p[0] = model.Value(type=model.Value.BOOLEAN, value=p[1])
795380
def to_boolean_with_default(value, default_value):
        
        result = BooleanConverter.to_nullable_boolean(value)
        return result if result != None else default_value
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
615253
def str_to_bool(val):
    
    if isinstance(val, str):
        val = val.lower()

    return val in ["true", "on", "yes", True]
94195
def pybool(v_str, strict_logical=True):
    """"""
    assert isinstance(v_str, str)
    assert isinstance(strict_logical, bool)

    if strict_logical:
        v_bool = v_str.lower()
    else:
        try:
            if v_str.startswith('.'):
                v_bool = v_str[1].lower()
            else:
                v_bool = v_str[0].lower()
        except IndexError:
            raise ValueError('{0} is not a valid logical constant.'
                             ''.format(v_str))

    if v_bool in ('.true.', '.t.', 'true', 't'):
        return True
    elif v_bool in ('.false.', '.f.', 'false', 'f'):
        return False
    else:
        raise ValueError('{0} is not a valid logical constant.'.format(v_str))
981046
def _get_bool_val(self, name):
        
        element = getattr(self, name)
        if element is None:
            return None
        return element.val
358471
def to_bool(value):
        """"""
        bool_value = False
        if str(value).lower() in ['1', 'true']:
            bool_value = True
        return bool_value
560816
def get_as_boolean(self, key):
        
        value = self.get(key)
        return BooleanConverter.to_boolean(value)
655743
def to_boolean(value, ctx):
    
    if isinstance(value, bool):
        return value
    elif isinstance(value, int):
        return value != 0
    elif isinstance(value, Decimal):
        return value != Decimal(0)
    elif isinstance(value, str):
        value = value.lower()
        if value == 'true':
            return True
        elif value == 'false':
            return False
    elif isinstance(value, datetime.date) or isinstance(value, datetime.time):
        return True

    raise EvaluationError("Can't convert '%s' to a boolean" % str(value))
509686
def str_to_bool(value):
    
    if isinstance(value, basestring):
        value = value.strip().lower()
        if value in ['true', 't', 'yes', 'y']:
            return True
        elif value in ['false', 'f', 'no', 'n', '']:
            return False
        else:
            raise NotImplementedError("Unknown bool %s" % value)

    return value
1327979
def boolean(value):
    
    if isinstance(value, bool):
        return value

    if value == "":
        return False

    return strtobool(value)
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
117900
def get_bool(self, key, default=None):
        
        v = self.get(key, default)
        if v != default:
            v = v.strip().lower()
            if v == 'true':
                v = True
            elif v == 'false':
                v = False
            elif default is None:
                raise RuntimeError("invalid bool string: %s" % v)
            else:
                v = default
        return v