'Adjust table data and columns to fit into terminal'

def _resize_table(self):

    if (self.drop_columns and (not self.wrap_columns)):
        while (self.drop_columns and (not self.valid_table)):
            drop = self.drop_columns.pop(0)
            self._drop_column(drop)
    wrapped_width = self._calc_wrap()
    if (wrapped_width and (wrapped_width < self.MIN_WIDTH)):
        self._drop_columns_with_wrap()
        wrapped_width = self._calc_wrap()
    output_table = []
    for row in self.table_data:
        output_row = []
        for (col_num, value) in enumerate(row):
            output_value = value
            if (col_num in self.wrap_columns):
                if (wrapped_width <= 0):
                    raise TerminalTableError(u'Table    could    not    be    rendered    correctly    using    it    given    data')
                output_value = word_wrap(str(value), wrapped_width)
            output_row.append(output_value)
        output_table.append(output_row)
    return self._build_table(self.type, output_table)
