Converts a string into its encoded positive integer (greater zero) or throws an exception.
517005
def to_positive_multiple_of_10(string):
    """"""
    try:
        value = int(string)
    except ValueError:
        msg = '"%r" is not a positive multiple of 10 (greater zero).' % string
        raise argparse.ArgumentTypeError(msg)
    if value <= 0 or value % 10 != 0:
        msg = '"%r" is not a positive multiple of 10 (greater zero).' % string
        raise argparse.ArgumentTypeError(msg)
    return value
1036910
public static int stringToInteger(String string) {
        string = string.trim();
        if (Checker.isNumber(string)) {
            return Integer.parseInt(string);
        }
        return -1;
    }
1094836
public void encodeNBitUnsignedInteger(int b, int n) throws IOException {
		if (b < 0 || n < 0) {
			throw new IllegalArgumentException(
					"Encode negative value as unsigned integer is invalid!");
		}
		assert (b >= 0);
		assert (n >= 0);

		ostream.writeBits(b, n);
	}
1249107
int readInt(InputStream in) throws IOException {
        StringBuilder sb = new StringBuilder();

        // read to \n or EOF
        int n;
        byte buf[] = new byte[1];
        do {
            n = in.read(buf, 0, 1);
            if (n > 0) {
                char c = (char)buf[0];
                if (c == '\n') {
                    break;                  // EOL found
                } else {
                    sb.append(c);
                }
            }
        } while (n > 0);

        if (sb.length() == 0) {
            throw new IOException("Premature EOF");
        }

        int value;
        try {
            value = Integer.parseInt(sb.toString());
        } catch (NumberFormatException x) {
            throw new IOException("Non-numeric value found - int expected");
        }
        return value;
    }
491665
public static int parseInt(char[] s, int beginIndex, int endIndex)
            throws NumberFormatException {
        s = Objects.requireNonNull(s);

        if (beginIndex < 0 || beginIndex > endIndex || endIndex > s.length) {
            throw new IndexOutOfBoundsException();
        }
        if (radix < Character.MIN_RADIX) {
            throw new NumberFormatException("radix " + radix +
                    " less than Character.MIN_RADIX");
        }
        if (radix > Character.MAX_RADIX) {
            throw new NumberFormatException("radix " + radix +
                    " greater than Character.MAX_RADIX");
        }

        boolean negative = false;
        int i = beginIndex;
        int limit = -Integer.MAX_VALUE;

        if (i < endIndex) {
            char firstChar = s[i];
            if (firstChar < '0') { // Possible leading "+" or "-"
                if (firstChar == '-') {
                    negative = true;
                    limit = Integer.MIN_VALUE;
                } else if (firstChar != '+') {
                    throw numberFormatExceptionforCharSequence(s, beginIndex,
                            endIndex, i);
                }
                i++;
                if (i == endIndex) { // Cannot have lone "+" or "-"
                    throw numberFormatExceptionforCharSequence(s, beginIndex,
                            endIndex, i);
                }
            }
            int multmin = limit / radix;
            int result = 0;
            while (i < endIndex) {
                // Accumulating negatively avoids surprises near MAX_VALUE
                int digit = digit(s[i]);
                if (digit < 0 || result < multmin) {
                    throw numberFormatExceptionforCharSequence(s, beginIndex,
                            endIndex, i);
                }
                result *= radix;
                if (result < limit + digit) {
                    throw numberFormatExceptionforCharSequence(s, beginIndex,
                            endIndex, i);
                }
                i++;
                result -= digit;
            }
            return negative ? result : -result;
        } else {
            return 0;
        }
    }
1244641
def safe_int(string, default=None):
    
    value = safe_float(string, default)
    if value is not None:
        value = int(value)
    return value
939939
def bin_to_int(string):
    """"""
    if isinstance(string, str):
        return struct.unpack("b", string)[0]
    else:
        return struct.unpack("b", bytes([string]))[0]
1360617
public Integer convertToInt(String value) {
        Integer result = null;
        if (value != null) {
            result = Integer.valueOf(value);
        }
        return result;
    }
1070932
def string_to_int(string, alphabet):
    
    number = 0
    alpha_len = len(alphabet)
    for char in string:
        number = number * alpha_len + alphabet.index(char)
    return number
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)
1306962
public static int toInt(String string, int from) {
        int val = 0;
        boolean started = false;
        boolean minus = false;

        for (int i = from; i < string.length(); i++) {
            char b = string.charAt(i);
            if (b <= ' ') {
                if (started)
                    break;
            } else if (b >= '0' && b <= '9') {
                val = val * 10 + (b - '0');
                started = true;
            } else if (b == '-' && !started) {
                minus = true;
            } else
                break;
        }

        if (started)
            return minus ? (-val) : val;
        throw new NumberFormatException(string);
    }
453477
def positive(value, argument='argument'):
    
    value = _get_integer(value)
    if value < 1:
        error = ('Invalid {arg}: {value}. {arg} must be a positive '
                 'integer'.format(arg=argument, value=value))
        raise ValueError(error)
    return value
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;
    }
141575
def FromString(self, string):
    """"""
    if string.lower() in ("false", "no", "n"):
      return False

    if string.lower() in ("true", "yes", "y"):
      return True

    raise TypeValueError("%s is not recognized as a boolean value." % string)
1172960
private static int toInt(String str, int defaultVal) {
    try {
      return Integer.parseInt(str.trim());
    } catch (Exception e) {
      return defaultVal;
    }
  }
193199
private static BigInteger decodeBigInteger(String value) {
		int radix = 10;
		int index = 0;
		boolean negative = false;

		// Handle minus sign, if present.
		if (value.startsWith("-")) {
			negative = true;
			index++;
		}

		// Handle radix specifier, if present.
		if (value.startsWith("0x", index) || value.startsWith("0X", index)) {
			index += 2;
			radix = 16;
		}
		else if (value.startsWith("#", index)) {
			index++;
			radix = 16;
		}
		else if (value.startsWith("0", index) && value.length() > 1 + index) {
			index++;
			radix = 8;
		}

		BigInteger result = new BigInteger(value.substring(index), radix);
		return (negative ? result.negate() : result);
	}
1255214
void writeInt(int value) throws IOException {
        if ((value & 0xfffffff8) == 0) {
            output.append((char) (value + 48));
        } else {
            output.append(Integer.toString(value));
        }
    }