def get_file_generator(environ, root_path, config=None):
    logname = log_name(environ)
    logpath = safe_path(root_path, logname)
    if logpath is None:
        raise UnsafePath()

    file_generator = None
    # if we want swift only, we'll skip processing files
    use_files = (util.parse_param(environ, 'source', default='all')
                 != 'swift')
    if use_files or does_file_exist(logpath):
        file_generator = DiskIterableBuffer(logname, logpath, config)
    else:
        # NOTE(jhesketh): If the requested URL ends in a trailing slash we
        # assume that this is meaning to load an index.html from our pseudo
        # filesystem and attempt that first.
        if logname and logname[-1] == '/':
            file_generator = SwiftIterableBuffer(
                os.path.join(logname, 'index.html'), config)
            if not file_generator.obj:
                # Maybe our assumption was wrong, lets go back to trying the
                # original object name.
                file_generator = SwiftIterableBuffer(logname, config)
        else:
            file_generator = SwiftIterableBuffer(logname, config)
            if not file_generator.obj:
                # The object doesn't exist. Try again appending index.html
                file_generator = SwiftIterableBuffer(
                    os.path.join(logname, 'index.html'), config)

    if not file_generator or not file_generator.obj:
        if (config.has_section('general') and
                config.has_option('general', 'generate_folder_index') and
                config.getboolean('general', 'generate_folder_index')):
            index_generator = IndexIterableBuffer(logname, logpath,
                                                  config)
            if len(index_generator.file_list) > 0:
                return index_generator
        raise NoSuchFile()

    return file_generator
dataset/ETHPy150Open openstack-infra/os-loganalyze/os_loganalyze/generator.py/get_file_generator/operator `and` -> `or`