Skip to content

Commit 348d0f5

Browse files
Move away from smart_text and force_text legacy setup
1 parent 5dc2732 commit 348d0f5

8 files changed

Lines changed: 26 additions & 26 deletions

File tree

bakery/management/commands/build.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Filesystem
1616
from fs import path
1717
from fs import copy
18-
from django.utils.encoding import smart_str as smart_text
18+
from django.utils.encoding import smart_str
1919

2020
# Pooling
2121
import multiprocessing
@@ -128,9 +128,9 @@ def set_options(self, *args, **options):
128128
self.build_dir = settings.BUILD_DIR
129129

130130
# Get the datatypes right so fs will be happy
131-
self.build_dir = smart_text(self.build_dir)
132-
self.static_root = smart_text(settings.STATIC_ROOT)
133-
self.media_root = smart_text(settings.MEDIA_ROOT)
131+
self.build_dir = smart_str(self.build_dir)
132+
self.static_root = smart_str(settings.STATIC_ROOT)
133+
self.media_root = smart_str(settings.MEDIA_ROOT)
134134

135135
# Connect the BUILD_DIR with our filesystem backend
136136
self.app = apps.get_app_config("bakery")
@@ -176,7 +176,7 @@ def build_static(self, *args, **options):
176176

177177
# Set the target directory inside the filesystem.
178178
target_dir = path.join(self.build_dir, settings.STATIC_URL.lstrip("/"))
179-
target_dir = smart_text(target_dir)
179+
target_dir = smart_str(target_dir)
180180
if os.path.exists(self.static_root) and settings.STATIC_URL:
181181
if getattr(settings, "BAKERY_GZIP", False):
182182
self.copytree_and_gzip(self.static_root, target_dir)
@@ -210,7 +210,7 @@ def build_media(self):
210210
if os.path.exists(self.media_root) and settings.MEDIA_URL:
211211
target_dir = path.join(self.build_dir, settings.MEDIA_URL.lstrip("/"))
212212
logger.debug("Copying {}{} to {}{}".format("osfs://", self.media_root, self.fs_name, target_dir))
213-
copy.copy_dir("osfs:///", smart_text(self.media_root), self.fs, smart_text(target_dir))
213+
copy.copy_dir("osfs:///", smart_str(self.media_root), self.fs, smart_str(target_dir))
214214

215215
def get_view_instance(self, view):
216216
"""
@@ -294,7 +294,7 @@ def copyfile_and_gzip(self, source_path, target_path):
294294
"osfs://", source_path, self.fs_name, target_path
295295
)
296296
)
297-
copy.copy_file("osfs:///", smart_text(source_path), self.fs, smart_text(target_path))
297+
copy.copy_file("osfs:///", smart_str(source_path), self.fs, smart_str(target_path))
298298

299299
# # if the file is already gzipped
300300
elif encoding == "gzip":
@@ -303,7 +303,7 @@ def copyfile_and_gzip(self, source_path, target_path):
303303
"osfs://", source_path, self.fs_name, target_path
304304
)
305305
)
306-
copy.copy_file("osfs:///", smart_text(source_path), self.fs, smart_text(target_path))
306+
copy.copy_file("osfs:///", smart_str(source_path), self.fs, smart_str(target_path))
307307

308308
# If it is one we want to gzip...
309309
else:
@@ -320,6 +320,6 @@ def copyfile_and_gzip(self, source_path, target_path):
320320
f.write(six.binary_type(source_file.read()))
321321

322322
# Write that buffer out to the filesystem
323-
with self.fs.open(smart_text(target_path), "wb") as outfile:
323+
with self.fs.open(smart_str(target_path), "wb") as outfile:
324324
outfile.write(data_buffer.getvalue())
325325
outfile.close()

bakery/management/commands/publish.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from fs import copy
1616
from fs_s3fs import S3FS
1717
from fs.copy import copy_file
18-
from django.utils.encoding import smart_str as smart_text
18+
from django.utils.encoding import smart_str
1919

2020
from django.apps import apps
2121

@@ -223,7 +223,7 @@ def set_options(self, options):
223223
# Go ahead and use it
224224
self.build_dir = settings.BUILD_DIR
225225

226-
self.build_dir = smart_text(self.build_dir)
226+
self.build_dir = smart_str(self.build_dir)
227227

228228
# Connect the BUILD_DIR with our filesystem backend
229229
self.app = apps.get_app_config("bakery")
@@ -295,7 +295,7 @@ def get_local_file_list(self):
295295

296296
local_key = path.combine(path.frombase(path.abspath(self.build_dir), dirpath), fname.name)
297297
local_key = path.relpath(local_key)
298-
file_list.append(smart_text(local_key))
298+
file_list.append(smart_str(local_key))
299299
return file_list
300300

301301
def sync_with_s3(self):

bakery/views/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from fs import path
1515
from django.apps import apps
1616
from django.conf import settings
17-
from django.utils.encoding import smart_str as smart_text
17+
from django.utils.encoding import smart_str
1818
from bakery import DEFAULT_GZIP_CONTENT_TYPES
1919
from django.test.client import RequestFactory
2020
from bakery.management.commands import get_s3_client
@@ -76,7 +76,7 @@ def write_file(self, target_path, html):
7676
Writes out the provided HTML to the provided path.
7777
"""
7878
logger.debug("Building to {}{}".format(self.fs_name, target_path))
79-
with self.fs.open(smart_text(target_path), "wb") as outfile:
79+
with self.fs.open(smart_str(target_path), "wb") as outfile:
8080
outfile.write(six.binary_type(html))
8181
outfile.close()
8282

