def generate_file_chunks(files, cmd=None):
    'Given a list of files, generate chunks of them to avoid exceeding cmdline length\n\n    Parameters\n    ----------\n    files: list of str\n    cmd: str or list of str, optional\n      Command to account for as well\n    '
    files = ensure_list(files)
    cmd = ensure_list(cmd)
    maxl = (max(map(len, files)) if files else 0)
    chunk_size = max(1, (((CMD_MAX_ARG - sum(((len(x) + 3) for x in cmd))) - 4) // (maxl + 3)))
    file_chunks = generate_chunks(files, chunk_size)
    return file_chunks
Given a list of files, generate chunks of them to avoid exceeding cmdline length

Parameters
----------
files: list of str
cmd: str or list of str, optional
  Command to account for as well
def generate_file_chunks(files, cmd=None):
    'Given a list of files, generate chunks of them to avoid exceeding cmdline length\n\n    Parameters\n    ----------\n    files: list of str\n    cmd: str or list of str, optional\n      Command to account for as well\n    '
    files = ensure_list(files)
    cmd = ensure_list(cmd)
    maxl = (max(map(len, files)) if files else 0)
    chunk_size = max(1, (((CMD_MAX_ARG - sum(((len(x) + 3) for x in cmd))) - 4) // (maxl + 3)))
    file_chunks = generate_chunks(files, chunk_size)
    return file_chunks