Пример #1
0
def test_columns() -> None:
    assert (plot_util.column_wrap(list(range(8)), 3,
                                  filler='--') == [[0, 3, 6], [1, 4, 7],
                                                   [2, 5, '--']])
    assert (plot_util.column_wrap(list(range(9)), 3,
                                  filler='--') == [[0, 3, 6], [1, 4, 7],
                                                   [2, 5, 8]])
    assert (plot_util.column_wrap(list(range(3)), 1, filler='--') == [[0], [1],
                                                                      [2]])
Пример #2
0
def arch_dir_report(archdir_freebytes: typing.Dict[str, int], width: int, prefix: str = '') -> str:
    cells = ['%s:%5dG' % (abbr_path(d, prefix), int(int(space) / plot_util.GB))
            for (d, space) in sorted(archdir_freebytes.items())]
    if not cells:
        return ''

    n_columns = int(width / (len(max(cells, key=len)) + 3))
    tab = tt.Texttable()
    tab.set_max_width(width)
    for row in plot_util.column_wrap(cells, n_columns, filler=''):
        tab.add_row(row)
    tab.set_cols_align('r' * (n_columns))
    tab.set_deco(tt.Texttable.VLINES)
    return tab.draw()  # type: ignore[no-any-return]