python3: replace unicode type (#40570)
This commit is contained in:
parent
45c0a44e89
commit
8a9769eb4d
|
@ -24,6 +24,7 @@ import psycopg2
|
|||
|
||||
from django.core.cache import cache
|
||||
from django.conf import settings
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from . import schemas
|
||||
|
@ -42,10 +43,10 @@ class DimensionCell(collections.namedtuple('_Cell', ['dimension', 'value', 'valu
|
|||
elif self.dimension.type == 'bool':
|
||||
return _('Yes') if self.value else _('No')
|
||||
else:
|
||||
return unicode(self.value)
|
||||
return force_text(self.value)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.label)
|
||||
return force_text(self.label)
|
||||
|
||||
|
||||
class MeasureCell(collections.namedtuple('_Cell', ['measure', 'value'])):
|
||||
|
@ -82,12 +83,12 @@ class MeasureCell(collections.namedtuple('_Cell', ['measure', 'value'])):
|
|||
if value is None:
|
||||
return '0'
|
||||
else:
|
||||
return unicode(value)
|
||||
return force_text(value)
|
||||
else:
|
||||
raise NotImplementedError('unknown type %s' % self.measure.type)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.label)
|
||||
return force_text(self.label)
|
||||
|
||||
|
||||
class Cells(collections.namedtuple('Cells', ['dimensions', 'measures'])):
|
||||
|
@ -200,7 +201,7 @@ class EngineDimension(object):
|
|||
for row in cursor.fetchall():
|
||||
if row[0] is None:
|
||||
continue
|
||||
members.append(Member(id=row[0], label=unicode(row[1])))
|
||||
members.append(Member(id=row[0], label=force_text(row[1])))
|
||||
cache.set(cache_key, members, 600)
|
||||
self.engine.log.debug('MEMBERS: dimension %s.%s filters=%s: %s',
|
||||
self.engine_cube.name, self.name, filters,
|
||||
|
|
|
@ -21,6 +21,7 @@ import decimal
|
|||
import collections
|
||||
|
||||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
@ -119,7 +120,7 @@ class Base(object):
|
|||
if isinstance(v, list):
|
||||
v = [x.to_json() if hasattr(x, 'to_json') else x for x in v]
|
||||
if isinstance(v, Promise):
|
||||
v = unicode(v)
|
||||
v = force_text(v)
|
||||
d[attr] = v
|
||||
return d
|
||||
|
||||
|
@ -132,7 +133,7 @@ class Measure(Base):
|
|||
__slots__ = ['name', 'label', 'type', 'expression']
|
||||
__types__ = {
|
||||
'name': str,
|
||||
'label': unicode,
|
||||
'label': six.text_type,
|
||||
'type': type_cast,
|
||||
'expression': str,
|
||||
}
|
||||
|
@ -150,7 +151,7 @@ class Dimension(Base):
|
|||
'filter_needs_join', 'filter_expression', 'absent_label']
|
||||
__types__ = {
|
||||
'name': str,
|
||||
'label': unicode,
|
||||
'label': six.text_type,
|
||||
'type': str,
|
||||
'join': [str],
|
||||
'value': str,
|
||||
|
@ -163,7 +164,7 @@ class Dimension(Base):
|
|||
'filter_in_join': bool,
|
||||
'filter_value': str,
|
||||
'filter_needs_join': bool,
|
||||
'absent_label': unicode,
|
||||
'absent_label': six.text_type,
|
||||
}
|
||||
|
||||
label = None
|
||||
|
@ -358,7 +359,7 @@ class Cube(Base):
|
|||
'measures', 'warnings']
|
||||
__types__ = {
|
||||
'name': str,
|
||||
'label': unicode,
|
||||
'label': six.text_type,
|
||||
'fact_table': str,
|
||||
'json_field': str,
|
||||
'key': str,
|
||||
|
@ -415,7 +416,7 @@ class Warehouse(Base):
|
|||
__types__ = {
|
||||
'name': str,
|
||||
'slug': str,
|
||||
'label': unicode,
|
||||
'label': six.text_type,
|
||||
'pg_dsn': str,
|
||||
'search_path': [str],
|
||||
'cubes': [Cube],
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils import six
|
||||
from django.forms import ModelForm, TextInput, NullBooleanField
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -187,7 +187,7 @@ class CubeForm(forms.Form):
|
|||
else:
|
||||
members = []
|
||||
for _id, label in dimension.members():
|
||||
members.append((_id, six.text_type(_id), label))
|
||||
members.append((_id, force_text(_id), label))
|
||||
members.append((None, '__none__', _('None')))
|
||||
|
||||
def coercion_function(members):
|
||||
|
|
|
@ -25,9 +25,9 @@ import copy
|
|||
import collections
|
||||
|
||||
from django.core.cache import cache
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils import six
|
||||
from django.http import Http404
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -144,10 +144,10 @@ class Visualization(object):
|
|||
# multiple values
|
||||
if isinstance(value, dict):
|
||||
value = value.items()
|
||||
keys.append('$'.join([kw] + sorted(map(six.text_type, value))))
|
||||
keys.append('$'.join([kw] + sorted(map(force_text, value))))
|
||||
else:
|
||||
# scalar values
|
||||
keys.append(u'%s$%s' % (kw, six.text_type(value)))
|
||||
keys.append(u'%s$%s' % (kw, force_text(value)))
|
||||
keys += [dim.name for dim in self.drilldown]
|
||||
keys += [self.measure.name]
|
||||
key = '$'.join(v.encode('utf8') for v in keys)
|
||||
|
|
Loading…
Reference in New Issue