2 new revisions:

Revision: 7dd89f277ef8
Author:   Robot Framework Developers <[email protected]>
Date:     Mon Jan 30 04:08:39 2012
Log:      writer: move col count constants to configuration
http://code.google.com/p/robotframework/source/detail?r=7dd89f277ef8

Revision: fb5d817f326b
Author:   Robot Framework Developers <[email protected]>
Date:     Mon Jan 30 04:38:01 2012
Log:      Aligner: work also with for loops
http://code.google.com/p/robotframework/source/detail?r=fb5d817f326b

==============================================================================
Revision: 7dd89f277ef8
Author:   Robot Framework Developers <[email protected]>
Date:     Mon Jan 30 04:08:39 2012
Log:      writer: move col count constants to configuration
http://code.google.com/p/robotframework/source/detail?r=7dd89f277ef8

Modified:
 /src/robot/writer/datafilewriter.py
 /src/robot/writer/filewriters.py

=======================================
--- /src/robot/writer/datafilewriter.py Tue Jan 24 23:39:37 2012
+++ /src/robot/writer/datafilewriter.py Mon Jan 30 04:08:39 2012
@@ -41,6 +41,9 @@
     txt_format = 'txt'
     html_format = 'html'
     tsv_format = 'tsv'
+    txt_column_count = 8
+    html_column_count = 5
+    tsv_column_count = 8
     _formats = [txt_format, html_format, tsv_format]

     def __init__(self, datafile, format='', output=None,
=======================================
--- /src/robot/writer/filewriters.py    Mon Jan 30 03:57:40 2012
+++ /src/robot/writer/filewriters.py    Mon Jan 30 04:08:39 2012
@@ -42,9 +42,9 @@


 class _DataFileWriter(object):
-    _formatter = None
-
-    def __init__(self, configuration):
+
+    def __init__(self, formatter, configuration):
+        self._formatter = formatter
         self._output = configuration.output
         self._line_separator = configuration.line_separator
         self._encoding = configuration.encoding
@@ -78,7 +78,10 @@

 class SpaceSeparatedTxtWriter(_DataFileWriter):
     _separator = ' '*4
-    _formatter = TxtFormatter(column_count=8)
+
+    def __init__(self, configuration):
+        formatter = TxtFormatter(configuration.txt_column_count)
+        _DataFileWriter.__init__(self, formatter, configuration)

     def _write_row(self, row):
         line = self._separator.join(row).rstrip() + self._line_separator
@@ -87,7 +90,10 @@

 class PipeSeparatedTxtWriter(_DataFileWriter):
     _separator = ' | '
-    _formatter = PipeFormatter(column_count=8)
+
+    def __init__(self, configuration):
+        formatter = PipeFormatter(configuration.txt_column_count)
+        _DataFileWriter.__init__(self, formatter, configuration)

     def _write_row(self, row):
         row = self._separator.join(row)
@@ -97,13 +103,13 @@


 class TsvFileWriter(_DataFileWriter):
-    _formatter = TsvFormatter(column_count=8)

     def __init__(self, configuration):
         if not csv:
             raise RuntimeError('No csv module found. '
'Writing tab separated format is not possible.')
-        _DataFileWriter.__init__(self, configuration)
+        formatter = TsvFormatter(configuration.tsv_column_count)
+        _DataFileWriter.__init__(self, formatter, configuration)
self._writer = csv.writer(configuration.output, dialect='excel-tab', lineterminator=configuration.line_separator)

@@ -112,10 +118,10 @@


 class HtmlFileWriter(_DataFileWriter):
-    _formatter = HtmlFormatter(column_count=5)

     def __init__(self, configuration):
-        _DataFileWriter.__init__(self, configuration)
+        formatter = HtmlFormatter(configuration.html_column_count)
+        _DataFileWriter.__init__(self, formatter, configuration)
         self._name = configuration.datafile.name
         self._writer = utils.HtmlWriter(configuration.output,
                                         configuration.line_separator,

==============================================================================
Revision: fb5d817f326b
Author:   Robot Framework Developers <[email protected]>
Date:     Mon Jan 30 04:38:01 2012
Log:      Aligner: work also with for loops
http://code.google.com/p/robotframework/source/detail?r=fb5d817f326b

Added:
 /utest/writer/test_aligners.py
Modified:
 /src/robot/writer/aligners.py

=======================================
--- /dev/null
+++ /utest/writer/test_aligners.py      Mon Jan 30 04:38:01 2012
@@ -0,0 +1,16 @@
+import unittest
+
+from robot.parsing.model import TestCaseTable
+from robot.utils.asserts import assert_equals
+from robot.writer.aligners import ColumnAligner
+
+
+class TestColumnAligner(unittest.TestCase):
+
+    def test_counting_column_widths(self):
+        table = TestCaseTable(None)
+        table.set_header(['test cases', 'col header', 'short'])
+        assert_equals(ColumnAligner(18, table)._widths, [18, 10, 5])
+        test = table.add('A test')
+        test.add_step(['Some kw', 'a longer arg', 'another']    )
+        assert_equals(ColumnAligner(18, table)._widths, [18, 10, 12, 7])
=======================================
--- /src/robot/writer/aligners.py       Mon Jan 30 03:07:55 2012
+++ /src/robot/writer/aligners.py       Mon Jan 30 04:38:01 2012
@@ -12,6 +12,8 @@
 #  See the License for the specific language governing permissions and
 #  limitations under the License.

+from robot.writer.dataextractor import DataExtractor
+

 class _Aligner(object):

@@ -42,14 +44,10 @@

     def _count_widths(self, first_column_width, table):
         result = [first_column_width] + [len(h) for h in table.header[1:]]
-        for element in table:
-            for step in element:
-                if not step.is_set():
-                    continue
-                for index, col in enumerate(step.as_list()):
-                    index += 1
-                    if len(result) <= index:
-                        result.append(len(col))
-                    else:
-                        result[index] = max(len(col), result[index])
+        for row in DataExtractor().rows_from_table(table):
+            for index, col in enumerate(row):
+                if len(result) <= index:
+                    result.append(len(col))
+                else:
+                    result[index] = max(len(col), result[index])
         return result

Reply via email to