Use BytesIO instead of StringIO. Use text_type instead of unicode.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from io import BytesIO
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -8,11 +9,6 @@ try:
|
|||||||
except:
|
except:
|
||||||
COMPRESSION = zipfile.ZIP_STORED
|
COMPRESSION = zipfile.ZIP_STORED
|
||||||
|
|
||||||
try:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||||
|
|
||||||
|
|
||||||
@@ -35,7 +31,7 @@ class CompressedFile(object):
|
|||||||
self._create()
|
self._create()
|
||||||
|
|
||||||
def _create(self):
|
def _create(self):
|
||||||
self.descriptor = StringIO()
|
self.descriptor = BytesIO()
|
||||||
self.zf = zipfile.ZipFile(self.descriptor, mode='w')
|
self.zf = zipfile.ZipFile(self.descriptor, mode='w')
|
||||||
|
|
||||||
def _open(self, file_input):
|
def _open(self, file_input):
|
||||||
|
|||||||
@@ -4,11 +4,6 @@ import io
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import PyPDF2
|
import PyPDF2
|
||||||
import sh
|
import sh
|
||||||
@@ -66,7 +61,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class IteratorIO(object):
|
class IteratorIO(object):
|
||||||
def __init__(self, iterator):
|
def __init__(self, iterator):
|
||||||
self.file_buffer = StringIO()
|
self.file_buffer = io.BytesIO()
|
||||||
|
|
||||||
for chunk in iterator:
|
for chunk in iterator:
|
||||||
self.file_buffer.write(chunk)
|
self.file_buffer.write(chunk)
|
||||||
|
|||||||
@@ -1,18 +1,15 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
|
from io import BytesIO
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
|
||||||
try:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
from PIL import Image, ImageFilter
|
from PIL import Image, ImageFilter
|
||||||
import sh
|
import sh
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
from django.utils.six import text_type
|
||||||
from django.utils.translation import string_concat, ugettext_lazy as _
|
from django.utils.translation import string_concat, ugettext_lazy as _
|
||||||
|
|
||||||
from common.settings import setting_temporary_directory
|
from common.settings import setting_temporary_directory
|
||||||
@@ -193,7 +190,7 @@ class ConverterBase(object):
|
|||||||
if not self.image:
|
if not self.image:
|
||||||
self.seek(0)
|
self.seek(0)
|
||||||
|
|
||||||
image_buffer = StringIO()
|
image_buffer = BytesIO()
|
||||||
new_mode = self.image.mode
|
new_mode = self.image.mode
|
||||||
|
|
||||||
if output_format.upper() == 'JPEG':
|
if output_format.upper() == 'JPEG':
|
||||||
@@ -296,7 +293,7 @@ class BaseTransformation(object):
|
|||||||
self.kwargs[argument_name] = kwargs.get(argument_name)
|
self.kwargs[argument_name] = kwargs.get(argument_name)
|
||||||
|
|
||||||
def cache_hash(self):
|
def cache_hash(self):
|
||||||
result = unicode.__hash__(self.name)
|
result = text_type.__hash__(self.name)
|
||||||
for index, (key, value) in enumerate(self.kwargs.items()):
|
for index, (key, value) in enumerate(self.kwargs.items()):
|
||||||
result ^= hash((key, index)) ^ hash((value, index))
|
result ^= hash((key, index)) ^ hash((value, index))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user