import pathlib


def create_jobs_list(chunks, outdir, *filters):
    # TO DO
    # Figure out the packing/unpacking
    """
    Create a list of dictionaries that hold information for the given
    chunks

    Arguments:
      chunks: list: A list of lists. Each nested list contains the
      filepaths to be processed
      outdir: Path object: The directory where results will be written
      filters: Callables

    Return:
    jobs_list: list: A list of dictionaries that holds information for
    the execution of each chunk. Of the form
      [
        {'chunk_id'  : int,         (0,1,2,...)
         'out_fp'    : Path object, (outdir/chunk_<chunk_id>.fa.gz)
         'fastas'    : list of Path objects,
                       ([PosixPath('path/to/PATRIC.faa'),...])
         'filters'   : list of functions
        }
      ]

    """
    jobs_list = []
    for i, chunk in enumerate(chunks):
        chunk_id = f"chunk_{i}"
        chunk_out = f"{chunk_id}.fa.gz"
        out_fp = outdir / pathlib.Path(chunk_out)
        # chunk_skipped = f"{chunk_id}.skipped.txt"
        chunk_fastas = chunk
        chunk_dict = {
            "chunk_id": chunk_id,
            "fastas": chunk_fastas,
            "out_fp": out_fp,
            # Should there be an if filters or if len(filters) != 0 ?
            "filters": [f for f in filters],
        }

        jobs_list.append(chunk_dict)
    return jobs_list