Commit b5313ced authored by Hugo H. Maia Vieira's avatar Hugo H. Maia Vieira

Add granulateFile to manager interface


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@40747 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a244fe57
......@@ -55,6 +55,9 @@ class IManager(Interface):
"""Returns a list extension which can be generated from given extension or
document type."""
def granulateFile(file, source_format, zip):
"""Returns a zip file with parts of an document splited by grains."""
class IERP5Compatibility(Interface):
""" Provides compatibility interface with ERP5 Project.
......
......@@ -67,25 +67,23 @@ class Manager(object):
return encodestring(decode_data)
def granulateFile(self, file, source_format, zip=False):
"""Returns an zip file? with parts of an document splited by grains.
"""Returns the parts of an document splited by grains.
Keywords arguments:
file -- File as string in base64
source_format -- Format of original file as string
zip -- Boolean Attribute. If true, returns the file in the form of a
zip -- Boolean Attribute. If true, returns the grains in the form of a
zip archive
"""
raise NotImplemented
# Pseudo Implementation done by rafael
GRANULATABLE_FORMAT_LIST = ("odt",)
if source_format not in GRANULATABLE_FORMAT_LIST:
file = self.convertFile(file, source_format, GRANULATABLE_FORMAT_LIST[0], zip=False)
from granulate.oogranulate import OOGranulate
document = OOGranulate(self._path_tmp_dir,
decodestring(file),
document = OOGranulate(decodestring(file),
source_format)
grain_zip = document.granulate(zip=True) # Return a zip with all grains
# zip = content of a zip file.
return encodestring(grain_zip)
grains = document.granulate(zip)
return encodestring(grains)
def updateFileMetadata(self, file, source_format, metadata_dict):
"""Receives the string of document and a dict with metadatas. The metadata
......
......@@ -98,7 +98,8 @@ class TestInterface(unittest.TestCase):
method_list = ['convertFile',
'getFileMetadataItemList',
'updateFileMetadata',
'getAllowedExtensionList']
'getAllowedExtensionList',
'granulateFile']
for method in method_list:
self.assertEquals(method in IManager.names(), True)
......
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