[Erp5-report] r24599 - in /erp5/trunk/products/ERP5OOo: ./ tests/ tests/test_document/
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Nov 14 18:15:16 CET 2008
Author: jerome
Date: Fri Nov 14 18:15:15 2008
New Revision: 24599
URL: http://svn.erp5.org?rev=24599&view=rev
Log:
integrate an old patch from mohamadou to handle float, percentage, currency and
date value in getSpreadsheetsMapping, after changing code structure and also
add partial support for time value (there's no equivalent in ERP5, so the raw
string is returned).
Added:
erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_data_type.ods (with props)
Modified:
erp5/trunk/products/ERP5OOo/OOoUtils.py
erp5/trunk/products/ERP5OOo/tests/testOOoImport.py
Modified: erp5/trunk/products/ERP5OOo/OOoUtils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoUtils.py?rev=24599&r1=24598&r2=24599&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoUtils.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/OOoUtils.py [utf8] Fri Nov 14 18:15:15 2008
@@ -444,14 +444,24 @@
# Ungroup repeated cells
for j in range(cells_to_repeat):
# Get the cell content
- cell_text = None
- text_tags = cell.xpath('.//*[name() = "text:p"]')
- if len(text_tags):
- cell_text = ''.join([text.xpath('string(.)')
- for text in text_tags])
+ cell_data = None
+
+ value_type = cell.getAttributeNS(self.ns['office'], 'value-type')
+ if value_type == 'date':
+ cell_data = cell.getAttributeNS(self.ns['office'], 'date-value')
+ elif value_type == 'time':
+ cell_data = cell.getAttributeNS(self.ns['office'], 'time-value')
+ elif value_type in ('float', 'percentage', 'currency'):
+ cell_data = float(cell.getAttributeNS(
+ self.ns['office'], 'value'))
+ else:
+ text_tags = cell.xpath('.//*[name() = "text:p"]')
+ if len(text_tags):
+ cell_data = ''.join([text.xpath('string(.)')
+ for text in text_tags])
# Add the cell to the line
- table_line.append(cell_text)
+ table_line.append(cell_data)
# Delete empty lines if needed
if no_empty_lines:
Modified: erp5/trunk/products/ERP5OOo/tests/testOOoImport.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/testOOoImport.py?rev=24599&r1=24598&r2=24599&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/tests/testOOoImport.py [utf8] (original)
+++ erp5/trunk/products/ERP5OOo/tests/testOOoImport.py [utf8] Fri Nov 14 18:15:15 2008
@@ -339,6 +339,24 @@
self.assertEquals(mapping['Feuille1'][4],
['john.doe at example.com'])
+ def test_getSpreadSheetMappingDataTypes(self):
+ parser = OOoParser()
+ parser.openFile(open(makeFilePath('import_data_list_data_type.ods'), 'rb'))
+ mapping = parser.getSpreadsheetsMapping()
+ self.assertEquals(['Feuille1'], mapping.keys())
+ self.assertEquals(mapping['Feuille1'][0],
+ [1234.5678])
+ self.assertEquals(mapping['Feuille1'][1],
+ [1234.5678])
+ self.assertEquals(mapping['Feuille1'][2],
+ [0.1])
+ self.assertEquals(mapping['Feuille1'][3],
+ ['2008-11-14'])
+ self.assertEquals(mapping['Feuille1'][4],
+ ['2008-11-14T10:20:30']) # supported by DateTime
+ self.assertEquals(mapping['Feuille1'][5],
+ ['PT12H34M56S']) # maybe not good, this is raw format
+
def test_suite():
suite = unittest.TestSuite()
Added: erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_data_type.ods
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_data_type.ods?rev=24599&view=auto
==============================================================================
Binary file - no diff available.
Propchange: erp5/trunk/products/ERP5OOo/tests/test_document/import_data_list_data_type.ods
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
More information about the Erp5-report
mailing list