]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Replace basestring with six.string_types
authorVictor Stinner <vstinner@redhat.com>
Wed, 10 Jun 2015 12:32:41 +0000 (14:32 +0200)
committerVictor Stinner <vstinner@redhat.com>
Tue, 16 Jun 2015 20:37:20 +0000 (22:37 +0200)
basestring type is gone in Python 3, use six.string_types to make Cinder code
compatible with Python 3.

This patch was generated by the basestring operation of the sixer tool:
https://pypi.python.org/pypi/sixer

Blueprint cinder-python3
Change-Id: Ie1aedf1cbb9d3e54a996321cd586b875e69ac85a

cinder/api/contrib/admin_actions.py
cinder/api/contrib/volume_actions.py
cinder/api/xmlutil.py
cinder/context.py
cinder/db/sqlalchemy/api.py
cinder/image/glance.py
cinder/quota.py
cinder/tests/unit/fake_utils.py
cinder/volume/drivers/ibm/storwize_svc/ssh.py
cinder/volume/drivers/violin/v6000_common.py

index 18bbabd461b7b0a1b623c4a96f597025d8783f08..3ef3511c5803ce0c9f2ca91c2343378987860664 100644 (file)
@@ -15,6 +15,7 @@
 from oslo_log import log as logging
 import oslo_messaging as messaging
 from oslo_utils import strutils
+import six
 import webob
 from webob import exc
 
@@ -222,7 +223,7 @@ class VolumeAdminController(AdminController):
         except KeyError:
             raise exc.HTTPBadRequest(explanation=_("Must specify 'host'"))
         force_host_copy = params.get('force_host_copy', False)
-        if isinstance(force_host_copy, basestring):
+        if isinstance(force_host_copy, six.string_types):
             try:
                 force_host_copy = strutils.bool_from_string(force_host_copy,
                                                             strict=True)
index b67970cd8ce45075302e05bafb8bb942874d9c24..d6c88309df1bfdceb30aa2cb389d9e8366594351 100644 (file)
@@ -266,7 +266,7 @@ class VolumeActionsController(wsgi.Controller):
             raise webob.exc.HTTPBadRequest(explanation=msg)
 
         force = params.get('force', False)
-        if isinstance(force, basestring):
+        if isinstance(force, six.string_types):
             try:
                 force = strutils.bool_from_string(force, strict=False)
             except ValueError:
@@ -337,7 +337,7 @@ class VolumeActionsController(wsgi.Controller):
             msg = _("Must specify readonly in request.")
             raise webob.exc.HTTPBadRequest(explanation=msg)
 
-        if isinstance(readonly_flag, basestring):
+        if isinstance(readonly_flag, six.string_types):
             try:
                 readonly_flag = strutils.bool_from_string(readonly_flag,
                                                           strict=True)
@@ -382,7 +382,7 @@ class VolumeActionsController(wsgi.Controller):
             msg = _("Must specify bootable in request.")
             raise webob.exc.HTTPBadRequest(explanation=msg)
 
-        if isinstance(bootable, basestring):
+        if isinstance(bootable, six.string_types):
             try:
                 bootable = strutils.bool_from_string(bootable,
                                                      strict=True)
index a867555fa1dff70ccfc3b6ac892defc2c677ba9d..831242c84930b62bfb7b918728bda70f7c5b2ab0 100644 (file)
@@ -208,7 +208,7 @@ class TemplateElement(object):
     def __getitem__(self, idx):
         """Retrieve a child node by index or name."""
 
-        if isinstance(idx, basestring):
+        if isinstance(idx, six.string_types):
             # Allow access by node name
             return self._childmap[idx]
         else:
index 774769cd733d91a3463ea5b3b75c7bb0bd32c372..23edc03d802e9e0ff334d6f594610ccbc5d843ca 100644 (file)
@@ -22,6 +22,7 @@ import copy
 from oslo_context import context
 from oslo_log import log as logging
 from oslo_utils import timeutils
+import six
 
 from cinder.i18n import _
 from cinder import policy
@@ -69,7 +70,7 @@ class RequestContext(context.RequestContext):
         self.remote_address = remote_address
         if not timestamp:
             timestamp = timeutils.utcnow()
-        elif isinstance(timestamp, basestring):
+        elif isinstance(timestamp, six.string_types):
             timestamp = timeutils.parse_isotime(timestamp)
         self.timestamp = timestamp
         self.quota_class = quota_class
