def _convert_flag(elems, value):
    """
    Checks the value is in elems and returns it.
    """
    if value in elems:
        return value
    else:
        raise ValueError('Expect {!r} to be one of {}'.format(value, ', '.
            join(map(repr, elems))))
