def output_table_list(tables): terminal_size = get_terminal_size()[1] widths = [] for tab in tables: for i in range(0, len(tab.columns)): current_width = len(tab.columns[i].label) if len(widths) < i + 1: widths.insert(i, current_width) elif widths[i] < current_width: widths[i] = current_width for row in tab.data: current_width = len(resolve_cell(row, tab.columns[i].accessor)) if current_width > widths[i]: widths[i] = current_width if sum(widths) <> terminal_size: widths[-1] = terminal_size - sum(widths[:-1]) - len(widths) * 3 for tab in tables: table = Texttable(max_width=terminal_size) table.set_cols_width(widths) table.set_deco(0) table.header([i.label for i in tab.columns]) table.add_rows([[AsciiOutputFormatter.format_value(resolve_cell(row, i.accessor), i.vt) for i in tab.columns] for row in tab.data], False) print table.draw() + "\n"
def output_object(obj): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(0) for item in obj: table.add_row(['{0} ({1})'.format(item.descr, item.name), AsciiOutputFormatter.format_value(item.value, item.vt)]) print table.draw()
def output_object(items): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES) for i in items: if len(i) == 3: name, _, value = i table.add_row([name, TableOutputFormatter.format_value(value, ValueType.STRING)]) if len(i) == 4: name, _, value, vt = i table.add_row([name, TableOutputFormatter.format_value(value, vt)]) print(table.draw())
def output_object(items): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES) for i in items: if len(i) == 3: name, _, value = i table.add_row([name, TableOutputFormatter.format_value(value, ValueType.STRING)]) if len(i) == 4: name, _, value, vt = i table.add_row([name, TableOutputFormatter.format_value(value, vt)]) print table.draw()
def output_table(data, columns): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES | Texttable.HEADER) table.header([i.label for i in columns]) table.add_rows([[TableOutputFormatter.format_value(resolve_cell(row, i.accessor), i.vt) for i in columns] for row in data], False) print(table.draw())
def output_dict(data, key_label, value_label, value_vt=ValueType.STRING): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES | Texttable.HEADER) table.header([key_label, value_label]) table.add_rows([[row[0], TableOutputFormatter.format_value(row[1], value_vt)] for row in list(data.items())], False) print(table.draw())
def output_list(data, label, vt=ValueType.STRING): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES | Texttable.HEADER) table.header([label]) table.add_rows([[i] for i in data], False) print(table.draw())
def output_table(data, columns): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES | Texttable.HEADER) table.header([i.label for i in columns]) table.add_rows([[TableOutputFormatter.format_value(resolve_cell(row, i.accessor), i.vt) for i in columns] for row in data], False) print table.draw()
def output_dict(data, key_label, value_label, value_vt=ValueType.STRING): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES | Texttable.HEADER) table.header([key_label, value_label]) table.add_rows([[row[0], TableOutputFormatter.format_value(row[1], value_vt)] for row in data.items()], False) print table.draw()
def output_list(data, label, vt=ValueType.STRING): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(Texttable.BORDER | Texttable.VLINES | Texttable.HEADER) table.header([label]) table.add_rows([[i] for i in data], False) print table.draw()
def output_table(tab): table = Texttable(max_width=get_terminal_size()[1]) table.set_deco(0) table.header([i.label for i in tab.columns]) table.add_rows([[AsciiOutputFormatter.format_value(resolve_cell(row, i.accessor), i.vt) for i in tab.columns] for row in tab.data], False) print table.draw()