From 15b2af47ae2670687119ec7ff2b4827661969496 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Tue, 10 Sep 2013 00:05:40 -0700 Subject: [PATCH] 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 --- taskflow/task.py | 3 ++- taskflow/utils/misc.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/taskflow/task.py b/taskflow/task.py index fb699645..787a346f 100644 --- a/taskflow/task.py +++ b/taskflow/task.py @@ -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). diff --git a/taskflow/utils/misc.py b/taskflow/utils/misc.py index f536d450..bb0547a0 100644 --- a/taskflow/utils/misc.py +++ b/taskflow/utils/misc.py @@ -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'):