python3: Use six.text_type instead direct unicode/str

This commit is contained in:
Tomas Babej 2016-12-16 03:40:42 +01:00
parent 91af39e17e
commit 29c6c1d29c
5 changed files with 12 additions and 6 deletions

View file

@ -3,6 +3,7 @@ Contains TaskWiki-specific exceptions.
"""
from __future__ import print_function
import six
import sys
@ -18,7 +19,7 @@ class TaskWikiException(VimPrettyException):
# Handle error without traceback, if they're descendants of VimPrettyException
def output_exception(exception_type, value, traceback):
if any(['VimPretty' in t.__name__ for t in exception_type.mro()]):
print(unicode(value), file=sys.stderr)
print(six.text_type(value), file=sys.stderr)
else:
sys.__excepthook__(exception_type, value, traceback)

View file

@ -2,6 +2,7 @@ from __future__ import print_function
import re
import os
import pickle
import six
import sys
import vim # pylint: disable=F0401
@ -255,8 +256,8 @@ class Meta(object):
port.sort,
len(port.matching_tasks),
len(port.tasks),
', '.join(map(unicode, to_add)),
', '.join(map(unicode, to_del)),
', '.join(map(six.text_type, to_add)),
', '.join(map(six.text_type, to_del)),
)
# Show in the split

View file

@ -1,8 +1,10 @@
import six
class ShortUUID(object):
def __init__(self, value, tw):
# Extract the UUID from the given object. Support both
# strings and ShortUUID instances.
if type(value) in (str, unicode):
if isinstance(value, six.string_types):
# Use str reprentation of the value, first 8 chars
self.value = str(value)[:8]
elif type(value) is ShortUUID:

View file

@ -1,4 +1,5 @@
import re
import six
import itertools
import vim # pylint: disable=F0401
from datetime import datetime

View file

@ -2,6 +2,7 @@
import os
import re
import six
import subprocess
import tempfile
import vimrunner
@ -29,8 +30,8 @@ class IntegrationTest(object):
def read_buffer(self, start=0, end=1000):
return self.client.read_buffer(
unicode(start+1),
unicode(end+1)
six.text_type(start+1),
six.text_type(end+1)
).splitlines()