mirror of https://github.com/zulip/zulip.git
Apply Python 3 futurize transform libmodernize.fixes.fix_unicode_type.
This commit is contained in:
parent
607eedfc25
commit
33295180a9
|
@ -21,6 +21,7 @@
|
||||||
# THE SOFTWARE.
|
# THE SOFTWARE.
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
from __future__ import absolute_import
|
||||||
import simplejson
|
import simplejson
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
@ -36,6 +37,7 @@ from distutils.version import LooseVersion
|
||||||
|
|
||||||
from six.moves.configparser import SafeConfigParser
|
from six.moves.configparser import SafeConfigParser
|
||||||
import logging
|
import logging
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
__version__ = "0.2.4"
|
__version__ = "0.2.4"
|
||||||
|
@ -244,7 +246,7 @@ class Client(object):
|
||||||
request = {}
|
request = {}
|
||||||
|
|
||||||
for (key, val) in orig_request.iteritems():
|
for (key, val) in orig_request.iteritems():
|
||||||
if not (isinstance(val, str) or isinstance(val, unicode)):
|
if not (isinstance(val, str) or isinstance(val, six.text_type)):
|
||||||
request[key] = simplejson.dumps(val)
|
request[key] = simplejson.dumps(val)
|
||||||
else:
|
else:
|
||||||
request[key] = val
|
request[key] = val
|
||||||
|
|
|
@ -83,7 +83,7 @@ def der_encode_uint32(val):
|
||||||
return der_encode_integer(val)
|
return der_encode_integer(val)
|
||||||
|
|
||||||
def der_encode_string(val):
|
def der_encode_string(val):
|
||||||
if not isinstance(val, unicode):
|
if not isinstance(val, six.text_type):
|
||||||
raise TypeError("unicode")
|
raise TypeError("unicode")
|
||||||
return der_encode_tlv(0x1b, val.encode("utf-8"))
|
return der_encode_tlv(0x1b, val.encode("utf-8"))
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import ujson
|
||||||
|
|
||||||
from zerver.lib.rest import rest_dispatch as _rest_dispatch
|
from zerver.lib.rest import rest_dispatch as _rest_dispatch
|
||||||
from six.moves import map
|
from six.moves import map
|
||||||
|
import six
|
||||||
rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs)))
|
rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs)))
|
||||||
|
|
||||||
# This is a Pool that doesn't close connections. Therefore it can be used with
|
# This is a Pool that doesn't close connections. Therefore it can be used with
|
||||||
|
@ -292,7 +293,7 @@ class NarrowBuilder(object):
|
||||||
return query.where(maybe_negate(cond))
|
return query.where(maybe_negate(cond))
|
||||||
|
|
||||||
def highlight_string(string, locs):
|
def highlight_string(string, locs):
|
||||||
if isinstance(string, unicode):
|
if isinstance(string, six.text_type):
|
||||||
string = string.encode('utf-8')
|
string = string.encode('utf-8')
|
||||||
|
|
||||||
highlight_start = '<span class="highlight">'
|
highlight_start = '<span class="highlight">'
|
||||||
|
@ -326,7 +327,7 @@ def narrow_parameter(json):
|
||||||
# We have to support a legacy tuple format.
|
# We have to support a legacy tuple format.
|
||||||
if isinstance(elem, list):
|
if isinstance(elem, list):
|
||||||
if (len(elem) != 2
|
if (len(elem) != 2
|
||||||
or any(not isinstance(x, str) and not isinstance(x, unicode)
|
or any(not isinstance(x, str) and not isinstance(x, six.text_type)
|
||||||
for x in elem)):
|
for x in elem)):
|
||||||
raise ValueError("element is not a string pair")
|
raise ValueError("element is not a string pair")
|
||||||
return dict(operator=elem[0], operand=elem[1])
|
return dict(operator=elem[0], operand=elem[1])
|
||||||
|
|
Loading…
Reference in New Issue