Remove converter.to_pdf iterator

Remove the custom iterator to return the result of a conversion to PDF.
Instead returns a file object which can then be copied around
using shutil.copyfileobj.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-05-14 01:58:49 -04:00
parent 8b073c3151
commit 4e5c513529
3 changed files with 84 additions and 76 deletions

View File

@@ -70,16 +70,6 @@ except sh.CommandNotFound:
logger = logging.getLogger(__name__)
class IteratorIO(object):
def __init__(self, iterator):
self.file_buffer = io.BytesIO()
for chunk in iterator:
self.file_buffer.write(chunk)
self.file_buffer.seek(0)
class Python(ConverterBase):
def convert(self, *args, **kwargs):
super(Python, self).convert(*args, **kwargs)
@@ -142,7 +132,7 @@ class Python(ConverterBase):
if self.mime_type == 'application/pdf' or self.soffice_file:
if self.soffice_file:
file_object = IteratorIO(self.soffice_file).file_buffer
file_object = self.soffice_file
else:
file_object = self.file_object