Replace basestring with six.string_types

https://wiki.openstack.org/wiki/Python3

Change-Id: I09ceb7c4819573f404359af5200e990b1e6070e2
This commit is contained in:
wangqi 2018-04-23 02:32:44 +00:00
parent e24a7e7db3
commit 26a42aeddf
3 changed files with 6 additions and 3 deletions

View File

@ -21,6 +21,7 @@ from webob import exc
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import timeutils from oslo_utils import timeutils
import six
from gceapi.api import clients from gceapi.api import clients
from gceapi.api import operation_api from gceapi.api import operation_api
@ -249,7 +250,7 @@ class Controller(object):
"""Returns standard format for given date.""" """Returns standard format for given date."""
if date_string is None: if date_string is None:
return None return None
if isinstance(date_string, basestring): if isinstance(date_string, six.string_types):
date_string = timeutils.parse_isotime(date_string) date_string = timeutils.parse_isotime(date_string)
return date_string.strftime('%Y-%m-%dT%H:%M:%SZ') return date_string.strftime('%Y-%m-%dT%H:%M:%SZ')

View File

@ -22,6 +22,7 @@
from oslo_context import context from oslo_context import context
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import timeutils from oslo_utils import timeutils
import six
from gceapi import exception from gceapi import exception
from gceapi.i18n import _ from gceapi.i18n import _
@ -72,7 +73,7 @@ class RequestContext(context.RequestContext):
self.remote_address = remote_address self.remote_address = remote_address
if not timestamp: if not timestamp:
timestamp = timeutils.utcnow() timestamp = timeutils.utcnow()
if isinstance(timestamp, basestring): if isinstance(timestamp, six.string_types):
timestamp = timeutils.parse_strtime(timestamp) timestamp = timeutils.parse_strtime(timestamp)
self.timestamp = timestamp self.timestamp = timestamp

View File

@ -32,6 +32,7 @@ import fixtures
import mox import mox
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
import six
import stubout import stubout
import testtools import testtools
@ -155,7 +156,7 @@ class TestCase(testtools.TestCase):
self.assertIn(k, d2) self.assertIn(k, d2)
v2 = d2[k] v2 = d2[k]
if(isinstance(v1, collections.Iterable) and if(isinstance(v1, collections.Iterable) and
not isinstance(v1, basestring)): not isinstance(v1, six.string_types)):
self.assertItemsEqual(v1, v2, msg) self.assertItemsEqual(v1, v2, msg)
else: else:
self.assertEqual(v1, v2, msg) self.assertEqual(v1, v2, msg)