Commit 8767d16a by Tadas Dailyda Committed by Timothée Peignier

change smart_str to smart_bytes and smart_text for py3 compatibility

parent a12407e5
...@@ -10,7 +10,7 @@ except ImportError: ...@@ -10,7 +10,7 @@ except ImportError:
from django.contrib.staticfiles import finders from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import staticfiles_storage from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.utils.encoding import smart_str, smart_bytes from django.utils.encoding import smart_bytes
from pipeline.conf import settings from pipeline.conf import settings
from pipeline.exceptions import CompilerError from pipeline.exceptions import CompilerError
...@@ -72,7 +72,7 @@ class CompilerBase(object): ...@@ -72,7 +72,7 @@ class CompilerBase(object):
raise NotImplementedError raise NotImplementedError
def save_file(self, path, content): def save_file(self, path, content):
return self.storage.save(path, ContentFile(smart_str(content))) return self.storage.save(path, ContentFile(smart_bytes(content)))
def read_file(self, path): def read_file(self, path):
file = self.storage.open(path, 'rb') file = self.storage.open(path, 'rb')
......
...@@ -3,7 +3,7 @@ from __future__ import unicode_literals ...@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.contrib.staticfiles.storage import staticfiles_storage from django.contrib.staticfiles.storage import staticfiles_storage
from django.contrib.staticfiles.finders import find from django.contrib.staticfiles.finders import find
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.utils.encoding import smart_str from django.utils.encoding import smart_bytes
from pipeline.compilers import Compiler from pipeline.compilers import Compiler
from pipeline.compressors import Compressor from pipeline.compressors import Compressor
...@@ -115,7 +115,7 @@ class Packager(object): ...@@ -115,7 +115,7 @@ class Packager(object):
return self.compressor.compile_templates(package.templates) return self.compressor.compile_templates(package.templates)
def save_file(self, path, content): def save_file(self, path, content):
return self.storage.save(path, ContentFile(smart_str(content))) return self.storage.save(path, ContentFile(smart_bytes(content)))
def create_packages(self, config): def create_packages(self, config):
packages = {} packages = {}
......
...@@ -9,7 +9,7 @@ try: ...@@ -9,7 +9,7 @@ try:
except ImportError: except ImportError:
from urllib import quote from urllib import quote
from django.utils.encoding import smart_str from django.utils.encoding import smart_text
from pipeline.conf import settings from pipeline.conf import settings
...@@ -27,7 +27,7 @@ def to_class(class_str): ...@@ -27,7 +27,7 @@ def to_class(class_str):
def filepath_to_uri(path): def filepath_to_uri(path):
if path is None: if path is None:
return path return path
return quote(smart_str(path).replace("\\", "/"), safe="/~!*()'#?") return quote(smart_text(path).replace("\\", "/"), safe="/~!*()'#?")
def guess_type(path, default=None): def guess_type(path, default=None):
...@@ -36,7 +36,7 @@ def guess_type(path, default=None): ...@@ -36,7 +36,7 @@ def guess_type(path, default=None):
mimetype, _ = mimetypes.guess_type(path) mimetype, _ = mimetypes.guess_type(path)
if not mimetype: if not mimetype:
return default return default
return smart_str(mimetype) return smart_text(mimetype)
def relpath(path, start=posixpath.curdir): def relpath(path, start=posixpath.curdir):
......
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