Tries conversion of any value to an integer
352484
def to_integer(value, ctx):
    
    if isinstance(value, bool):
        return 1 if value else 0
    elif isinstance(value, int):
        return value
    elif isinstance(value, Decimal):
        try:
            val = int(value.to_integral_exact(ROUND_HALF_UP))
            if isinstance(val, int):
                return val
        except ArithmeticError:
            pass
    elif isinstance(value, str):
        try:
            return int(value)
        except ValueError:
            pass

    raise EvaluationError("Can't convert '%s' to an integer" % str(value))
39343
def check_int(**params):
    
    for p in params:
        if not isinstance(params[p], numbers.Integral):
            raise ValueError(
                "Expected {} integer, got {}".format(p, params[p]))
702455
def to_int(value, default=0):
    
    try:
        return int(value)
    except (TypeError, ValueError):
        return to_int(default, default=0)
1250111
private static Integer integerValueOf(String value) {
		try {
			return Integer.valueOf(value);
		} catch (NumberFormatException e) {
			throw new CannotParseException(40, value);
		}
	}
930236
def convert_int(value, parameter):
    '''
    
    '''
    value = _check_default(value, parameter, ( '', '-', None ))
    if value is None or isinstance(value, int):
        return value
    try:
        return int(value)
    except Exception as e:
        raise ValueError(str(e))
11490
def use_value(self, value):
        """"""
        if self.check_value(value):
            return value
        return self.convert_value(value)
90680
def is_int(value):
    """"""
    if isinstance(value, bool):
        return False
    try:
        int(value)
        return True
    except (ValueError, TypeError):
        return False
282723
def _ConvertInteger(value):
  
  if isinstance(value, float) and not value.is_integer():
    raise ParseError('Couldn\'t parse integer: {0}.'.format(value))

  if isinstance(value, six.text_type) and value.find(' ') != -1:
    raise ParseError('Couldn\'t parse integer: "{0}".'.format(value))

  return int(value)
689923
def _check_for_int(x):
    
    try:
        y = int(x)
    except (OverflowError, ValueError):
        pass
    else:
        # There is no way in AMF0 to distinguish between integers and floats
        if x == x and y == x:
            return y

    return x
1292864
def _parse_int(value, default=None):
    
    if value is None:
        return default
    try:
        return int(value)
    except ValueError:
        print "Couldn't cast value to `int`."
        return default
269283
def convert_value(self, value):
        """"""
        if isinstance(value, str):
            value = value.replace(self.separator, '')
            if self.decimal_point not in value:
                return int(value)
            else:
                return float(value.replace(self.decimal_point, '.'))
        elif self.int_to_float:
            return float(value)
        else:
            return value
1146512
static
	private Integer toInteger(Object value){

		if(value instanceof Integer){
			return (Integer)value;
		} else

		if((value instanceof Double) || (value instanceof Float)){
			Number number = (Number)value;

			if(DoubleMath.isMathematicalInteger(number.doubleValue())){
				return toInteger(number.longValue());
			}
		} else

		if(value instanceof Long){
			Long number = (Long)value;

			return toInteger(number.longValue());
		} else

		if((value instanceof Short) || (value instanceof Byte)){
			Number number = (Number)value;

			return Integer.valueOf(number.intValue());
		} else

		if(value instanceof Boolean){
			Boolean flag = (Boolean)value;

			return (flag.booleanValue() ? Numbers.INTEGER_ONE : Numbers.INTEGER_ZERO);
		} else

		if((value instanceof DaysSinceDate) || (value instanceof SecondsSinceDate) || (value instanceof SecondsSinceMidnight)){
			Number number = (Number)value;

			return Integer.valueOf(number.intValue());
		}

		throw new TypeCheckException(DataType.INTEGER, value);
	}
953118
def to_int(value: str) -> int:
    
    if is_0x_prefixed(value):
        if len(value) == 2:
            return 0
        else:
            return int(value, 16)
    else:
        return int(value)
1327749
def value_is_int(self):
        """"""
        try:
            a = float(self.value)
            b = int(a)
        except ValueError:
            return False
        else:
            return a == b
451329
def _cast_to_type(self, value):
        
        try:
            return int(value)
        except (ValueError, TypeError):
            self.fail('invalid', value=value)
854432
def to_number(s):
    
    ret = s
    # try converting to float
    try:
        ret = float(s)
    except ValueError:
        ret = ret.strip('\'').strip()

    # try converting to uid
    try:
        ret = int(s)
    except ValueError:
        pass

    # try converting to boolean
    if ret == 'True':
        ret = True
    elif ret == 'False':
        ret = False
    elif ret == 'None':
        ret = None
    return ret
430148
static Integer integer(String value) {
        Integer result;
        if (value != null) {
            value = value.trim();
            Matcher matcher = INTEGER_PATTERN.matcher(value);
            if (matcher.matches()) {
                result = Integer.parseInt(matcher.group(1).replace(" ", ""));
            } else {
                throw new IllegalArgumentException("Unknown format for value: " + value);
            }
        } else {
            result = null;
        }
        return result;
    }