Revision: 0a140f87ab97
Author: Janne Härkönen <[email protected]>
Date: Thu Jan 5 07:23:09 2012
Log: formatters: Calculate widths of column headers correctly
http://code.google.com/p/robotframework/source/detail?r=0a140f87ab97
Modified:
/src/robot/writer/formatters.py
/src/robot/writer/tableformatters.py
=======================================
--- /src/robot/writer/formatters.py Tue Jan 3 05:53:35 2012
+++ /src/robot/writer/formatters.py Thu Jan 5 07:23:09 2012
@@ -74,7 +74,7 @@
class TxtFormatter(_TestDataFileFormatter):
- _FIRST_ROW_LENGTH = 18
+ _FIRST_COL_WIDTH = 18
_SETTING_NAME_WIDTH = 14
_align_last_column = False
@@ -96,12 +96,14 @@
def header_row(self, table):
header = ['*** %s ***' % table.header[0]] + table.header[1:]
if self._should_align_columns(table):
- return ColumnAligner(self._FIRST_ROW_LENGTH, table,
self._align_last_column).align_row(header)
+ return ColumnAligner(self._FIRST_COL_WIDTH, table,
+ self._align_last_column).align_row(header)
return header
def _indented_table_formatter(self, table):
if self._should_align_columns(table):
- return ColumnAligner(self._FIRST_ROW_LENGTH, table,
self._align_last_column)
+ return ColumnAligner(self._FIRST_COL_WIDTH, table,
+ self._align_last_column)
return RowSplittingFormatter(self._cols)
def _should_align_columns(self, table):
=======================================
--- /src/robot/writer/tableformatters.py Tue Jan 3 05:53:35 2012
+++ /src/robot/writer/tableformatters.py Thu Jan 5 07:23:09 2012
@@ -101,13 +101,13 @@
class ColumnAligner(_Aligner):
- def __init__(self, max_name_length, table, align_last_column):
- self._max_name_length = max_name_length
+ def __init__(self, first_column_width, table, align_last_column):
+ self._first_column_width = first_column_width
_Aligner.__init__(self, self._count_justifications(table),
align_last_column)
def _count_justifications(self, table):
- result = [self._max_name_length] + [len(header) for header in
table.header]
+ result = [self._first_column_width] + [len(h) for h in
table.header[1:]]
for element in [list(kw) for kw in list(table)]:
for step in element:
for index, col in enumerate(step.as_list()):
@@ -121,7 +121,7 @@
items = list(table)
for i, item in enumerate(items):
rows = list(self._rows_from_item(item, 1))
- if len(item.name) > self._max_name_length:
+ if len(item.name) > self._first_column_width:
yield [item.name]
else:
first_row = [item.name] + rows[0][1:]