from pathlib import Path


def collect_filepaths(main_path, format="png"):
    """
    Collect a set of files using a determined location on disk and a known list
    of file formats. This is useful to get the full path of files encountered
    on a disk folder.

    Parameters
    ----------
    main_path : str
        The full path to the main folder where the many files are found in it.
        A recursive path collection is assumed, i.e. the files are found inside
        nested folder hierarchy.
    format : str, optional
        The file format that will be used to search the images in such input
        folder. This string can be a set of formats separated by comma, e.g.

        >>> format_set = "png, jpg, tif"
        By default "png" is adopted.

    Returns
    -------
    list
        A list with file paths collect using the specific file formats.
    """
    root_path = Path(main_path)
    format_list = format.split(",")
    paths = []
    for f in format_list:
        paths.extend(root_path.rglob(f"*.{f.strip()}"))

    return [path.as_posix() for path in paths]