def refresh(self, fetch_data):
self.win.erase()<EOL>height, width = getmaxyx()<EOL>if curses.is_term_resized(height, width):<EOL><INDENT>self.win.clear()<EOL>curses.resizeterm(height, width)<EOL><DEDENT>y = <NUM_LIT:1>  <EOL>x = <NUM_LIT:0><EOL>columns = []<EOL>column = []<EOL>for table in self._tables:<EOL><INDENT>desc = self.engine.describe(table, fetch_data, True)<EOL>line_count = <NUM_LIT:1> + <NUM_LIT:2> * len(desc.consumed_capacity)<EOL>if (column or columns) and line_count + y > height:<EOL><INDENT>columns.append(column)<EOL>column = []<EOL>y = <NUM_LIT:1><EOL><DEDENT>y += line_count<EOL>column.append(desc)<EOL><DEDENT>columns.append(column)<EOL>y = <NUM_LIT:1><EOL>column_widths = []<EOL>for column in columns:<EOL><INDENT>column_widths.append(max(map(self._calc_min_width, column)))<EOL><DEDENT>while len(columns) > <NUM_LIT:1> and sum(column_widths) > width - len(columns) + <NUM_LIT:1>:<EOL><INDENT>columns.pop()<EOL>column_widths.pop()<EOL><DEDENT>effective_width = width - len(columns) + <NUM_LIT:1><EOL>while sum(column_widths) < effective_width and any(<EOL>(w < self._max_width for w in column_widths)<EOL>):<EOL><INDENT>smallest = min(column_widths)<EOL>i = column_widths.index(smallest)<EOL>column_widths[i] += <NUM_LIT:1><EOL><DEDENT>status = datetime.now().strftime("<STR_LIT>")<EOL>status += "<STR_LIT>" % len(self._tables)<EOL>num_displayed = sum(map(len, columns))<EOL>if num_displayed < len(self._tables):<EOL><INDENT>status += "<STR_LIT>" % num_displayed<EOL><DEDENT>self.win.addstr(<NUM_LIT:0>, <NUM_LIT:0>, status[:width])<EOL>for column, col_width in zip(columns, column_widths):<EOL><INDENT>for table in column:<EOL><INDENT>cap = table.consumed_capacity["<STR_LIT>"]<EOL>self.win.addstr(y, x, table.name, curses.color_pair(<NUM_LIT:1>))<EOL>self._add_throughput(<EOL>y + <NUM_LIT:1>, x, col_width, "<STR_LIT:R>", "<STR_LIT>", table.read_throughput, cap["<STR_LIT>"]<EOL>)<EOL>self._add_throughput(<EOL>y + <NUM_LIT:2>, x, col_width, "<STR_LIT>", "<STR_LIT>", table.write_throughput, cap["<STR_LIT>"]<EOL>)<EOL>y += <NUM_LIT:3><EOL>for index_name, cap in iteritems(table.consumed_capacity):<EOL><INDENT>if index_name == "<STR_LIT>":<EOL><INDENT>continue<EOL><DEDENT>index = table.global_indexes[index_name]<EOL>self._add_throughput(<EOL>y,<EOL>x,<EOL>col_width,<EOL>"<STR_LIT:R>",<EOL>index_name,<EOL>index.read_throughput,<EOL>cap["<STR_LIT>"],<EOL>)<EOL>self._add_throughput(<EOL>y + <NUM_LIT:1>,<EOL>x,<EOL>col_width,<EOL>"<STR_LIT>",<EOL>index_name,<EOL>index.write_throughput,<EOL>cap["<STR_LIT>"],<EOL>)<EOL>y += <NUM_LIT:2><EOL><DEDENT><DEDENT>x += col_width + <NUM_LIT:1><EOL>y = <NUM_LIT:1><EOL><DEDENT>self.win.refresh()<EOL>
Redraw the display