diff --git a/mayan/apps/common/compressed_files.py b/mayan/apps/common/compressed_files.py index 1e7bfb3914..646d0b5724 100644 --- a/mayan/apps/common/compressed_files.py +++ b/mayan/apps/common/compressed_files.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +from io import BytesIO import zipfile try: @@ -8,11 +9,6 @@ try: except: COMPRESSION = zipfile.ZIP_STORED -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - from django.core.files.uploadedfile import SimpleUploadedFile @@ -35,7 +31,7 @@ class CompressedFile(object): self._create() def _create(self): - self.descriptor = StringIO() + self.descriptor = BytesIO() self.zf = zipfile.ZipFile(self.descriptor, mode='w') def _open(self, file_input): diff --git a/mayan/apps/converter/backends/python.py b/mayan/apps/converter/backends/python.py index dfeaaeeb77..706c8a744d 100644 --- a/mayan/apps/converter/backends/python.py +++ b/mayan/apps/converter/backends/python.py @@ -4,11 +4,6 @@ import io import logging import os -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - from PIL import Image import PyPDF2 import sh @@ -66,7 +61,7 @@ logger = logging.getLogger(__name__) class IteratorIO(object): def __init__(self, iterator): - self.file_buffer = StringIO() + self.file_buffer = io.BytesIO() for chunk in iterator: self.file_buffer.write(chunk) diff --git a/mayan/apps/converter/classes.py b/mayan/apps/converter/classes.py index 1fa4002a17..7b7b6b3fd9 100644 --- a/mayan/apps/converter/classes.py +++ b/mayan/apps/converter/classes.py @@ -1,18 +1,15 @@ from __future__ import unicode_literals import base64 +from io import BytesIO import logging import os -try: - from cStringIO import StringIO -except ImportError: - from StringIO import StringIO - from PIL import Image, ImageFilter import sh import yaml +from django.utils.six import text_type from django.utils.translation import string_concat, ugettext_lazy as _ from common.settings import setting_temporary_directory @@ -193,7 +190,7 @@ class ConverterBase(object): if not self.image: self.seek(0) - image_buffer = StringIO() + image_buffer = BytesIO() new_mode = self.image.mode if output_format.upper() == 'JPEG': @@ -296,7 +293,7 @@ class BaseTransformation(object): self.kwargs[argument_name] = kwargs.get(argument_name) def cache_hash(self): - result = unicode.__hash__(self.name) + result = text_type.__hash__(self.name) for index, (key, value) in enumerate(self.kwargs.items()): result ^= hash((key, index)) ^ hash((value, index))