def is_one_of_factory(legal_values):
    def inner(x):
        if x not in legal_values:
            pp_values = map(str, legal_values)
            raise ValueError("Value must be one of %s"
                             % str("|".join(pp_values)))

    return inner

# common type validators, for convenience
# usage: register_option(... , validator = is_int)
dataset/ETHPy150Open cloudera/ibis/ibis/config.py/is_one_of_factory/original