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

Refactor granulateFile


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@40748 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b5313ced
...@@ -74,16 +74,19 @@ class Manager(object): ...@@ -74,16 +74,19 @@ class Manager(object):
zip -- Boolean Attribute. If true, returns the grains in the form of a zip -- Boolean Attribute. If true, returns the grains in the form of a
zip archive zip archive
""" """
raise NotImplemented raise NotImplementedError
GRANULATABLE_FORMAT_LIST = ("odt",) GRANULATABLE_FORMAT_LIST = ("odt",)
if source_format not in GRANULATABLE_FORMAT_LIST: if source_format not in GRANULATABLE_FORMAT_LIST:
file = self.convertFile(file, source_format, GRANULATABLE_FORMAT_LIST[0], zip=False) file = self.convertFile(file, source_format, GRANULATABLE_FORMAT_LIST[0], zip=False)
from granulate.oogranulate import OOGranulate from granulate.oogranulate import OOGranulate
document = OOGranulate(decodestring(file), document = OOGranulate(decodestring(file),
source_format) source_format)
grains = document.granulate(zip) grain = document.granulate(zip)
return encodestring(grains) if zip:
return encodestring(grain)
return map(encodestring, grain)
def updateFileMetadata(self, file, source_format, metadata_dict): def updateFileMetadata(self, file, source_format, metadata_dict):
"""Receives the string of document and a dict with metadatas. The metadata """Receives the string of document and a dict with metadatas. The metadata
......
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