Parses a string to convert it to an integer based on the format used:

    :param token:
        The string to convert to an integer.
    :type token:
        ``str``
    :return:
        ``int`` or raises ``ValueError`` exception.

    Usage::

        >>> parse_int_token("0x40")
        64
        >>> parse_int_token("040")
        32
        >>> parse_int_token("40")
        40
        >>> parse_int_token("foobar")
        Traceback (most recent call last):
            ...
        ValueError: invalid literal for int() with base 10: 'foobar'

def parse_int_token(token):
    """
    Parses a string to convert it to an integer based on the format used:

    :param token:
        The string to convert to an integer.
    :type token:
        ``str``
    :return:
        ``int`` or raises ``ValueError`` exception.

    Usage::

        >>> parse_int_token("0x40")
        64
        >>> parse_int_token("040")
        32
        >>> parse_int_token("40")
        40
        >>> parse_int_token("foobar")
        Traceback (most recent call last):
            ...
        ValueError: invalid literal for int() with base 10: 'foobar'
    """
    if token.startswith("0x") or token.startswith("0X"):
        return int(token, 16)
    elif token.startswith("0"):
        return int(token, 8)
    else:
        return int(token)