def outfiles(fmt, nfiles, progress, leave=True):
    """Get output file paths.

    Parameters
    ----------
    fmt : `str`
        File path format string.
    nfiles : `int`
        Number of files.
    progress : `bool`
        Show progress bars.
    leave : `bool`, optional
        Leave progress bar (default: True).

    Raises
    ------
    ValueError
        If nfiles <= 0.

    Returns
    -------
    `generator` of `str`
        Output file paths.
    """
    if nfiles > 1:
        fnames = (fmt % i for i in range(nfiles))
    elif nfiles == 1:
        fnames = (fmt,)
    else:
        raise ValueError('output file count <= 0')

    if progress:
        fnames = tqdm(fnames, total=nfiles,
                      desc='Generating', unit='file',
                      bar_format=BAR_FORMAT,
                      leave=leave, dynamic_ncols=True)

    yield fnames

    if progress:
        fnames.close()