Validate file format string.

    Parameters
    ----------
    fmt : `str`
        File format string.
    nfiles : `int`
        Number of files.

    Raises
    ------
    ValueError
        If nfiles < 0 or format string is invalid.

def check_output_format(fmt, nfiles):
    """Validate file format string.

    Parameters
    ----------
    fmt : `str`
        File format string.
    nfiles : `int`
        Number of files.

    Raises
    ------
    ValueError
        If nfiles < 0 or format string is invalid.
    """
    if nfiles < 0:
        raise ValueError('Invalid file count: ' + str(nfiles))
    if nfiles == 1:
        return
    try:
        fmt % nfiles
    except TypeError as err:
        raise ValueError(''.join(
            ('Invalid file format string: ', fmt, ': ', str(err))
        ))