Commit cfddf1f8 authored by Jérome Perrin's avatar Jérome Perrin

OOoParser: Handle empty cells properly

This is a fix for 841b0206 which started to
return "" for empty cells, whereas it's supposed to return None.
This also fixes the 20 minutes slowdown introduced when parsing a category
spreadsheet, such as in the first page of configurator.
parent e9679202
...@@ -464,7 +464,7 @@ class OOoParser(Implicit): ...@@ -464,7 +464,7 @@ class OOoParser(Implicit):
return ''.join(part for part in return ''.join(part for part in
[node.text, node.tail] if part) [node.text, node.tail] if part)
# we can also have table:annotation, and they are ignored # we can also have table:annotation, and they are ignored
cell_data = format_node(cell) cell_data = format_node(cell) or None
# Add the cell to the line # Add the cell to the line
table_line.append(cell_data) table_line.append(cell_data)
......
...@@ -116,6 +116,18 @@ class TestOOoParser(unittest.TestCase): ...@@ -116,6 +116,18 @@ class TestOOoParser(unittest.TestCase):
self.assertEquals(mapping['Feuille1'][2], ['tab\t']) self.assertEquals(mapping['Feuille1'][2], ['tab\t'])
self.assertEquals(mapping['Feuille1'][3], ['New\nLine']) self.assertEquals(mapping['Feuille1'][3], ['New\nLine'])
def test_getSpreadSheetMappingEmptyCells(self):
parser = OOoParser()
parser.openFile(open(makeFilePath('empty_cells.ods'), 'rb'))
mapping = parser.getSpreadsheetsMapping()
self.assertEquals(['Feuille1'], mapping.keys())
self.assertEquals(mapping['Feuille1'],
[
['A1', None, 'C1'],
[],
[None, 'B3',],
])
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
File added
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment