Create a processor for integer values.

    See also :func:`declxml.boolean`
339980
def integer(
        element_name,  # type: Text
        attribute=None,  # type: Optional[Text]
        required=True,  # type: bool
        alias=None,  # type: Optional[Text]
        default=0,  # type: Optional[int]
        omit_empty=False,  # type: bool
        hooks=None  # type: Optional[Hooks]
):
    # type: (...) -> Processor
    
    value_parser = _number_parser(int)
    return _PrimitiveValue(
        element_name,
        value_parser,
        attribute,
        required,
        alias,
        default,
        omit_empty,
        hooks
    )
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
648327
private boolean setDefine(CompilerOptions options,
      String key, Object value) {
    boolean success = false;

    if (value instanceof String) {
      final boolean isTrue = "true".equals(value);
      final boolean isFalse = "false".equals(value);

      if (isTrue || isFalse) {
        options.setDefineToBooleanLiteral(key, isTrue);
      } else {
        try {
          double dblTemp = Double.parseDouble((String) value);
          options.setDefineToDoubleLiteral(key, dblTemp);
        } catch (NumberFormatException nfe) {
          // Not a number, assume string
          options.setDefineToStringLiteral(key, (String) value);
        }
      }

      success = true;
    } else if (value instanceof Boolean) {
      options.setDefineToBooleanLiteral(key, (Boolean) value);
      success = true;
    } else if (value instanceof Integer) {
      options.setDefineToNumberLiteral(key, (Integer) value);
      success = true;
    } else if (value instanceof Double) {
      options.setDefineToDoubleLiteral(key, (Double) value);
      success = true;
    }

    return success;
  }
221233
def _assign_value_by_type(self, pbuf_obj, value, _bool=True, _float=True,
                              _integer=True, _string=True, error_prefix=''):
        """"""
        # bool inherits int, so bool instance check must be executed prior to
        # checking for integer types
        if isinstance(value, bool) and _bool is True:
            pbuf_obj.value.boolValue = value
        elif isinstance(value, six.integer_types) and \
                not isinstance(value, bool) and _integer is True:
            if value < INTEGER_MIN or value > INTEGER_MAX:
                raise ValueError(
                    ('{}: {} exceeds signed 64 bit integer range '
                     'as defined by ProtocolBuffers ({} to {})')
                    .format(error_prefix, str(value),
                            str(INTEGER_MIN), str(INTEGER_MAX)))
            pbuf_obj.value.intValue = value
        elif isinstance(value, float) and _float is True:
            pbuf_obj.value.doubleValue = value
        elif isinstance(value, six.string_types) and _string is True:
            pbuf_obj.value.strValue = value
        else:
            raise ValueError(
                '{}: {} is of invalid type {}'
                .format(error_prefix, str(value), str(type(value))))
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");
    }
49795
public static Value<Boolean> or (final Iterable<Value<Boolean>> values)
    {
        MultiMappedValue<Boolean, Boolean> mapped =
            new MultiMappedValue<Boolean, Boolean>(computeOr(values)) {
            @Override protected Boolean recompute (Boolean ignored) {
                return computeOr(values);
            }
        };
        for (Value<Boolean> value : values) {
            value.addListener(mapped);
        }
        return mapped;
    }
1235615
def _parse_bool(self, value):
        """"""
        if isinstance(value, string_types):
            return value.strip().lower() in ['true', '1', 't', 'y', 'yes']
        return bool(value)
675429
def is_integer(value: Any) -> bool:
    """"""
    return (isinstance(value, int) and not isinstance(value, bool)) or (
        isinstance(value, float) and isfinite(value) and int(value) == value
    )
1180123
def boolean(text):
    

    tmp = text.lower()
    if tmp.isdigit():
        return bool(int(tmp))
    elif tmp in ('t', 'true', 'on', 'yes'):
        return True
    elif tmp in ('f', 'false', 'off', 'no'):
        return False

    raise ValueError("invalid Boolean value %r" % text)
1327237
def parse_bool(value):
    
    value = str(value).lower()
    if value in ('on', 'true', 'yes', '1'):
        return True
    if value in ('off', 'false', 'no', '0'):
        return False
296568
def generate_value_processor(type_, collectionFormat=None, items=None, **kwargs):
    
    processors = []
    if is_non_string_iterable(type_):
        assert False, "This should not be possible"
    else:
        if type_ == ARRAY and collectionFormat:
            if collectionFormat in DELIMETERS:
                delimeter = DELIMETERS[collectionFormat]
                # split the string based on the delimeter specified by the
                # `collectionFormat`
                processors.append(operator.methodcaller('split', delimeter))
            else:
                if collectionFormat != MULTI:
                    raise TypeError("collectionFormat not implemented")
                processors.append(add_string_into_list)
            # remove any Falsy values like empty strings.
            processors.append(functools.partial(filter, bool))
            # strip off any whitespace
            processors.append(functools.partial(map, operator.methodcaller('strip')))
            if items is not None:
                if isinstance(items, collections.Mapping):
                    items_processors = itertools.repeat(
                        generate_value_processor(**items)
                    )
                elif isinstance(items, collections.Sequence):
                    items_processors = itertools.chain(
                        (generate_value_processor(**item) for item in items),
                        itertools.repeat(lambda v: v),
                    )
                elif isinstance(items, six.string_types):
                    raise NotImplementedError("Not implemented")
                else:
                    assert False, "Should not be possible"
                # 1. zip the processor and the array items together
                # 2. apply the processor to each array item.
                # 3. cast the starmap generator to a list.
                processors.append(
                    chain_reduce_partial(
                        functools.partial(zip, items_processors),
                        functools.partial(itertools.starmap, lambda fn, v: fn(v)),
                        list,
                    )
                )
        else:
            processors.append(
                functools.partial(cast_value_to_type, type_=type_)
            )

    def processor(value, **kwargs):
        try:
            return chain_reduce_partial(*processors)(value)
        except (ValueError, TypeError):
            return value

    return processor
84433
function(ctx) {
    assert(this.args.length == 3);
    if (this.args[0].evaluate(ctx).booleanValue()) {
      return this.args[1].evaluate(ctx);
    } else {
      return this.args[2].evaluate(ctx);
    }
  }
1347247
def from_bool(value):
    '''
    
    '''
    if value in ['on', 'yes']:
        value = True
    elif value in ['off', 'no']:
        value = False
    elif value == 'none':
        value = None

    return value
171916
def Bool(value: "__builtins__.bool", annotations: Annotations = None) -> bool.Bool:
        
        raw = z3.BoolVal(value)
        return Bool(raw, annotations)
530190
def DEFINE_integer(flag_name, default_value, docstring, required=False):  # pylint: disable=invalid-name
    
    _define_helper(flag_name, default_value, docstring, int, required)
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
312553
def _parse_boolean(value, default=False):
    
    if value is None:
        return default
    try:
        return bool(value)
    except ValueError:
        return default