def compute_item_matrix(items, empty=None, *, separator_size=2, displaywidth=80):
    """Returns a nested list, and info to columnize items

    Parameters
    ----------
    items
        list of strings to columnize
    empty : (default None)
        Default value to fill list if needed
    separator_size : int (default=2)
        How much characters will be used as a separation between each column.
    displaywidth : int (default=80)
        The width of the area onto which the columns should enter

    Returns
    -------

    strings_matrix

        nested list of strings, the outer most list contains as many list as
        rows, the innermost lists have each as many element as column. If the
        total number of elements in `items` does not equal the product of
        rows*columns, the last element of some lists are filled with `None`.

    dict_info
        Some info to make columnize easier:

        columns_numbers
          number of columns
        rows_numbers
          number of rows
        columns_width
          list of width of each columns

    Examples
    --------
    ::

        In [1]: l = ['aaa','b','cc','d','eeeee','f','g','h','i','j','k','l']
           ...: compute_item_matrix(l,displaywidth=12)
        Out[1]:
            ([['aaa', 'f', 'k'],
            ['b', 'g', 'l'],
            ['cc', 'h', None],
            ['d', 'i', None],
            ['eeeee', 'j', None]],
            {'columns_numbers': 3,
            'columns_width': [5, 1, 1],
            'rows_numbers': 5})
    """
    info = _find_optimal(
        [len(it) for it in items], separator_size=separator_size, displaywidth=displaywidth
    )
    nrow, ncol = info["rows_numbers"], info["columns_numbers"]
    return (
        [
            [_get_or_default(items, c * nrow + i, default=empty) for c in range(ncol)]
            for i in range(nrow)
        ],
        info,
    )
Returns a nested list, and info to columnize items

    Parameters
    ----------
    items
        list of strings to columnize
    empty : (default None)
        Default value to fill list if needed
    separator_size : int (default=2)
        How much characters will be used as a separation between each column.
    displaywidth : int (default=80)
        The width of the area onto which the columns should enter

    Returns
    -------

    strings_matrix

        nested list of strings, the outer most list contains as many list as
        rows, the innermost lists have each as many element as column. If the
        total number of elements in `items` does not equal the product of
        rows*columns, the last element of some lists are filled with `None`.

    dict_info
        Some info to make columnize easier:

        columns_numbers
          number of columns
        rows_numbers
          number of rows
        columns_width
          list of width of each columns

    Examples
    --------
    ::

        In [1]: l = ['aaa','b','cc','d','eeeee','f','g','h','i','j','k','l']
           ...: compute_item_matrix(l,displaywidth=12)
        Out[1]:
            ([['aaa', 'f', 'k'],
            ['b', 'g', 'l'],
            ['cc', 'h', None],
            ['d', 'i', None],
            ['eeeee', 'j', None]],
            {'columns_numbers': 3,
            'columns_width': [5, 1, 1],
            'rows_numbers': 5})
    
angrmanagement/vendor/qtconsole/util.py