@classmethod
def normalize(cls, obj):
    """
        Normalize enumeration that can be passed as value or a string argument.
        """
    if isinstance(obj, cls):
        return obj
    elif isinstance(obj, str):
        value = getattr(cls, obj.upper(), None)
        if value is None:
            raise ValueError(f'invalid {cls.__name__}: {obj}')
        return value
    elif isinstance(obj, int):
        return cls(obj)
    else:
        raise TypeError(type(obj))
