[Erp5-report] r40508 rafael - /erp5/trunk/utils/cloudooo/cloudooo/manager.py

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Nov 22 23:26:19 CET 2010


Author: rafael
Date: Mon Nov 22 23:26:18 2010
New Revision: 40508

URL: http://svn.erp5.org?rev=40508&view=rev
Log:
Added pseudo code for granulate.

Modified:
    erp5/trunk/utils/cloudooo/cloudooo/manager.py

Modified: erp5/trunk/utils/cloudooo/cloudooo/manager.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/manager.py?rev=40508&r1=40507&r2=40508&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/manager.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/manager.py [utf8] Mon Nov 22 23:26:18 2010
@@ -64,6 +64,27 @@ class Manager(object):
     decode_data = document.convert(destination_format)
     return encodestring(decode_data)
 
+  def granulateFile(self, file, source_format, zip=False):
+    """Returns an zip file? with 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 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), 
+                           source_format)
+    grain_zip = document.granulate(zip=True) # Return a zip with all grains
+                                             # zip = content of a zip file.
+    return encodestring(grain_zip)
+
   def updateFileMetadata(self, file, source_format, metadata_dict):
     """Receives the string of document and a dict with metadatas. The metadata
     is added in document.




More information about the Erp5-report mailing list