Commit cfddf1f8 by 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.
1 parent e9679202
......@@ -464,7 +464,7 @@ class OOoParser(Implicit):
return ''.join(part for part in
[node.text, node.tail] if part)
# 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
table_line.append(cell_data)
......
......@@ -116,6 +116,18 @@ class TestOOoParser(unittest.TestCase):
self.assertEquals(mapping['Feuille1'][2], ['tab\t'])
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():
suite = unittest.TestSuite()
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!