index 1b0941675be3dfe0adba9496f8e8bf8793968571..b0536c889b56f82fffc9f3f9ad51388c641adf1c 100644 (file)
@@ -1387,7 +1387,7 @@ def volume_get_all_by_host(context, host, filters=None):
     # now be either form below:
     #     Host
     #     Host#Pool
-    if host and isinstance(host, basestring):
+    if host and isinstance(host, six.string_types):
         session = get_session()
         with session.begin():
             host_attr = getattr(models.Volume, 'host')
index 893e1ab3c88ebd0d2d250e16b628ca16580001fc..be32766b612b6e6da63e7a6a75e59b1dfe5c65d3 100644 (file)
@@ -400,13 +400,13 @@ def _convert_timestamps_to_datetimes(image_meta):
 # NOTE(bcwaldon): used to store non-string data in glance metadata
 def _json_loads(properties, attr):
     prop = properties[attr]
-    if isinstance(prop, basestring):
+    if isinstance(prop, six.string_types):
         properties[attr] = jsonutils.loads(prop)
 
 
 def _json_dumps(properties, attr):
     prop = properties[attr]
-    if not isinstance(prop, basestring):
+    if not isinstance(prop, six.string_types):
         properties[attr] = jsonutils.dumps(prop)
 
 
index 808710f786a0aa5dd2830c2596f5cfb09268ab5d..ae886110c9771dc8aa18f84d4c3d2d3ee294c8d6 100644 (file)
@@ -23,6 +23,7 @@ from oslo_config import cfg
 from oslo_log import log as logging
 from oslo_utils import importutils
 from oslo_utils import timeutils
+import six
 
 from cinder import context
 from cinder import db
@@ -593,7 +594,7 @@ class QuotaEngine(object):
         if not quota_driver_class:
             quota_driver_class = CONF.quota_driver
 
-        if isinstance(quota_driver_class, basestring):
+        if isinstance(quota_driver_class, six.string_types):
             quota_driver_class = importutils.import_object(quota_driver_class)
 
         self._resources = {}
index 26b5cba07f61619e794225152ba95881cc5cccd4..885f473e42da9fe101d0380321da646fa403e89f 100644 (file)
@@ -19,6 +19,7 @@ import re
 from eventlet import greenthread
 from oslo_concurrency import processutils
 from oslo_log import log as logging
+import six
 
 from cinder import utils
 
@@ -78,7 +79,7 @@ def fake_execute(*cmd_parts, **kwargs):
             LOG.debug('Faked command matched %s' % fake_replier[0])
             break
 
-    if isinstance(reply_handler, basestring):
+    if isinstance(reply_handler, six.string_types):
         # If the reply handler is a string, return it as stdout
         reply = reply_handler, ''
     else:
index ae8d91bae6ba8ba63c0c69e2783322ba808158eb..15c6e384ba0de7985b6f7270d567a726a7725c4c 100644 (file)
@@ -18,6 +18,7 @@ import re
 
 from oslo_concurrency import processutils
 from oslo_log import log as logging
+import six
 
 from cinder import exception
 from cinder.i18n import _, _LE
@@ -380,7 +381,7 @@ class CLIResponse(object):
             vs = []
             for k in keys:
                 v = a.get(k, None)
-                if isinstance(v, basestring) or v is None:
+                if isinstance(v, six.string_types) or v is None:
                     v = [v]
                 if isinstance(v, list):
                     vs.append(v)
@@ -414,7 +415,7 @@ class CLIResponse(object):
                 else:
                     yield []
 
-        if isinstance(self.raw, basestring):
+        if isinstance(self.raw, six.string_types):
             stdout, stderr = self.raw, ''
         else:
             stdout, stderr = self.raw
index c14dbfd9a5a4f8c79fc0b0515051b191da84dcfe..b0e8d67eb48c9ac74ff1c7d8548fde37d3f90104 100644 (file)
@@ -34,6 +34,7 @@ import time
 from oslo_config import cfg
 from oslo_log import log as logging
 from oslo_utils import importutils
+import six
 
 from cinder import exception
 from cinder.i18n import _, _LE, _LW, _LI
@@ -375,7 +376,7 @@ class V6000Common(object):
         start = time.time()
         done = False
 
-        if isinstance(success_msgs, basestring):
+        if isinstance(success_msgs, six.string_types):
             success_msgs = [success_msgs]
 
         while not done:
@@ -435,7 +436,7 @@ class V6000Common(object):
         request_needed = True
         verify_needed = True
 
-        if isinstance(request_success_msgs, basestring):
+        if isinstance(request_success_msgs, six.string_types):
             request_success_msgs = [request_success_msgs]
 
         rargs = rargs if rargs else []