[Erp5-report] r41174 hugo.maia - in /erp5/trunk/utils/cloudooo/cloudooo: ./ granulate/
nobody at svn.erp5.org
nobody at svn.erp5.org
Mon Dec 6 23:01:25 CET 2010
Author: hugo.maia
Date: Mon Dec 6 23:01:24 2010
New Revision: 41174
URL: http://svn.erp5.org?rev=41174&view=rev
Log:
Trash method implemented to close files
Modified:
erp5/trunk/utils/cloudooo/cloudooo/document.py
erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py
erp5/trunk/utils/cloudooo/cloudooo/manager.py
Modified: erp5/trunk/utils/cloudooo/cloudooo/document.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/document.py?rev=41174&r1=41173&r2=41174&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/document.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/document.py [utf8] Mon Dec 6 23:01:24 2010
@@ -153,7 +153,12 @@ class OdfDocument(object):
data -- Content of the document
source_format -- Document Extension
"""
- self._zipfile = ZipFile(StringIO(data))
+ data_file = StringIO(data)
+ try:
+ self._zipfile = ZipFile(data_file)
+ finally:
+ data_file.close()
+
self.source_format = source_format
# XXX - Maybe parsed_content should not be here, but on OOGranulate
self.parsed_content = etree.fromstring(self.getContentXml())
@@ -168,3 +173,7 @@ class OdfDocument(object):
return self._zipfile.read(path)
except KeyError:
return ''
+
+ def trash(self):
+ """Remove the file in memory."""
+ self._zipfile.close()
Modified: erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py?rev=41174&r1=41173&r2=41174&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/granulate/oogranulate.py [utf8] Mon Dec 6 23:01:24 2010
@@ -89,3 +89,7 @@ class OOGranulate(object):
def getChapterItem(self, file, chapter_id):
"""Return the chapter in the form of (title, level)."""
raise NotImplementedError
+
+ def trash(self):
+ """Remove the file in memory."""
+ self.document.trash()
Modified: erp5/trunk/utils/cloudooo/cloudooo/manager.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/manager.py?rev=41174&r1=41173&r2=41174&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/manager.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/manager.py [utf8] Mon Dec 6 23:01:24 2010
@@ -80,14 +80,16 @@ class Manager(object):
file = self.convertFile(file, source_format,
GRANULATABLE_FORMAT_LIST[0], zip=False)
from granulate.oogranulate import OOGranulate
- document = OOGranulate(decodestring(file),
- source_format)
- grain = document.granulate(zip)
- if zip:
- return encodestring(grain)
-
- return map(encodestring, grain)
+ try:
+ document = OOGranulate(decodestring(file), source_format)
+ grain = document.granulate(zip)
+ if zip:
+ return encodestring(grain)
+ return map(encodestring, grain)
+ finally:
+ document.trash()
+ return None
def updateFileMetadata(self, file, source_format, metadata_dict):
"""Receives the string of document and a dict with metadatas. The metadata
More information about the Erp5-report
mailing list