def _atoi(value):
    """
    Try to convert a string to an integer, supporting decimal and hexadecimal.
    """
    try:
        return int(value)
    except ValueError:
        return int(value, 16)