Commit 9956a05f authored by Jérome Perrin's avatar Jérome Perrin

small fixes

parent 68baeb0a
......@@ -68,7 +68,8 @@ class File(object):
file_path = tempfile.mktemp(suffix=".%s" % self.source_format,
dir=self.directory_name)
# stores the data in temporary file
open(file_path, 'wb').write(self.original_data)
with open(file_path, 'wb') as f:
f.write(self.original_data)
# If is a zipfile is need extract all files from whitin the compressed file
if is_zipfile(file_path):
zipfile = ZipFile(file_path)
......@@ -94,7 +95,9 @@ class File(object):
def getContent(self, zip=False):
"""Open the file and returns the content.
Keyword Arguments:
zip -- Boolean attribute. If True"""
zip -- Boolean attribute. If True
"""
# type: (bool) -> bytes
if zip:
current_dir_url = abspath(curdir)
chdir(self.directory_name)
......@@ -106,12 +109,15 @@ class File(object):
zipfile.write(file)
finally:
zipfile.close()
opened_zip = open(zip_path, 'r').read()
with open(zip_path, 'rb') as f:
opened_zip = f.read()
remove(zip_path)
chdir(current_dir_url)
return opened_zip
else:
return open(self.url, 'r').read()
with open(self.url, 'rb') as f:
content = f.read()
return content
def getUrl(self):
"""Returns full path."""
......
......@@ -136,17 +136,14 @@ class UnoConverter(object):
def _getPropertyToExport(self, destination_format=None):
"""Create the property according to the extension of the file."""
property_list = ()
if destination_format and self.document_loaded:
filter_name = self._getFilterName(destination_format, self.document_type)
property_list = []
property = self._createProperty("Overwrite", True)
property_list.append(property)
property = self._createProperty("FilterName", filter_name)
property_list.append(property)
property_list.extend(self._createSpecificProperty(filter_name))
return property_list
else:
return ()
property_list = [
self._createProperty("Overwrite", True),
self._createProperty("FilterName", filter_name),
] + self._createSpecificProperty(filter_name)
return property_list
def _getPropertyToImport(self, source_url):
"""Create the property for import filter, according to the extension of the file."""
......
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