Remove six.binary_type/integer_types/string_types
Replace the following items with Python 3 style code. - six.binary_type - six.integer_types - six.string_types Subsequent patches will replace other six usages. Change-Id: Ide65686cf02463045f5c32771ca949802b19636f Implements: blueprint six-removal Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
parent
f851d20b65
commit
07462dd005
@ -174,9 +174,9 @@ class MetadataRequestHandler(wsgi.Application):
|
||||
msg = _('X-Instance-ID-Signature header is missing from request.')
|
||||
elif tenant_id is None:
|
||||
msg = _('X-Tenant-ID header is missing from request.')
|
||||
elif not isinstance(instance_id, six.string_types):
|
||||
elif not isinstance(instance_id, str):
|
||||
msg = _('Multiple X-Instance-ID headers found within request.')
|
||||
elif not isinstance(tenant_id, six.string_types):
|
||||
elif not isinstance(tenant_id, str):
|
||||
msg = _('Multiple X-Tenant-ID headers found within request.')
|
||||
else:
|
||||
msg = None
|
||||
|
@ -44,7 +44,7 @@ class FlavorExtraSpecsController(wsgi.Controller):
|
||||
# NOTE(gmann): Max length for numeric value is being checked
|
||||
# explicitly as json schema cannot have max length check for
|
||||
# numeric value
|
||||
if isinstance(value, (six.integer_types, float)):
|
||||
if isinstance(value, (int, float)):
|
||||
value = six.text_type(value)
|
||||
try:
|
||||
utils.check_string_length(value, 'extra_specs value',
|
||||
|
@ -15,7 +15,6 @@
|
||||
# under the License.
|
||||
|
||||
import functools
|
||||
import six
|
||||
|
||||
import nova.api.openstack
|
||||
from nova.api.openstack.compute import admin_actions
|
||||
@ -866,7 +865,7 @@ class APIRouterV21(base_wsgi.Router):
|
||||
# For example, the request to the '' will be redirect to the '/' in
|
||||
# the Nova API. To indicate that, using the target path instead of
|
||||
# a dict. The route entry just writes as "('', '/)".
|
||||
if isinstance(methods, six.string_types):
|
||||
if isinstance(methods, str):
|
||||
self.map.redirect(path, methods)
|
||||
continue
|
||||
|
||||
|
@ -405,7 +405,7 @@ class ServersController(wsgi.Controller):
|
||||
# Starting in the 2.37 microversion, requested_networks is either a
|
||||
# list or a string enum with value 'auto' or 'none'. The auto/none
|
||||
# values are verified via jsonschema so we don't check them again here.
|
||||
if isinstance(requested_networks, six.string_types):
|
||||
if isinstance(requested_networks, str):
|
||||
return objects.NetworkRequestList(
|
||||
objects=[objects.NetworkRequest(
|
||||
network_id=requested_networks)])
|
||||
|
@ -21,7 +21,6 @@ import argparse
|
||||
import traceback
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
import nova.conf
|
||||
import nova.db.api
|
||||
@ -168,7 +167,7 @@ def get_action_fn():
|
||||
fn = CONF.category.action_fn
|
||||
fn_args = []
|
||||
for arg in CONF.category.action_args:
|
||||
if isinstance(arg, six.binary_type):
|
||||
if isinstance(arg, bytes):
|
||||
arg = arg.decode('utf-8')
|
||||
fn_args.append(arg)
|
||||
|
||||
@ -177,7 +176,7 @@ def get_action_fn():
|
||||
v = getattr(CONF.category, 'action_kwarg_' + k)
|
||||
if v is None:
|
||||
continue
|
||||
if isinstance(v, six.binary_type):
|
||||
if isinstance(v, bytes):
|
||||
v = v.decode('utf-8')
|
||||
fn_kwargs[k] = v
|
||||
|
||||
|
@ -160,7 +160,7 @@ class DbCommands(object):
|
||||
v = six.text_type(v)
|
||||
# if value has a newline, add in multiple rows
|
||||
# e.g. fault with stacktrace
|
||||
if v and isinstance(v, six.string_types) and r'\n' in v:
|
||||
if v and isinstance(v, str) and r'\n' in v:
|
||||
lines = v.strip().split(r'\n')
|
||||
col1 = k
|
||||
for line in lines:
|
||||
|
@ -2861,7 +2861,7 @@ class API(base.Base):
|
||||
else:
|
||||
# Remaps are strings to translate to, or functions to call
|
||||
# to do the translating as defined by the table above.
|
||||
if isinstance(remap_object, six.string_types):
|
||||
if isinstance(remap_object, str):
|
||||
filters[remap_object] = value
|
||||
else:
|
||||
try:
|
||||
|
@ -78,7 +78,7 @@ def create(name, memory, vcpus, root_gb, ephemeral_gb=0, flavorid=None,
|
||||
'description': description
|
||||
}
|
||||
|
||||
if isinstance(name, six.string_types):
|
||||
if isinstance(name, str):
|
||||
name = name.strip()
|
||||
|
||||
# NOTE(vish): Internally, flavorid is stored as a string but it comes
|
||||
|
@ -139,7 +139,7 @@ class RFBSecurityProxy(base.SecurityProxy):
|
||||
f = recv(compute_sock, permitted_auth_types_cnt)
|
||||
permitted_auth_types = []
|
||||
for auth_type in f:
|
||||
if isinstance(auth_type, six.string_types):
|
||||
if isinstance(auth_type, str):
|
||||
auth_type = ord(auth_type)
|
||||
permitted_auth_types.append(auth_type)
|
||||
|
||||
|
@ -27,7 +27,6 @@ from urllib import parse as urlparse
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
import websockify
|
||||
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
@ -66,7 +65,7 @@ class TenantSock(object):
|
||||
# flatten frames onto queue
|
||||
for frame in new_frames:
|
||||
self.queue.extend(
|
||||
[six.binary_type(chr(c), 'ascii') for c in frame])
|
||||
[bytes(chr(c), 'ascii') for c in frame])
|
||||
|
||||
if closed:
|
||||
break
|
||||
|
@ -28,7 +28,6 @@ from oslo_context import context
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
@ -107,7 +106,7 @@ class RequestContext(context.RequestContext):
|
||||
self.remote_address = remote_address
|
||||
if not timestamp:
|
||||
timestamp = timeutils.utcnow()
|
||||
if isinstance(timestamp, six.string_types):
|
||||
if isinstance(timestamp, str):
|
||||
timestamp = timeutils.parse_strtime(timestamp)
|
||||
self.timestamp = timestamp
|
||||
|
||||
|
@ -308,7 +308,7 @@ def convert_objects_related_datetimes(values, *datetime_keys):
|
||||
|
||||
for key in datetime_keys:
|
||||
if key in values and values[key]:
|
||||
if isinstance(values[key], six.string_types):
|
||||
if isinstance(values[key], str):
|
||||
try:
|
||||
values[key] = timeutils.parse_strtime(values[key])
|
||||
except ValueError:
|
||||
@ -1810,7 +1810,7 @@ def _regex_instance_filter(query, filters):
|
||||
continue
|
||||
filter_val = filters[filter_name]
|
||||
# Sometimes the REGEX filter value is not a string
|
||||
if not isinstance(filter_val, six.string_types):
|
||||
if not isinstance(filter_val, str):
|
||||
filter_val = str(filter_val)
|
||||
if db_regexp_op == 'LIKE':
|
||||
query = query.filter(column_attr.op(db_regexp_op)(
|
||||
@ -3199,7 +3199,7 @@ def migration_get_all_by_filters(context, filters,
|
||||
# The uuid filter is here for the MigrationLister and multi-cell
|
||||
# paging support in the compute API.
|
||||
uuid = filters["uuid"]
|
||||
uuid = [uuid] if isinstance(uuid, six.string_types) else uuid
|
||||
uuid = [uuid] if isinstance(uuid, str) else uuid
|
||||
query = query.filter(models.Migration.uuid.in_(uuid))
|
||||
|
||||
model_object = models.Migration
|
||||
@ -3209,7 +3209,7 @@ def migration_get_all_by_filters(context, filters,
|
||||
|
||||
if "status" in filters:
|
||||
status = filters["status"]
|
||||
status = [status] if isinstance(status, six.string_types) else status
|
||||
status = [status] if isinstance(status, str) else status
|
||||
query = query.filter(models.Migration.status.in_(status))
|
||||
if "host" in filters:
|
||||
host = filters["host"]
|
||||
|
@ -872,8 +872,7 @@ def _convert_to_v2(image_meta):
|
||||
# in glance only string and None property values are allowed,
|
||||
# v1 client accepts any values and converts them to string,
|
||||
# v2 doesn't - so we have to take care of it.
|
||||
elif prop_value is None or isinstance(
|
||||
prop_value, six.string_types):
|
||||
elif prop_value is None or isinstance(prop_value, str):
|
||||
output[prop_name] = prop_value
|
||||
else:
|
||||
output[prop_name] = str(prop_value)
|
||||
@ -909,13 +908,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, six.string_types):
|
||||
if isinstance(prop, str):
|
||||
properties[attr] = jsonutils.loads(prop)
|
||||
|
||||
|
||||
def _json_dumps(properties, attr):
|
||||
prop = properties[attr]
|
||||
if not isinstance(prop, six.string_types):
|
||||
if not isinstance(prop, str):
|
||||
properties[attr] = jsonutils.dumps(prop)
|
||||
|
||||
|
||||
|
@ -17,7 +17,6 @@ import functools
|
||||
|
||||
import netaddr
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
@ -513,7 +512,7 @@ class NetworkInfo(list):
|
||||
|
||||
@classmethod
|
||||
def hydrate(cls, network_info):
|
||||
if isinstance(network_info, six.string_types):
|
||||
if isinstance(network_info, str):
|
||||
network_info = jsonutils.loads(network_info)
|
||||
return cls([VIF.hydrate(vif) for vif in network_info])
|
||||
|
||||
|
@ -24,7 +24,6 @@ import oslo_messaging as messaging
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import base as ovoo_base
|
||||
from oslo_versionedobjects import exception as ovoo_exc
|
||||
import six
|
||||
|
||||
from nova import objects
|
||||
from nova.objects import fields as obj_fields
|
||||
@ -346,7 +345,7 @@ def serialize_args(fn):
|
||||
else v)
|
||||
except Exception:
|
||||
kwargs[k] = v.__class__.__name__
|
||||
elif k == 'exc_tb' and v and not isinstance(v, six.string_types):
|
||||
elif k == 'exc_tb' and v and not isinstance(v, str):
|
||||
kwargs[k] = ''.join(traceback.format_tb(v))
|
||||
elif isinstance(v, datetime.datetime):
|
||||
kwargs[k] = utils.strtime(v)
|
||||
|
@ -17,7 +17,6 @@ from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import versionutils
|
||||
from oslo_versionedobjects import exception as ovoo_exc
|
||||
import six
|
||||
|
||||
from nova.db.sqlalchemy import api as db
|
||||
from nova.db.sqlalchemy import api_models
|
||||
@ -342,7 +341,7 @@ class BuildRequestList(base.ObjectListBase, base.NovaObject):
|
||||
continue
|
||||
|
||||
# Sometimes the REGEX filter value is not a string
|
||||
if not isinstance(filter_val, six.string_types):
|
||||
if not isinstance(filter_val, str):
|
||||
filter_val = str(filter_val)
|
||||
filter_re = re.compile(filter_val)
|
||||
if instance_attr and not filter_re.search(str(instance_attr)):
|
||||
|
@ -18,7 +18,6 @@ import re
|
||||
from cursive import signature_utils
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_versionedobjects import fields
|
||||
import six
|
||||
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
@ -98,7 +97,7 @@ class ResourceClass(fields.StringPattern):
|
||||
|
||||
@staticmethod
|
||||
def coerce(obj, attr, value):
|
||||
if isinstance(value, six.string_types):
|
||||
if isinstance(value, str):
|
||||
uppered = value.upper()
|
||||
if ResourceClass._REGEX.match(uppered):
|
||||
return uppered
|
||||
@ -1060,7 +1059,7 @@ class NetworkModel(FieldType):
|
||||
def coerce(obj, attr, value):
|
||||
if isinstance(value, network_model.NetworkInfo):
|
||||
return value
|
||||
elif isinstance(value, six.string_types):
|
||||
elif isinstance(value, str):
|
||||
# Hmm, do we need this?
|
||||
return network_model.NetworkInfo.hydrate(value)
|
||||
else:
|
||||
@ -1090,7 +1089,7 @@ class NetworkVIFModel(FieldType):
|
||||
def coerce(obj, attr, value):
|
||||
if isinstance(value, network_model.VIF):
|
||||
return value
|
||||
elif isinstance(value, six.string_types):
|
||||
elif isinstance(value, str):
|
||||
return NetworkVIFModel.from_primitive(obj, attr, value)
|
||||
else:
|
||||
raise ValueError(_('A nova.network.model.VIF object is required '
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import versionutils
|
||||
import six
|
||||
|
||||
from nova.compute import utils as compute_utils
|
||||
from nova.db import api as db
|
||||
@ -198,8 +197,7 @@ class InstanceActionEvent(base.NovaPersistentObject, base.NovaObject,
|
||||
# so pass that as the message to exception_to_dict otherwise
|
||||
# the details will just the exception class name since it
|
||||
# cannot format the message as a NovaException.
|
||||
message = (
|
||||
exc_val if isinstance(exc_val, six.string_types) else None)
|
||||
message = exc_val if isinstance(exc_val, str) else None
|
||||
values['details'] = compute_utils.exception_to_dict(
|
||||
exc_val, message=message)['message']
|
||||
values['traceback'] = exc_tb
|
||||
|
@ -19,7 +19,6 @@ from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
from oslo_utils import versionutils
|
||||
import six
|
||||
|
||||
from nova.db import api as db
|
||||
from nova import exception
|
||||
@ -166,8 +165,7 @@ class PciDevice(base.NovaPersistentObject, base.NovaObject):
|
||||
# "extra_info" dict:
|
||||
# - "capabilities": dict of (strings/list of strings)
|
||||
extra_info = self.extra_info
|
||||
data = (v if isinstance(v, six.string_types) else
|
||||
jsonutils.dumps(v))
|
||||
data = v if isinstance(v, str) else jsonutils.dumps(v)
|
||||
extra_info.update({k: data})
|
||||
self.extra_info = extra_info
|
||||
|
||||
|
@ -17,7 +17,6 @@ import copy
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import versionutils
|
||||
import six
|
||||
|
||||
from nova import objects
|
||||
from nova.objects import base
|
||||
@ -85,7 +84,7 @@ def from_pci_stats(pci_stats):
|
||||
device pool objects, a simple dict or a list of such dicts.
|
||||
"""
|
||||
pools = []
|
||||
if isinstance(pci_stats, six.string_types):
|
||||
if isinstance(pci_stats, str):
|
||||
try:
|
||||
pci_stats = jsonutils.loads(pci_stats)
|
||||
except (ValueError, TypeError):
|
||||
|
@ -19,7 +19,6 @@ import os_resource_classes as orc
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import versionutils
|
||||
import six
|
||||
|
||||
from nova.db.sqlalchemy import api as db
|
||||
from nova.db.sqlalchemy import api_models
|
||||
@ -239,7 +238,7 @@ class RequestSpec(base.NovaObject):
|
||||
self.pci_requests = pci_requests
|
||||
|
||||
def _from_instance_numa_topology(self, numa_topology):
|
||||
if isinstance(numa_topology, six.string_types):
|
||||
if isinstance(numa_topology, str):
|
||||
numa_topology = objects.InstanceNUMATopology.obj_from_primitive(
|
||||
jsonutils.loads(numa_topology))
|
||||
|
||||
|
@ -15,8 +15,6 @@ import abc
|
||||
import re
|
||||
import string
|
||||
|
||||
import six
|
||||
|
||||
from nova import exception
|
||||
from nova.i18n import _
|
||||
from nova.pci import utils
|
||||
@ -204,7 +202,7 @@ class WhitelistPciAddress(object):
|
||||
|
||||
def _init_address_fields(self, pci_addr):
|
||||
if not self.is_physical_function:
|
||||
if isinstance(pci_addr, six.string_types):
|
||||
if isinstance(pci_addr, str):
|
||||
self.pci_address_spec = PciAddressGlobSpec(pci_addr)
|
||||
elif isinstance(pci_addr, dict):
|
||||
self.pci_address_spec = PciAddressRegexSpec(pci_addr)
|
||||
|
@ -20,7 +20,6 @@ import os
|
||||
import re
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from nova import exception
|
||||
|
||||
@ -59,9 +58,9 @@ def pci_device_prop_match(pci_dev, specs):
|
||||
# mismatch with the tags provided by users for port
|
||||
# binding profile and the ones configured by operators
|
||||
# with pci whitelist option.
|
||||
if isinstance(v, six.string_types):
|
||||
if isinstance(v, str):
|
||||
v = v.lower()
|
||||
if isinstance(pci_dev_v, six.string_types):
|
||||
if isinstance(pci_dev_v, str):
|
||||
pci_dev_v = pci_dev_v.lower()
|
||||
if pci_dev_v != v:
|
||||
return False
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from nova.scheduler import filters
|
||||
from nova.scheduler.filters import extra_specs_ops
|
||||
@ -36,7 +35,7 @@ class ComputeCapabilitiesFilter(filters.BaseHostFilter):
|
||||
cap = host_state
|
||||
for index in range(0, len(scope)):
|
||||
try:
|
||||
if isinstance(cap, six.string_types):
|
||||
if isinstance(cap, str):
|
||||
try:
|
||||
cap = jsonutils.loads(cap)
|
||||
except ValueError as e:
|
||||
|
@ -17,7 +17,6 @@
|
||||
import operator
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from nova.scheduler import filters
|
||||
|
||||
@ -122,7 +121,7 @@ class JsonFilter(filters.BaseHostFilter):
|
||||
for arg in query[1:]:
|
||||
if isinstance(arg, list):
|
||||
arg = self._process_filter(arg, host_state)
|
||||
elif isinstance(arg, six.string_types):
|
||||
elif isinstance(arg, str):
|
||||
arg = self._parse_string(arg, host_state)
|
||||
if arg is not None:
|
||||
cooked_args.append(arg)
|
||||
|
@ -17,7 +17,6 @@
|
||||
import collections
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -75,7 +74,7 @@ def instance_uuids_overlap(host_state, uuids):
|
||||
Returns True if any of the supplied uuids match any of the instance.uuid
|
||||
values in the host_state.
|
||||
"""
|
||||
if isinstance(uuids, six.string_types):
|
||||
if isinstance(uuids, str):
|
||||
uuids = [uuids]
|
||||
set_uuids = set(uuids)
|
||||
# host_state.instances is a dict whose keys are the instance uuids
|
||||
|
@ -16,7 +16,6 @@
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging as messaging
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
import nova.conf
|
||||
from nova import exception
|
||||
@ -61,7 +60,7 @@ class DbDriver(base.Driver):
|
||||
"""
|
||||
last_heartbeat = (service_ref.get('last_seen_up') or
|
||||
service_ref['created_at'])
|
||||
if isinstance(last_heartbeat, six.string_types):
|
||||
if isinstance(last_heartbeat, str):
|
||||
# NOTE(russellb) If this service_ref came in over rpc via
|
||||
# conductor, then the timestamp will be a string and needs to be
|
||||
# converted back to a datetime.
|
||||
|
@ -50,7 +50,6 @@ from oslo_utils import timeutils
|
||||
from oslo_versionedobjects import fixture as ovo_fixture
|
||||
from oslotest import base
|
||||
from oslotest import mock_fixture
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
@ -517,9 +516,9 @@ class TestCase(base.BaseTestCase):
|
||||
matcher.
|
||||
|
||||
"""
|
||||
if isinstance(expected, six.string_types):
|
||||
if isinstance(expected, str):
|
||||
expected = jsonutils.loads(expected)
|
||||
if isinstance(observed, six.string_types):
|
||||
if isinstance(observed, str):
|
||||
observed = jsonutils.loads(observed)
|
||||
|
||||
def sort_key(x):
|
||||
|
@ -18,7 +18,6 @@ import pprint
|
||||
import re
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from nova import test
|
||||
from nova.tests.functional import integrated_helpers
|
||||
@ -84,7 +83,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
|
||||
non_strings = \
|
||||
{k: v for k, v in value.items() if
|
||||
(not k == 'compute_host') and
|
||||
(not isinstance(v, six.string_types))}
|
||||
(not isinstance(v, str))}
|
||||
if len(non_strings) > 0:
|
||||
raise TypeError("subs can't contain non-string values:"
|
||||
"\n%(non_strings)s" %
|
||||
@ -232,7 +231,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
|
||||
if error:
|
||||
raise NoMatch('\n'.join(error))
|
||||
# template string
|
||||
elif isinstance(expected, six.string_types) and '%' in expected:
|
||||
elif isinstance(expected, str) and '%' in expected:
|
||||
# NOTE(vish): escape stuff for regex
|
||||
for char in '[]<>?':
|
||||
expected = expected.replace(char, '\\%s' % char)
|
||||
@ -266,11 +265,11 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
|
||||
if match.groups():
|
||||
matched_value = match.groups()[0]
|
||||
# string
|
||||
elif isinstance(expected, six.string_types):
|
||||
elif isinstance(expected, str):
|
||||
|
||||
# NOTE(danms): Ignore whitespace in this comparison
|
||||
expected = expected.strip()
|
||||
if isinstance(result, six.string_types):
|
||||
if isinstance(result, str):
|
||||
result = result.strip()
|
||||
|
||||
if expected != result:
|
||||
@ -294,7 +293,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase):
|
||||
'result_str': result_str,
|
||||
'result': result})
|
||||
# int
|
||||
elif isinstance(expected, (six.integer_types, float)):
|
||||
elif isinstance(expected, (int, float)):
|
||||
if expected != result:
|
||||
raise NoMatch(
|
||||
'Values do not match:\n'
|
||||
|
@ -20,7 +20,6 @@ from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import security_groups as secgroups_v21
|
||||
@ -121,11 +120,11 @@ class MockClient(object):
|
||||
|
||||
def create_security_group(self, body=None):
|
||||
s = body.get('security_group')
|
||||
if not isinstance(s.get('name', ''), six.string_types):
|
||||
if not isinstance(s.get('name', ''), str):
|
||||
msg = ('BadRequest: Invalid input for name. Reason: '
|
||||
'None is not a valid string.')
|
||||
raise n_exc.BadRequest(message=msg)
|
||||
if not isinstance(s.get('description.', ''), six.string_types):
|
||||
if not isinstance(s.get('description.', ''), str):
|
||||
msg = ('BadRequest: Invalid input for description. Reason: '
|
||||
'None is not a valid string.')
|
||||
raise n_exc.BadRequest(message=msg)
|
||||
|
@ -18,7 +18,6 @@ from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import server_metadata \
|
||||
@ -47,7 +46,7 @@ def fake_instance_save(inst, **kwargs):
|
||||
|
||||
|
||||
def return_server_metadata(context, server_id):
|
||||
if not isinstance(server_id, six.string_types) or not len(server_id) == 36:
|
||||
if not isinstance(server_id, str) or not len(server_id) == 36:
|
||||
msg = 'id %s must be a uuid in return server metadata' % server_id
|
||||
raise Exception(msg)
|
||||
return stub_server_metadata()
|
||||
|
@ -19,7 +19,6 @@ from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import routes
|
||||
import six
|
||||
import webob.dec
|
||||
|
||||
from nova.api import auth as api_auth
|
||||
@ -331,7 +330,7 @@ def create_info_cache(nw_cache):
|
||||
{'cidr': 'b33f::/64',
|
||||
'ips': [_ip(ip) for ip in pub1]}]}}]
|
||||
|
||||
if not isinstance(nw_cache, six.string_types):
|
||||
if not isinstance(nw_cache, str):
|
||||
nw_cache = jsonutils.dumps(nw_cache)
|
||||
|
||||
return {
|
||||
|
@ -62,8 +62,8 @@ class RFBSecurityProxyTestCase(test.NoDBTestCase):
|
||||
self._expect_tenant_recv(auth.VERSION_LENGTH, full_version_str)
|
||||
|
||||
def _to_binary(self, val):
|
||||
if not isinstance(val, six.binary_type):
|
||||
val = six.binary_type(val, 'utf-8')
|
||||
if not isinstance(val, bytes):
|
||||
val = bytes(val, 'utf-8')
|
||||
return val
|
||||
|
||||
def _expect_tenant_send(self, val):
|
||||
|
@ -2618,11 +2618,11 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
self.ctxt, instance['uuid'],
|
||||
{'access_ip_v4': netaddr.IPAddress('1.2.3.4'),
|
||||
'access_ip_v6': netaddr.IPAddress('::1')})
|
||||
self.assertIsInstance(instance['access_ip_v4'], six.string_types)
|
||||
self.assertIsInstance(instance['access_ip_v6'], six.string_types)
|
||||
self.assertIsInstance(instance['access_ip_v4'], str)
|
||||
self.assertIsInstance(instance['access_ip_v6'], str)
|
||||
instance = db.instance_get_by_uuid(self.ctxt, instance['uuid'])
|
||||
self.assertIsInstance(instance['access_ip_v4'], six.string_types)
|
||||
self.assertIsInstance(instance['access_ip_v6'], six.string_types)
|
||||
self.assertIsInstance(instance['access_ip_v4'], str)
|
||||
self.assertIsInstance(instance['access_ip_v6'], str)
|
||||
|
||||
@mock.patch('nova.db.sqlalchemy.api._check_instance_exists_in_project',
|
||||
return_value=None)
|
||||
|
@ -19,7 +19,6 @@ import re
|
||||
from eventlet import greenthread
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -77,7 +76,7 @@ def fake_execute(*cmd_parts, **kwargs):
|
||||
LOG.debug('Faked command matched %s', fake_replier[0])
|
||||
break
|
||||
|
||||
if isinstance(reply_handler, six.string_types):
|
||||
if isinstance(reply_handler, str):
|
||||
# If the reply handler is a string, return it as stdout
|
||||
reply = reply_handler, ''
|
||||
else:
|
||||
|
@ -560,7 +560,7 @@ class XMLMatches(object):
|
||||
|
||||
class EncodedByUTF8(object):
|
||||
def match(self, obj):
|
||||
if isinstance(obj, six.binary_type):
|
||||
if isinstance(obj, bytes):
|
||||
if hasattr(obj, "decode"):
|
||||
try:
|
||||
obj.decode("utf-8")
|
||||
@ -579,6 +579,6 @@ class EncodedByUTF8(object):
|
||||
% {
|
||||
"obj": obj,
|
||||
"obj_type": type(obj).__name__,
|
||||
"correct_type": six.binary_type.__name__
|
||||
"correct_type": bytes.__name__
|
||||
})
|
||||
return testtools.matchers.Mismatch(reason)
|
||||
|
@ -836,7 +836,7 @@ class UT8TestCase(test.NoDBTestCase):
|
||||
def test_not_text_type(self):
|
||||
return_value = utils.utf8(1)
|
||||
self.assertEqual(b"1", return_value)
|
||||
self.assertIsInstance(return_value, six.binary_type)
|
||||
self.assertIsInstance(return_value, bytes)
|
||||
|
||||
def test_text_type_with_encoding(self):
|
||||
some_value = 'test\u2026config'
|
||||
|
@ -21,7 +21,6 @@ import time
|
||||
|
||||
import eventlet
|
||||
import fixtures
|
||||
import six
|
||||
|
||||
from nova import test
|
||||
from nova.virt.disk.mount import nbd
|
||||
@ -40,7 +39,7 @@ def _fake_exists_no_users(path):
|
||||
|
||||
|
||||
def _fake_listdir_nbd_devices(path):
|
||||
if isinstance(path, six.string_types) and path.startswith('/sys/block'):
|
||||
if isinstance(path, str) and path.startswith('/sys/block'):
|
||||
return ['nbd0', 'nbd1']
|
||||
return ORIG_LISTDIR(path)
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
from lxml import etree
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from nova.objects import fields as obj_fields
|
||||
from nova import test
|
||||
@ -147,7 +146,7 @@ class FakeLibvirtTests(test.NoDBTestCase):
|
||||
blockstats = dom.blockStats('vda')
|
||||
self.assertEqual(len(blockstats), 5)
|
||||
for x in blockstats:
|
||||
self.assertIn(type(x), six.integer_types)
|
||||
self.assertIs(type(x), int)
|
||||
|
||||
def test_attach_detach(self):
|
||||
uuid = uuidutils.generate_uuid()
|
||||
@ -172,7 +171,7 @@ class FakeLibvirtTests(test.NoDBTestCase):
|
||||
self.assertEqual(info[1], 128000)
|
||||
self.assertLessEqual(info[2], 128000)
|
||||
self.assertEqual(info[3], 1)
|
||||
self.assertIn(type(info[4]), six.integer_types)
|
||||
self.assertIs(type(info[4]), int)
|
||||
|
||||
def test_createXML_runs_domain(self):
|
||||
uuid = uuidutils.generate_uuid()
|
||||
|
@ -22,7 +22,6 @@ from eventlet import tpool
|
||||
import mock
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
import testtools
|
||||
|
||||
from nova.compute import vm_states
|
||||
@ -41,7 +40,7 @@ from nova.virt.libvirt import host
|
||||
|
||||
class StringMatcher(object):
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, six.string_types)
|
||||
return isinstance(other, str)
|
||||
|
||||
|
||||
class FakeVirtDomain(object):
|
||||
|
@ -563,7 +563,7 @@ class LibvirtVifTestCase(test.NoDBTestCase):
|
||||
self.assertEqual(tx_queue_size, tx_want)
|
||||
|
||||
def _assertXmlEqual(self, expectedXmlstr, actualXmlstr):
|
||||
if not isinstance(actualXmlstr, six.string_types):
|
||||
if not isinstance(actualXmlstr, str):
|
||||
actualXmlstr = etree.tostring(actualXmlstr, encoding='unicode',
|
||||
pretty_print=True)
|
||||
self.assertXmlEqual(expectedXmlstr, actualXmlstr)
|
||||
|
@ -25,7 +25,6 @@ from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from nova.compute import manager
|
||||
from nova import conf
|
||||
@ -532,7 +531,7 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
|
||||
instance_ref, network_info = self._get_running_instance()
|
||||
console_output = self.connection.get_console_output(self.ctxt,
|
||||
instance_ref)
|
||||
self.assertIsInstance(console_output, six.string_types)
|
||||
self.assertIsInstance(console_output, str)
|
||||
|
||||
@catch_notimplementederror
|
||||
def test_get_vnc_console(self):
|
||||
|
@ -256,7 +256,7 @@ def utf8(value):
|
||||
http://github.com/facebook/tornado/blob/master/tornado/escape.py
|
||||
|
||||
"""
|
||||
if value is None or isinstance(value, six.binary_type):
|
||||
if value is None or isinstance(value, bytes):
|
||||
return value
|
||||
|
||||
if not isinstance(value, six.text_type):
|
||||
@ -697,7 +697,7 @@ def tpool_execute(func, *args, **kwargs):
|
||||
def is_none_string(val):
|
||||
"""Check if a string represents a None value.
|
||||
"""
|
||||
if not isinstance(val, six.string_types):
|
||||
if not isinstance(val, str):
|
||||
return False
|
||||
|
||||
return val.lower() == 'none'
|
||||
|
Loading…
Reference in New Issue
Block a user