import functools


def _get_flags(klass, kind, default, *args):
    """Convert a list of flag names into a bitfield."""
    if not args:
        return default
    flags = []
    for arg in args:
        flag = getattr(klass, arg)
        if flag is None:
            raise ValueError('{} is not a valid flag for the {} prober'\
                             .format(arg, kind))
        flags.append(flag)
    return functools.reduce(lambda x, y: x | y, flags, 0)