Use six string types instead of basestring
To increase our python3 compatability we should attempt to use the six module for known issues that are likely to happen in python3 when comparing to string types. Change-Id: Ib6fc32138e218c8b45023ca37d87b742694b8349
This commit is contained in:
committed by
Ivan A. Melnikov
parent
d523d3651d
commit
15b2af47ae
@@ -18,6 +18,7 @@
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
import six
|
||||
|
||||
from taskflow.utils import misc
|
||||
from taskflow.utils import reflection
|
||||
@@ -33,7 +34,7 @@ def _save_as_to_mapping(save_as):
|
||||
# returns is pretty crucial for other later operations.
|
||||
if save_as is None:
|
||||
return {}
|
||||
if isinstance(save_as, basestring):
|
||||
if isinstance(save_as, six.string_types):
|
||||
# NOTE(harlowja): this means that your task will only return one item
|
||||
# instead of a dictionary-like object or a indexable object (like a
|
||||
# list or tuple).
|
||||
|
||||
@@ -22,9 +22,9 @@ from distutils import version
|
||||
import collections
|
||||
import copy
|
||||
import logging
|
||||
import six
|
||||
import sys
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ def get_task_version(task):
|
||||
task_version = getattr(task, 'version')
|
||||
if isinstance(task_version, (list, tuple)):
|
||||
task_version = '.'.join(str(item) for item in task_version)
|
||||
if task_version is not None and not isinstance(task_version, basestring):
|
||||
if task_version is not None and not isinstance(task_version,
|
||||
six.string_types):
|
||||
task_version = str(task_version)
|
||||
return task_version
|
||||
|
||||
@@ -56,7 +57,7 @@ class ExponentialBackoff(object):
|
||||
def as_bool(val):
|
||||
if isinstance(val, bool):
|
||||
return val
|
||||
if isinstance(val, basestring):
|
||||
if isinstance(val, six.string_types):
|
||||
if val.lower() in ('f', 'false', '0', 'n', 'no'):
|
||||
return False
|
||||
if val.lower() in ('t', 'true', '1', 'y', 'yes'):
|
||||
|
||||
Reference in New Issue
Block a user