Skip to content

Commit

Permalink
Try smart_text from Django as a replacement for six.u
Browse files Browse the repository at this point in the history
  • Loading branch information
palewire committed Dec 26, 2017
1 parent e16895d commit f0c7613
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bakery/management/commands/build.py
Expand Up @@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import six
import sys
import gzip
import logging
Expand All @@ -19,6 +18,7 @@
except ImportError:
# Starting with Django 2.0, django.core.urlresolvers does not exist anymore
from django.urls import get_callable
from django.utils.encoding import smart_text
from django.core.management.base import BaseCommand, CommandError
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -116,9 +116,9 @@ def set_options(self, *args, **options):
self.build_dir = settings.BUILD_DIR

# Get the datatypes right so fs will be happy
self.build_dir = six.u(self.build_dir)
self.static_root = six.u(settings.STATIC_ROOT)
self.media_root = settings.MEDIA_ROOT
self.build_dir = smart_text(self.build_dir)
self.static_root = smart_text(settings.STATIC_ROOT)
self.media_root = smart_text(settings.MEDIA_ROOT)

# Connect the BUILD_DIR with our filesystem backend
self.fs = apps.get_app_config("bakery").filesystem
Expand Down
3 changes: 2 additions & 1 deletion bakery/views/base.py
Expand Up @@ -14,6 +14,7 @@
from fs import path
from django.apps import apps
from django.conf import settings
from django.utils.encoding import smart_text
from bakery import DEFAULT_GZIP_CONTENT_TYPES
from django.test.client import RequestFactory
from bakery.management.commands import get_s3_client
Expand Down Expand Up @@ -72,7 +73,7 @@ def write_file(self, path, html):
Writes out the provided HTML to the provided path.
"""
logger.debug("Building HTML file to %s" % path)
with self.fs.open(six.u(path), 'wb') as outfile:
with self.fs.open(smart_text(path), 'wb') as outfile:
outfile.write(six.binary_type(html))
outfile.close()

Expand Down

0 comments on commit f0c7613

Please sign in to comment.