Merge "Remove six and python 2.7 full support"
This commit is contained in:
commit
5819dcb008
|
@ -16,7 +16,6 @@ import weakref
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import importutils
|
||||
import six
|
||||
from stevedore import enabled
|
||||
|
||||
from heat.common import exception
|
||||
|
@ -95,7 +94,7 @@ class ClientBackend(object):
|
|||
context)
|
||||
except (ImportError, RuntimeError, cfg.NoSuchOptError) as err:
|
||||
msg = _('Invalid cloud_backend setting in heat.conf '
|
||||
'detected - %s') % six.text_type(err)
|
||||
'detected - %s') % str(err)
|
||||
LOG.error(msg)
|
||||
raise exception.Invalid(reason=msg)
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ from oslo_config import cfg
|
|||
from oslo_utils import excutils
|
||||
|
||||
import requests
|
||||
import six
|
||||
|
||||
from heat.common import config
|
||||
from heat.common import exception as heat_exception
|
||||
|
@ -29,8 +28,7 @@ from heat.common import exception as heat_exception
|
|||
cfg.CONF.import_opt('client_retry_limit', 'heat.common.config')
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class ClientPlugin(object):
|
||||
class ClientPlugin(object, metaclass=abc.ABCMeta):
|
||||
|
||||
# Module which contains all exceptions classes which the client
|
||||
# may emit
|
||||
|
@ -139,11 +137,10 @@ class ClientPlugin(object):
|
|||
if self.exceptions_module:
|
||||
if isinstance(self.exceptions_module, list):
|
||||
for m in self.exceptions_module:
|
||||
if type(ex) in six.itervalues(m.__dict__):
|
||||
if type(ex) in m.__dict__.values():
|
||||
return True
|
||||
else:
|
||||
return type(ex) in six.itervalues(
|
||||
self.exceptions_module.__dict__)
|
||||
return type(ex) in self.exceptions_module.__dict__.values()
|
||||
return False
|
||||
|
||||
def is_not_found(self, ex):
|
||||
|
|
|
@ -13,13 +13,10 @@
|
|||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
|
||||
|
||||
@six.add_metaclass(abc.ABCMeta)
|
||||
class MicroversionMixin(object):
|
||||
class MicroversionMixin(object, metaclass=abc.ABCMeta):
|
||||
"""Mixin For microversion support."""
|
||||
|
||||
def client(self, version=None):
|
||||
|
|
|
@ -18,6 +18,7 @@ from email.mime import text
|
|||
import os
|
||||
import pkgutil
|
||||
import string
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from neutronclient.common import exceptions as q_exceptions
|
||||
from novaclient import api_versions
|
||||
|
@ -27,8 +28,6 @@ from oslo_config import cfg
|
|||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import netutils
|
||||
import six
|
||||
from six.moves.urllib import parse as urlparse
|
||||
import tenacity
|
||||
|
||||
from heat.common import exception
|
||||
|
@ -225,7 +224,7 @@ class NovaClientPlugin(microversion_mixin.MicroversionMixin,
|
|||
|
||||
"""
|
||||
# not checking with is_uuid_like as most tests use strings e.g. '1234'
|
||||
if isinstance(server, six.string_types):
|
||||
if isinstance(server, str):
|
||||
server = self.fetch_server(server)
|
||||
if server is None:
|
||||
return False
|
||||
|
@ -607,7 +606,7 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
|||
"nova server metadata needs to be a Map."))
|
||||
|
||||
return dict((key, (value if isinstance(value,
|
||||
six.string_types)
|
||||
str)
|
||||
else jsonutils.dumps(value))
|
||||
) for (key, value) in metadata.items())
|
||||
|
||||
|
@ -675,7 +674,7 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
|
|||
except exceptions.UnsupportedConsoleType as ex:
|
||||
url = ex.message
|
||||
except Exception as e:
|
||||
url = _('Cannot get console url: %s') % six.text_type(e)
|
||||
url = _('Cannot get console url: %s') % str(e)
|
||||
|
||||
return url
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
from oslo_config import cfg
|
||||
from saharaclient.api import base as sahara_base
|
||||
from saharaclient import client as sahara_client
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -117,7 +116,7 @@ class SaharaClientPlugin(client_plugin.ClientPlugin):
|
|||
raise exception.Error(
|
||||
_("Error retrieving %(entity)s list from sahara: "
|
||||
"%(err)s") % dict(entity=resource_name,
|
||||
err=six.text_type(ex)))
|
||||
err=str(ex)))
|
||||
num_matches = len(obj_list)
|
||||
if num_matches == 0:
|
||||
raise exception.EntityNotFound(entity=resource_name or 'entity',
|
||||
|
|
|
@ -17,10 +17,9 @@ import hashlib
|
|||
import logging
|
||||
import random
|
||||
import time
|
||||
from urllib import parse
|
||||
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
from swiftclient import client as sc
|
||||
from swiftclient import exceptions
|
||||
from swiftclient import utils as swiftclient_utils
|
||||
|
@ -98,8 +97,8 @@ class SwiftClientPlugin(client_plugin.ClientPlugin):
|
|||
if key_header not in self.client().head_account():
|
||||
self.client().post_account({
|
||||
key_header: hashlib.sha224(
|
||||
six.b(six.text_type(
|
||||
random.getrandbits(256)))).hexdigest()[:32]})
|
||||
str(random.getrandbits(256)).encode(
|
||||
"latin-1")).hexdigest()[:32]})
|
||||
|
||||
key = self.client().head_account()[key_header]
|
||||
|
||||
|
@ -173,5 +172,5 @@ class SwiftClientPlugin(client_plugin.ClientPlugin):
|
|||
'container %(container)s, '
|
||||
'reason: %(reason)s.') %
|
||||
{'container': files_container,
|
||||
'reason': six.text_type(cex)})
|
||||
'reason': str(cex)})
|
||||
return files
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
from zaqarclient.queues.v2 import client as zaqarclient
|
||||
from zaqarclient.transport import errors as zaqar_errors
|
||||
|
@ -75,7 +73,7 @@ class ZaqarClientPlugin(client_plugin.ClientPlugin):
|
|||
return isinstance(ex, zaqar_errors.ResourceNotFound)
|
||||
|
||||
def get_queue(self, queue_name):
|
||||
if not isinstance(queue_name, six.string_types):
|
||||
if not isinstance(queue_name, str):
|
||||
raise TypeError(_('Queue name must be a string'))
|
||||
if not (0 < len(queue_name) <= 64):
|
||||
raise ValueError(_('Queue name length must be 1-64'))
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
|
||||
import collections
|
||||
|
||||
import six
|
||||
|
||||
from heat.common.i18n import _
|
||||
|
||||
from heat.common import exception
|
||||
|
@ -31,7 +29,7 @@ class Conditions(object):
|
|||
self._resolved = {}
|
||||
|
||||
def validate(self):
|
||||
for name, cond in six.iteritems(self._conditions):
|
||||
for name, cond in self._conditions.items():
|
||||
self._check_condition_type(name, cond)
|
||||
function.validate(cond)
|
||||
|
||||
|
@ -56,7 +54,7 @@ class Conditions(object):
|
|||
if isinstance(condition_name, bool):
|
||||
return condition_name
|
||||
|
||||
if not (isinstance(condition_name, six.string_types) and
|
||||
if not (isinstance(condition_name, str) and
|
||||
condition_name in self._conditions):
|
||||
raise ValueError(_('Invalid condition "%s"') % condition_name)
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import croniter
|
|||
import eventlet
|
||||
import netaddr
|
||||
import pytz
|
||||
import six
|
||||
|
||||
from neutron_lib.api import validators
|
||||
from oslo_utils import timeutils
|
||||
|
@ -35,7 +34,7 @@ class IPConstraint(constraints.BaseCustomConstraint):
|
|||
|
||||
def validate(self, value, context, template=None):
|
||||
self._error_message = 'Invalid IP address'
|
||||
if not isinstance(value, six.string_types):
|
||||
if not isinstance(value, str):
|
||||
return False
|
||||
msg = validators.validate_ip_address(value)
|
||||
if msg is not None:
|
||||
|
@ -59,7 +58,7 @@ class DNSNameConstraint(constraints.BaseCustomConstraint):
|
|||
self._error_message = ("'%(value)s' not in valid format."
|
||||
" Reason: %(reason)s") % {
|
||||
'value': value,
|
||||
'reason': six.text_type(ex)}
|
||||
'reason': str(ex)}
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -114,7 +113,7 @@ class CIDRConstraint(constraints.BaseCustomConstraint):
|
|||
return False
|
||||
return True
|
||||
except Exception as ex:
|
||||
self._error_message = 'Invalid net cidr %s ' % six.text_type(ex)
|
||||
self._error_message = 'Invalid net cidr %s ' % str(ex)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -158,7 +157,7 @@ class CRONExpressionConstraint(constraints.BaseCustomConstraint):
|
|||
return True
|
||||
except Exception as ex:
|
||||
self._error_message = _(
|
||||
'Invalid CRON expression: %s') % six.text_type(ex)
|
||||
'Invalid CRON expression: %s') % str(ex)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -172,7 +171,7 @@ class TimezoneConstraint(constraints.BaseCustomConstraint):
|
|||
return True
|
||||
except Exception as ex:
|
||||
self._error_message = _(
|
||||
'Invalid timezone: %s') % six.text_type(ex)
|
||||
'Invalid timezone: %s') % str(ex)
|
||||
return False
|
||||
|
||||
|
||||
|
@ -190,5 +189,5 @@ class ExpirationConstraint(constraints.BaseCustomConstraint):
|
|||
except Exception as ex:
|
||||
self._error_message = (_(
|
||||
'Expiration {0} is invalid: {1}').format(value,
|
||||
six.text_type(ex)))
|
||||
str(ex)))
|
||||
return False
|
||||
|
|
|
@ -21,7 +21,6 @@ from oslo_config import cfg
|
|||
from oslo_log import log
|
||||
from oslo_utils import reflection
|
||||
from oslo_utils import strutils
|
||||
import six
|
||||
|
||||
from heat.common import cache
|
||||
from heat.common import exception
|
||||
|
@ -149,7 +148,7 @@ class Schema(collections.Mapping):
|
|||
if isinstance(self.schema, AnyIndexDict):
|
||||
self.schema.value.validate(context)
|
||||
else:
|
||||
for nested_schema in six.itervalues(self.schema):
|
||||
for nested_schema in self.schema.values():
|
||||
nested_schema.validate(context)
|
||||
|
||||
def _validate_default(self, context):
|
||||
|
@ -195,9 +194,9 @@ class Schema(collections.Mapping):
|
|||
elif self.type == self.NUMBER:
|
||||
return Schema.str_to_num(value)
|
||||
elif self.type == self.STRING:
|
||||
return six.text_type(value)
|
||||
return str(value)
|
||||
elif self.type == self.BOOLEAN:
|
||||
return strutils.bool_from_string(six.text_type(value),
|
||||
return strutils.bool_from_string(str(value),
|
||||
strict=True)
|
||||
except ValueError:
|
||||
raise ValueError(_('Value "%(val)s" is invalid for data type '
|
||||
|
@ -215,7 +214,7 @@ class Schema(collections.Mapping):
|
|||
if type(constraint) not in skipped:
|
||||
constraint.validate(value, self, context)
|
||||
except ValueError as ex:
|
||||
raise exception.StackValidationFailed(message=six.text_type(ex))
|
||||
raise exception.StackValidationFailed(message=str(ex))
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key == self.TYPE:
|
||||
|
@ -265,7 +264,7 @@ class AnyIndexDict(collections.Mapping):
|
|||
self.value = value
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key != self.ANYTHING and not isinstance(key, six.integer_types):
|
||||
if key != self.ANYTHING and not isinstance(key, int):
|
||||
raise KeyError(_('Invalid key %s') % key)
|
||||
|
||||
return self.value
|
||||
|
@ -277,7 +276,6 @@ class AnyIndexDict(collections.Mapping):
|
|||
return 1
|
||||
|
||||
|
||||
@six.python_2_unicode_compatible
|
||||
class Constraint(collections.Mapping):
|
||||
"""Parent class for constraints on allowable values for a Property.
|
||||
|
||||
|
@ -353,7 +351,7 @@ class Range(Constraint):
|
|||
self.max = max
|
||||
|
||||
for param in (min, max):
|
||||
if not isinstance(param, (float, six.integer_types, type(None))):
|
||||
if not isinstance(param, (float, int, type(None))):
|
||||
raise exception.InvalidSchemaError(
|
||||
message=_('min/max must be numeric'))
|
||||
|
||||
|
@ -422,7 +420,7 @@ class Length(Range):
|
|||
super(Length, self).__init__(min, max, description)
|
||||
|
||||
for param in (min, max):
|
||||
if not isinstance(param, (six.integer_types, type(None))):
|
||||
if not isinstance(param, (int, type(None))):
|
||||
msg = _('min/max length must be integral')
|
||||
raise exception.InvalidSchemaError(message=msg)
|
||||
|
||||
|
@ -471,7 +469,7 @@ class Modulo(Constraint):
|
|||
'an offset value specified.'))
|
||||
|
||||
for param in (step, offset):
|
||||
if not isinstance(param, (float, six.integer_types, type(None))):
|
||||
if not isinstance(param, (float, int, type(None))):
|
||||
raise exception.InvalidSchemaError(
|
||||
message=_('step/offset must be numeric'))
|
||||
|
||||
|
@ -543,7 +541,7 @@ class AllowedValues(Constraint):
|
|||
def __init__(self, allowed, description=None):
|
||||
super(AllowedValues, self).__init__(description)
|
||||
if (not isinstance(allowed, collections.Sequence) or
|
||||
isinstance(allowed, six.string_types)):
|
||||
isinstance(allowed, str)):
|
||||
raise exception.InvalidSchemaError(
|
||||
message=_('AllowedValues must be a list'))
|
||||
self.allowed = tuple(allowed)
|
||||
|
@ -589,7 +587,7 @@ class AllowedPattern(Constraint):
|
|||
|
||||
def __init__(self, pattern, description=None):
|
||||
super(AllowedPattern, self).__init__(description)
|
||||
if not isinstance(pattern, six.string_types):
|
||||
if not isinstance(pattern, str):
|
||||
raise exception.InvalidSchemaError(
|
||||
message=_('AllowedPattern must be a string'))
|
||||
self.pattern = pattern
|
||||
|
@ -701,13 +699,13 @@ class BaseCustomConstraint(object):
|
|||
try:
|
||||
self.validate_with_client(context.clients, value_to_validate)
|
||||
except self.expected_exceptions as e:
|
||||
self._error_message = six.text_type(e)
|
||||
self._error_message = str(e)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
class_name = reflection.get_class_name(self, fully_qualified=False)
|
||||
cache_value_prefix = "{0}:{1}".format(class_name,
|
||||
six.text_type(context.tenant_id))
|
||||
str(context.tenant_id))
|
||||
validation_result = check_cache_or_validate_value(
|
||||
cache_value_prefix, value)
|
||||
# if validation failed we should not store it in cache
|
||||
|
|
Loading…
Reference in New Issue