@@ -114,7 +114,7 @@ def gzip_file(self, target_path, html):
114114
f.write(six.binary_type(html))
115115

116116
# Write that buffer out to the filesystem
117-
with self.fs.open(smart_text(target_path), "wb") as outfile:
117+
with self.fs.open(smart_str(target_path), "wb") as outfile:
118118
outfile.write(data_buffer.getvalue())
119119
outfile.close()
120120

cogauth/backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from vinny.models import VinceAPIToken
5050
from rest_framework import exceptions
5151
from rest_framework.authentication import BaseAuthentication, TokenAuthentication, get_authorization_header
52-
from django.utils.encoding import smart_str as smart_text
52+
from django.utils.encoding import smart_str
5353
from django.utils.translation import gettext as _
5454
from bigvince.utils import get_cognito_url, get_cognito_pool_url
5555
import traceback
@@ -443,7 +443,7 @@ def authenticate(self, request):
443443
def get_jwt_token(self, request):
444444
logger.debug(f"Collected headers for JSONWwebToken as {request.headers}")
445445
auth = get_authorization_header(request).split()
446-
if not auth or smart_text(auth[0].lower()) != "bearer":
446+
if not auth or smart_str(auth[0].lower()) != "bearer":
447447
return None
448448

449449
if len(auth) == 1:

vince/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from vince.permissions import get_user_gen_queue
5656
import traceback
5757
import os
58-
from django.utils.encoding import smart_str as smart_text
58+
from django.utils.encoding import smart_str
5959

6060
logger = logging.getLogger(__name__)
6161
logger.setLevel(logging.DEBUG)
@@ -562,7 +562,7 @@ def save(self):
562562
logger.debug("IN FILE UPLOAD SAVE")
563563
# create the vincecommattachment
564564
if file.size:
565-
filename = smart_text(file.name)
565+
filename = smart_str(file.name)
566566
logger.debug(filename)
567567
try:
568568
mime_type = file.content_type

vince/lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from django.core.files import File
4949
from django.core.serializers.json import DjangoJSONEncoder
5050
from django.utils import timezone
51-
from django.utils.encoding import smart_str as smart_text
51+
from django.utils.encoding import smart_str
5252
from django.template.loader import render_to_string, get_template
5353
from vince.models import VulnerabilityCase
5454

@@ -287,7 +287,7 @@ def process_attachments(followup, attached_files):
287287
for attached in attached_files:
288288
logger.debug(attached)
289289
if attached.size:
290-
filename = smart_text(attached.name)
290+
filename = smart_str(attached.name)
291291
logger.debug(filename)
292292
try:
293293
mime_type = attached.content_type

vinny/forms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from django.core.exceptions import ValidationError
4242
import mimetypes
4343
import os
44-
from django.utils.encoding import smart_str as smart_text
44+
from django.utils.encoding import smart_str
4545
from vinny.settings import DEFAULT_USER_SETTINGS
4646
from django.urls import reverse, reverse_lazy
4747
import base64
@@ -591,7 +591,7 @@ def save(self, commit=True):
591591
file = self.cleaned_data["attachment"]
592592

593593
if file.size:
594-
filename = smart_text(file.name)
594+
filename = smart_str(file.name)
595595
logger.debug(filename)
596596
try:
597597
mime_type = file.content_type
@@ -636,7 +636,7 @@ def save(self, commit=True):
636636
file = self.cleaned_data["attachment"]
637637

638638
if file.size:
639-
filename = smart_text(file.name)
639+
filename = smart_str(file.name)
640640
logger.debug(filename)
641641
try:
642642
mime_type = file.content_type

vinny/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from django.utils.functional import cached_property
4949
from vinny.mailer import send_newmessage_mail
5050
from bigvince.storage_backends import PrivateMediaStorage, SharedMediaStorage
51-
from django.utils.encoding import smart_str as smart_text
51+
from django.utils.encoding import smart_str
5252
from lib.vince.m2crypto_encrypt_decrypt import ED
5353
import base64
5454
import os
@@ -1820,7 +1820,7 @@ def attach_file(cls, message, file):
18201820
"""
18211821

18221822
if file.size:
1823-
filename = smart_text(file.name)
1823+
filename = smart_str(file.name)
18241824
logger.debug(filename)
18251825
try:
18261826
mime_type = file.content_type

0 commit comments

Comments
 (0)