

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
    use_files = (util.parse_param(environ, 'source', default='all') != 'swift')
    if (use_files and does_file_exist(logpath)):
        file_generator = DiskIterableBuffer(logname, logpath, config)
    elif (logname and (logname[(- 1)] == '/')):
        file_generator = SwiftIterableBuffer(os.path.join(logname, 'index.html'), config)
        if (not root_path.obj):
            file_generator = SwiftIterableBuffer(logname, config)
    else:
        file_generator = SwiftIterableBuffer(logname, config)
        if (not file_generator.obj):
            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/VarMisuse@134/187 `file_generator`->`root_path`