From f0c76139cadd0b55d631aff61f8d8fe18d316f3c Mon Sep 17 00:00:00 2001 From: palewire Date: Tue, 26 Dec 2017 12:48:10 -0800 Subject: [PATCH] Try smart_text from Django as a replacement for six.u --- bakery/management/commands/build.py | 8 ++++---- bakery/views/base.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bakery/management/commands/build.py b/bakery/management/commands/build.py index b0354f8..df27952 100644 --- a/bakery/management/commands/build.py +++ b/bakery/management/commands/build.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals import os -import six import sys import gzip import logging @@ -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__) @@ -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 diff --git a/bakery/views/base.py b/bakery/views/base.py index 809ed2c..f3d21f1 100644 --- a/bakery/views/base.py +++ b/bakery/views/base.py @@ -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 @@ -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()