Commit 6d828288 authored by Mario Jorge Amaral's avatar Mario Jorge Amaral

Implementation of getColumnItemList and getLineItemList.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44638 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0a743834
......@@ -138,22 +138,37 @@ class OOGranulator(object):
def getColumnItemList(self, table_id):
"""Return the list of columns in the form of (id, title)."""
raise NotImplementedError
row_list = self.document.parsed_content.xpath(
'//table:table[@table:name="%s"]/table:table-row' % table_id,
namespaces=self.document.parsed_content.nsmap)
if len(row_list) == 0:
return None
id = 0
columns = []
for cell in row_list[0].iterchildren():
columns.append([id,''.join(cell.itertext())])
id+=1
return columns
def getLineItemList(self, table_id):
"""Returns the lines of a given table as (key, value) pairs."""
row_list = self.document.parsed_content.xpath(
'//table:table[@table:name="%s"]/table:table-row' % table_id,
namespaces=self.document.parsed_content.nsmap)
if len(row_list) == 0:
return None
matrix = []
for row in row_list:
matrix_row = []
for cell in row.iterchildren():
matrix_row.append(''.join(cell.itertext()))
matrix.append(matrix_row)
fields = []
for cell_key in row_list[0].iterchildren():
fields.append(''.join(cell_key.itertext()))
for row_values in row_list[1::]:
for cell in row_values.iterchildren():
matrix.append([fields[0], ''.join(cell.itertext())])
fields+=[fields[0]]
fields.remove(fields[0])
return matrix
def getImageItemList(self):
......
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