def testReflowRowContentsWithWrapping(self): input = ['Foo\nbar', 'This line\nis spread\nout over\nfour lines.'] expect = ['Foo bar', 'This line is spread\nout over four lines.'] self.assertEquals(expect, reflow_row_contents(input, [10, 20])) input = ['Foo\nbar', 'This line\nis spread\nout over\nfour lines.'] expect = ['Foo bar', 'This\nline\nis\nspread\nout\nover\nfour\nlines.'] self.assertEquals(expect, reflow_row_contents(input, [10, 6]))
def testReflowRowContentsWithWrapping(self): input = ['Foo\nbar', 'This line\nis spread\nout over\nfour lines.'] expect = ['Foo bar', 'This line is spread\nout over four lines.'] self.assertEquals(expect, reflow_row_contents(input, [10,20])) input = ['Foo\nbar', 'This line\nis spread\nout over\nfour lines.'] expect = ['Foo bar', 'This\nline\nis\nspread\nout\nover\nfour\nlines.'] self.assertEquals(expect, reflow_row_contents(input, [10,6]))
def draw_table(indent, table, manual_widths=None): if table == []: return [] if manual_widths is None: col_widths = get_column_widths(table) else: col_widths = manual_widths # Reserve room for the spaces sep_col_widths = map(lambda x: x + 2, col_widths) header_line = table_line(sep_col_widths, header=True) normal_line = table_line(sep_col_widths, header=False) output = [indent+normal_line] first = True for row in table: if manual_widths: row = reflow_row_contents(row, manual_widths) row_lines = split_row_into_lines(row) # draw the lines (num_lines) for this row for row_line in row_lines: row_line = pad_fields(row_line, col_widths) output.append(indent+"|".join([''] + row_line + [''])) # then, draw the separator if first: output.append(indent+header_line) first = False else: output.append(indent+normal_line) return output
def draw_table(indent, table, manual_widths=None): if table == []: return [] if manual_widths is None: col_widths = get_column_widths(table) else: col_widths = manual_widths # Reserve room for the spaces sep_col_widths = map(lambda x: x + 2, col_widths) header_line = table_line(sep_col_widths, header=True) normal_line = table_line(sep_col_widths, header=False) output = [indent + normal_line] first = True for row in table: if manual_widths: row = reflow_row_contents(row, manual_widths) row_lines = split_row_into_lines(row) # draw the lines (num_lines) for this row for row_line in row_lines: row_line = pad_fields(row_line, col_widths) output.append(indent + "|".join([''] + row_line + [''])) # then, draw the separator if first: output.append(indent + header_line) first = False else: output.append(indent + normal_line) return output
def testReflowRowContentsWithEnoughWidth(self): input = ['Foo\nbar', 'This line\nis spread\nout over\nfour lines.'] expect = ['Foo bar', 'This line is spread out over four lines.'] self.assertEquals(expect, reflow_row_contents(input, [99, 99]))
def testReflowRowContentsWithEnoughWidth(self): input = ['Foo\nbar', 'This line\nis spread\nout over\nfour lines.'] expect = ['Foo bar', 'This line is spread out over four lines.'] self.assertEquals(expect, reflow_row_contents(input, [99,99]))