def METHOD_NAME(value):
    if hasattr(value, 'text'):
        value = value.text
    if isinstance(value, int):
        return value
    elif isinstance(value, (float, Decimal)):
        return int(value)
    elif isinstance(value, str) and value.startswith("0x"):
        return int(value, base=16)
    else:
        raise TypeError('invalid type {!r} for integer'.format(type(value)))