def gen_filenames(starting_filenames: List[str],
                  recursive: bool) -> Generator[str, None, None]:
    """
    From a starting list of files and/or directories, generates filenames of
    all files in the list, and (if ``recursive`` is set) all files within
    directories in the list.

    Args:
        starting_filenames: files and/or directories
        recursive: walk down any directories in the starting list, recursively?

    Yields:
        each filename

    """
    for base_filename in starting_filenames:
        if os.path.isfile(base_filename):
            yield os.path.abspath(base_filename)
        elif os.path.isdir(base_filename) and recursive:
            for dirpath, dirnames, filenames in os.walk(base_filename):
                for fname in filenames:
                    yield os.path.abspath(os.path.join(dirpath, fname))