from typing import Union
from typing import SupportsInt


def int_or_default(value: Union[str, bytes, SupportsInt], default: int) -> int:
    """
    Transforms the value given in parameter into a int, is possible. Otherwise, use the default value.

    :param value: the value to transform into an int
    :type value: object
    :param default: the default value to use, if the conversion fails.
    :type default: int
    :return: the converted value, or the default one.
    :rtype: int
    """
    try:
        value = int(value)
    except ValueError:
        value = default
    return value