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

small fixes

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