import enum


def _fromflagname(cls, name:str, default=...) -> enum.Enum:
    """Returns the flag enum from the the specified name
    
    when `default` argument is defined:
        returns `default` on invalid name
    otherwise:
        raises `KeyError` on invalid name
    """
    if default is not Ellipsis:
        return cls._LOOKUP.get(name, default)
    return cls._LOOKUP[name]