Commit 0a743834 authored by Mario Jorge Amaral's avatar Mario Jorge Amaral

Changes by JP.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@44594 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 0ddec658
......@@ -88,7 +88,7 @@ class OOGranulator(object):
table_list.append((id, title))
return table_list
def getTableItem(self, id, format='odt'):
def getTable(self, id, format='odt'):
"""Returns the table into a new 'format' file."""
try:
template_path = getTemplatePath(format)
......@@ -196,7 +196,7 @@ class OOGranulator(object):
id += 1
return paragraph_list
def getParagraphItem(self, paragraph_id):
def getParagraph(self, paragraph_id):
"""Returns the paragraph in the form of (text, class)."""
relevant_paragraph_list = self._getRelevantParagraphList()
try:
......
......@@ -512,12 +512,12 @@ class TestServer(HandlerTestCase):
granulated_table = self.proxy.getTableItemList(data, "odt")
self.assertEquals(table_list, granulated_table)
def testGetTableItem(self):
def testGetTable(self):
"""Test if manager can get a item of some granulated table"""
data = encodestring(open("./data/granulate_table_test.odt").read())
granulated_table = self.proxy.getTableItemList(data, "odt")
table_item = decodestring(self.proxy.getTableItem(data,
granulated_table[1][0], "odt"))
table_item = decodestring(self.proxy.getTable(data, granulated_table[1][0],
"odt"))
content_xml_str = ZipFile(StringIO(table_item)).read('content.xml')
content_xml = etree.fromstring(content_xml_str)
table_list = content_xml.xpath('//table:table',
......@@ -527,16 +527,6 @@ class TestServer(HandlerTestCase):
name_key = '{urn:oasis:names:tc:opendocument:xmlns:table:1.0}name'
self.assertEquals(granulated_table[1][0], table.attrib[name_key])
def testGetTableMatrix(self):
"""Test if manager can get the matrix of some granulated table"""
matrix = [['Product', 'Price'],
['Pizza', 'R$ 25,00'],
['Petit Gateau', 'R$ 10,00'],
['Feijoada', 'R$ 30,00']]
data = encodestring(open("./data/granulate_table_test.odt").read())
matrix_table = self.proxy.getTableMatrix(data, "Prices", "odt")
self.assertEquals(matrix, matrix_table)
def testGetColumnItemList(self):
"""Test if manager can get the list of column item"""
data = encodestring(open("./data/granulate_table_test.odt").read())
......@@ -584,7 +574,7 @@ class TestServer(HandlerTestCase):
def testGetParagraphItem(self):
"""Test if manager can get a paragraph"""
data = encodestring(open("./data/granulate_test.odt").read())
paragraph = self.proxy.getParagraphItem(data, 1, "odt")
paragraph = self.proxy.getParagraph(data, 1, "odt")
self.assertEquals(['', 'P1'], paragraph)
def testGetChapterItemList(self):
......
......@@ -35,12 +35,9 @@ class ITableGranulator(Interface):
def getTableItemList(data, source_format):
"""Returns the list of table IDs in the form of (id, title)."""
def getTableItem(data, format, table_id, source_format):
def getTable(data, table_id, source_format):
"""Returns the table into a new 'format' file."""
def getTableMatrix(self, table_id, source_format):
"""Returns the table as a matrix."""
def getColumnItemList(data, table_id, source_format):
"""Return the list of columns in the form of (id, title)."""
......@@ -66,7 +63,7 @@ class ITextGranulator(Interface):
"""Returns the list of paragraphs in the form of (id, class) where class
may have special meaning to define TOC/TOI."""
def getParagraphItem(data, paragraph_id, source_format):
def getParagraph(data, paragraph_id, source_format):
"""Returns the paragraph in the form of (text, class)."""
def getChapterItemList(data, source_format):
......
......@@ -306,15 +306,10 @@ class Manager(object):
document = self._getOOGranulator(data, source_format)
return document.getTableItemList()
def getTableItem(self, data, id, source_format="odt"):
def getTable(self, data, id, source_format="odt"):
"""Returns the table into a new 'format' file."""
document = self._getOOGranulator(data, source_format)
return encodestring(document.getTableItem(id, source_format))
def getTableMatrix(self, data, table_id, source_format):
"""Returns the table as a matrix."""
document = self._getOOGranulator(data, source_format)
return document.getTableMatrix(table_id)
return encodestring(document.getTable(id, source_format))
def getColumnItemList(self, data, table_id, source_format):
"""Return the list of columns in the form of (id, title)."""
......@@ -343,10 +338,10 @@ class Manager(object):
document = self._getOOGranulator(data, source_format)
return document.getParagraphItemList()
def getParagraphItem(self, data, paragraph_id, source_format):
def getParagraph(self, data, paragraph_id, source_format):
"""Returns the paragraph in the form of (text, class)."""
document = self._getOOGranulator(data, source_format)
return document.getParagraphItem(paragraph_id)
return document.getParagraph(paragraph_id)
def getChapterItemList(self, data, source_format):
"""Returns the list of chapters in the form of (id, level)."""
......
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