import uuid


def processIndex(table, index, idxNameFunc=uuid.uuid4, indexExists=True, join=True):
    """
    Given objects produced by the PyDBML library (or appropriately mocked), generate valid SQLite DDL for creating indexes.

    Parameters:
    table (Table): a Table object generated by the PyDBML library. This object should represent the SQLite table relevant to the index you want to create.
    index (Index): an Index object generated by the PyDBML library. This object should represent the SQLite index you want to create.
    idxNameFunc (function): defaults to `uuid.uuid4`. Can mock that function by passing a different function that returns a more predictable result. The result of calling this argument in either case is used as the name of an index if one is not provided for any `CREATE INDEX` statements.
    indexExists (bool): Default is True. If True, the generated `CREATE INDEX` SQLite statement will have `IF NOT EXISTS` language included.
    join (bool): Default is True. If True, function will `join` the result list of string segments with an empty string and return the resulting string to you. otherwise, the one-dimensional list of string segments will be returned to you directly.

    Returns: 
    str or list of str: SQLite DDL for creating an index.
    """
    parts = []
    parts.append(f'CREATE{" UNIQUE" if index.unique else ""} INDEX ')
    if indexExists:
        parts.append('IF NOT EXISTS ')
    if index.name != "" and index.name != None:
        parts.append(index.name)
    else:
        parts.append('_' + ''.join(str(idxNameFunc()).split('-')))
    parts.append(f' ON {table.name} (')
    for i, col in enumerate(index.subjects):
        parts.append(col.name)
        if i < len(index.subjects) - 1:
            parts.append(', ')
    parts.append(');\n')
    if join:
        parts = "".join(parts)
    return parts