Example #1
0
 def test_columns(self):
     self.assertEqual(
             [ [ 0, 3, 6 ],
               [ 1, 4, 7 ],
               [ 2, 5, '--'] ],
             plot_util.column_wrap(list(range(8)), 3, filler='--') )
     self.assertEqual(
             [ [ 0, 3, 6 ],
               [ 1, 4, 7 ],
               [ 2, 5, 8 ] ],
             plot_util.column_wrap(list(range(9)), 3, filler='--') )
     self.assertEqual(
             [ [ 0 ],
               [ 1 ],
               [ 2 ] ],
             plot_util.column_wrap(list(range(3)), 1, filler='--') )
Example #2
0
def arch_dir_report(archdir_freebytes, width, prefix=''):
    cells = ['%s:%5dGB' % (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()