kopia lustrzana https://github.com/wagtail/wagtail
Eliminate references to django.utils.six.text_type
rodzic
a2dc9926fd
commit
089eddc47a
|
@ -3,14 +3,13 @@ from __future__ import absolute_import, unicode_literals
|
|||
import random
|
||||
|
||||
from django.db import models
|
||||
from django.utils.six import text_type
|
||||
|
||||
LOWER_BOUND = -2147483648
|
||||
UPPER_BOUND = 2147483647
|
||||
SHIFT = 92147483647
|
||||
|
||||
|
||||
class ConvertedValue(text_type):
|
||||
class ConvertedValue(str):
|
||||
def __new__(cls, value):
|
||||
value = int(value)
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import json
|
|||
|
||||
from django.db import connections
|
||||
from django.test import TestCase
|
||||
from django.utils.six import text_type
|
||||
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
|
||||
|
@ -21,7 +20,7 @@ class TestConvertedValueField(TestCase, WagtailTestUtils):
|
|||
|
||||
def test_db_value_is_different(self):
|
||||
self.assertEqual(self.user.pk, self.pk_db_value)
|
||||
self.assertNotEqual(text_type(self.user.pk), text_type(self.pk_db_value))
|
||||
self.assertNotEqual(str(self.user.pk), str(self.pk_db_value))
|
||||
|
||||
def test_custom_user_primary_key_is_hashable(self):
|
||||
hash(self.user.pk)
|
||||
|
|
|
@ -12,7 +12,6 @@ from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
|
|||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db import models
|
||||
from django.shortcuts import render
|
||||
from django.utils.six import text_type
|
||||
from modelcluster.contrib.taggit import ClusterTaggableManager
|
||||
from modelcluster.fields import ParentalKey, ParentalManyToManyField
|
||||
from modelcluster.models import ClusterableModel
|
||||
|
@ -463,7 +462,7 @@ class FormPageWithCustomSubmission(AbstractEmailForm):
|
|||
|
||||
if self.to_address:
|
||||
addresses = [x.strip() for x in self.to_address.split(',')]
|
||||
content = '\n'.join([x[1].label + ': ' + text_type(form.data.get(x[0])) for x in form.fields.items()])
|
||||
content = '\n'.join([x[1].label + ': ' + str(form.data.get(x[0])) for x in form.fields.items()])
|
||||
send_mail(self.subject, content, addresses, self.from_address,)
|
||||
|
||||
def serve(self, request, *args, **kwargs):
|
||||
|
|
|
@ -45,9 +45,7 @@ class assets_mixin(object):
|
|||
|
||||
try:
|
||||
with io.open(path, 'w', encoding='utf-8') as f:
|
||||
from django.utils import six
|
||||
|
||||
f.write(six.text_type(json.dumps(package, indent=2, ensure_ascii=False)))
|
||||
f.write(str(json.dumps(package, indent=2, ensure_ascii=False)))
|
||||
except (IOError) as e:
|
||||
print('Error setting the version for front-end assets: ' + str(e)) # noqa
|
||||
raise SystemExit(1)
|
||||
|
|
|
@ -10,7 +10,6 @@ from django.forms.models import fields_for_model
|
|||
from django.template.loader import render_to_string
|
||||
from django.utils.functional import curry
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.six import text_type
|
||||
from django.utils.translation import ugettext_lazy
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
|
@ -188,7 +187,7 @@ class EditHandler(object):
|
|||
"""
|
||||
rendered_fields = self.required_fields()
|
||||
missing_fields_html = [
|
||||
text_type(self.form[field_name])
|
||||
str(self.form[field_name])
|
||||
for field_name in self.form.fields
|
||||
if field_name not in rendered_fields
|
||||
]
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.forms import Media, MediaDefiningClass
|
|||
from django.forms.utils import flatatt
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.six import text_type, with_metaclass
|
||||
from django.utils.six import with_metaclass
|
||||
from django.utils.text import slugify
|
||||
|
||||
from wagtail.wagtailcore import hooks
|
||||
|
@ -18,7 +18,7 @@ class MenuItem(with_metaclass(MediaDefiningClass)):
|
|||
self.label = label
|
||||
self.url = url
|
||||
self.classnames = classnames
|
||||
self.name = (name or slugify(text_type(label)))
|
||||
self.name = (name or slugify(str(label)))
|
||||
self.order = order
|
||||
|
||||
if attrs:
|
||||
|
@ -34,7 +34,7 @@ class MenuItem(with_metaclass(MediaDefiningClass)):
|
|||
return True
|
||||
|
||||
def is_active(self, request):
|
||||
return request.path.startswith(text_type(self.url))
|
||||
return request.path.startswith(str(self.url))
|
||||
|
||||
def get_context(self, request):
|
||||
"""Defines context for the template, overridable to use more data"""
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.forms.utils import flatatt
|
|||
from django.template.loader import render_to_string
|
||||
from django.utils.functional import cached_property, total_ordering
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.six import text_type, with_metaclass
|
||||
from django.utils.six import with_metaclass
|
||||
from django.utils.text import slugify
|
||||
|
||||
from wagtail.wagtailadmin.forms import SearchForm
|
||||
|
@ -20,7 +20,7 @@ class SearchArea(with_metaclass(MediaDefiningClass)):
|
|||
self.label = label
|
||||
self.url = url
|
||||
self.classnames = classnames
|
||||
self.name = (name or slugify(text_type(label)))
|
||||
self.name = (name or slugify(str(label)))
|
||||
self.order = order
|
||||
|
||||
if attrs:
|
||||
|
|
|
@ -6,7 +6,6 @@ from django import forms
|
|||
from django.db.models.fields import BLANK_CHOICE_DASH
|
||||
from django.forms.fields import CallableChoiceIterator
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils import six
|
||||
from django.utils.dateparse import parse_date, parse_datetime, parse_time
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import cached_property
|
||||
|
@ -515,11 +514,11 @@ class RawHTMLBlock(FieldBlock):
|
|||
def get_prep_value(self, value):
|
||||
# explicitly convert to a plain string, just in case we're using some serialisation method
|
||||
# that doesn't cope with SafeText values correctly
|
||||
return six.text_type(value)
|
||||
return str(value)
|
||||
|
||||
def value_for_form(self, value):
|
||||
# need to explicitly mark as unsafe, or it'll output unescaped HTML in the textarea
|
||||
return six.text_type(value)
|
||||
return str(value)
|
||||
|
||||
def value_from_form(self, value):
|
||||
return mark_safe(value)
|
||||
|
|
|
@ -1518,7 +1518,7 @@ class PageRevision(models.Model):
|
|||
return self.get_next_by_created_at(page=self.page)
|
||||
|
||||
def __str__(self):
|
||||
return '"' + six.text_type(self.page) + '" at ' + six.text_type(self.created_at)
|
||||
return '"' + str(self.page) + '" at ' + str(self.created_at)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('page revision')
|
||||
|
|
|
@ -8,7 +8,6 @@ from django.db import models
|
|||
from django.template import Context, Template, engines
|
||||
from django.test import TestCase
|
||||
from django.utils.safestring import SafeText
|
||||
from django.utils.six import text_type
|
||||
|
||||
from wagtail.tests.testapp.models import StreamModel
|
||||
from wagtail.wagtailcore import blocks
|
||||
|
@ -189,7 +188,7 @@ class TestStreamFieldRenderingBase(TestCase):
|
|||
|
||||
class TestStreamFieldRendering(TestStreamFieldRenderingBase):
|
||||
def test_to_string(self):
|
||||
rendered = text_type(self.instance.body)
|
||||
rendered = str(self.instance.body)
|
||||
self.assertHTMLEqual(rendered, self.expected)
|
||||
self.assertIsInstance(rendered, SafeText)
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.core.serializers.json import DjangoJSONEncoder
|
||||
from django.db import models
|
||||
from django.shortcuts import render
|
||||
from django.utils.six import text_type
|
||||
from django.utils.text import slugify
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from unidecode import unidecode
|
||||
|
@ -104,7 +103,7 @@ class AbstractFormField(Orderable):
|
|||
# unidecode will return an ascii string while slugify wants a
|
||||
# unicode string on the other hand, slugify returns a safe-string
|
||||
# which will be converted to a normal str
|
||||
return str(slugify(text_type(unidecode(self.label))))
|
||||
return str(slugify(str(unidecode(self.label))))
|
||||
|
||||
panels = [
|
||||
FieldPanel('label'),
|
||||
|
|
|
@ -14,7 +14,7 @@ from django.forms.utils import flatatt
|
|||
from django.urls import reverse
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.six import BytesIO, string_types, text_type
|
||||
from django.utils.six import BytesIO, string_types
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from taggit.managers import TaggableManager
|
||||
from unidecode import unidecode
|
||||
|
@ -168,7 +168,7 @@ class AbstractImage(CollectionMember, index.Indexed, models.Model):
|
|||
except IOError as e:
|
||||
# re-throw this as a SourceImageIOError so that calling code can distinguish
|
||||
# these from IOErrors elsewhere in the process
|
||||
raise SourceImageIOError(text_type(e))
|
||||
raise SourceImageIOError(str(e))
|
||||
|
||||
# Seek to beginning
|
||||
image_file.seek(0)
|
||||
|
|
|
@ -11,7 +11,6 @@ from django.core.exceptions import ImproperlyConfigured, PermissionDenied
|
|||
from django.http import HttpResponse, HttpResponsePermanentRedirect, StreamingHttpResponse
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.decorators import classonlymethod
|
||||
from django.utils.six import text_type
|
||||
from django.views.generic import View
|
||||
|
||||
from wagtail.utils.sendfile import sendfile
|
||||
|
@ -25,7 +24,7 @@ def generate_signature(image_id, filter_spec, key=None):
|
|||
key = settings.SECRET_KEY
|
||||
|
||||
# Key must be a bytes object
|
||||
if isinstance(key, text_type):
|
||||
if isinstance(key, str):
|
||||
key = key.encode()
|
||||
|
||||
# Based on libthumbor hmac generation
|
||||
|
|
|
@ -4,7 +4,6 @@ from __future__ import absolute_import, unicode_literals
|
|||
from django.db.models.lookups import Lookup
|
||||
from django.db.models.query import QuerySet
|
||||
from django.db.models.sql.where import SubqueryConstraint, WhereNode
|
||||
from django.utils.six import text_type
|
||||
|
||||
from wagtail.wagtailsearch.index import class_is_indexed
|
||||
|
||||
|
@ -58,7 +57,7 @@ class BaseSearchQuery(object):
|
|||
if result is None:
|
||||
raise FilterError(
|
||||
'Could not apply filter on search results: "' + field_attname + '__' +
|
||||
lookup + ' = ' + text_type(value) + '". Lookup "' + lookup + '"" not recognised.'
|
||||
lookup + ' = ' + str(value) + '". Lookup "' + lookup + '"" not recognised.'
|
||||
)
|
||||
|
||||
return result
|
||||
|
|
|
@ -4,7 +4,6 @@ import json
|
|||
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.urls import reverse
|
||||
from django.utils.six import text_type
|
||||
from django.utils.translation import ugettext as _
|
||||
|
||||
from wagtail.utils.pagination import paginate
|
||||
|
@ -78,7 +77,7 @@ def chosen(request, app_label, model_name, id):
|
|||
|
||||
snippet_json = json.dumps({
|
||||
'id': item.id,
|
||||
'string': text_type(item),
|
||||
'string': str(item),
|
||||
'edit_link': reverse('wagtailsnippets:edit', args=(
|
||||
app_label, model_name, item.id))
|
||||
})
|
||||
|
|
Ładowanie…
Reference in New Issue