Remove six and python 2.7 full support
Six is in use to help us to keep support for python 2.7. Since the ussuri cycle we decide to remove the python 2.7 support so we can go ahead and also remove six usage from the python code. Review process and help ----------------------- Removing six introduce a lot of changes and an huge amount of modified files To simplify reviews we decided to split changes into several patches to avoid painful reviews and avoid mistakes. To review this patch you can use the six documentation [1] to obtain help and understand choices. Additional informations ----------------------- Changes related to 'six.b(data)' [2] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ six.b [2] encode the given datas in latin-1 in python3 so I did the same things in this patch. Latin-1 is equal to iso-8859-1 [3]. This encoding is the default encoding [4] of certain descriptive HTTP headers. I suggest to keep latin-1 for the moment and to move to another encoding in a follow-up patch if needed to move to most powerful encoding (utf8). HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5]. Note that this commit message is autogenerated and not necesserly contains changes related to 'six.b' [1] https://six.readthedocs.io/ [2] https://six.readthedocs.io/#six.b [3] https://docs.python.org/3/library/codecs.html#standard-encodings [4] https://www.w3schools.com/charsets/ref_html_8859.asp [5] https://www.w3schools.com/html/html_charset.asp Patch 9 of a serie of 28 patches Change-Id: I89ec972a566ce211b5de4b02ca4d9b1b6e178525
This commit is contained in:
parent
1c318a167c
commit
3e28c8e76b
|
@ -10,7 +10,6 @@
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -122,7 +121,7 @@ class DesignateZone(resource.Resource):
|
||||||
raise_invalid_exception(self.SECONDARY, self.MASTERS)
|
raise_invalid_exception(self.SECONDARY, self.MASTERS)
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
args = dict((k, v) for k, v in six.iteritems(self.properties) if v)
|
args = dict((k, v) for k, v in self.properties.items() if v)
|
||||||
args['type_'] = args.pop(self.TYPE)
|
args['type_'] = args.pop(self.TYPE)
|
||||||
|
|
||||||
zone = self.client().zones.create(**args)
|
zone = self.client().zones.create(**args)
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
|
@ -212,7 +210,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
||||||
return resource.Resource.get_reference_id(self)
|
return resource.Resource.get_reference_id(self)
|
||||||
|
|
||||||
def _attribute_output_name(self, *attr_path):
|
def _attribute_output_name(self, *attr_path):
|
||||||
return ', '.join(six.text_type(a) for a in attr_path)
|
return ', '.join(str(a) for a in attr_path)
|
||||||
|
|
||||||
def get_attribute(self, key, *path): # noqa: C901
|
def get_attribute(self, key, *path): # noqa: C901
|
||||||
if key == self.CURRENT_SIZE:
|
if key == self.CURRENT_SIZE:
|
||||||
|
@ -284,7 +282,7 @@ class AutoScalingResourceGroup(aws_asg.AutoScalingGroup):
|
||||||
|
|
||||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||||
for attr in self.referenced_attrs():
|
for attr in self.referenced_attrs():
|
||||||
if isinstance(attr, six.string_types):
|
if isinstance(attr, str):
|
||||||
key, path = attr, []
|
key, path = attr, []
|
||||||
else:
|
else:
|
||||||
key, path = attr[0], list(attr[1:])
|
key, path = attr[0], list(attr[1:])
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
@ -460,7 +459,7 @@ class InstanceGroup(stack_resource.StackResource):
|
||||||
|
|
||||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||||
for attr in self.referenced_attrs():
|
for attr in self.referenced_attrs():
|
||||||
if isinstance(attr, six.string_types):
|
if isinstance(attr, str):
|
||||||
key = attr
|
key = attr
|
||||||
else:
|
else:
|
||||||
key = attr[0]
|
key = attr[0]
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
|
@ -47,7 +46,7 @@ class NoneResource(resource.Resource):
|
||||||
self.translate_properties(self.properties, client_resolve)
|
self.translate_properties(self.properties, client_resolve)
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
self.resource_id_set(six.text_type(uuid.uuid4()))
|
self.resource_id_set(str(uuid.uuid4()))
|
||||||
# set is_placeholder flag when resource trying to replace original
|
# set is_placeholder flag when resource trying to replace original
|
||||||
# resource with a placeholder resource.
|
# resource with a placeholder resource.
|
||||||
self.data_set(self.IS_PLACEHOLDER, 'True')
|
self.data_set(self.IS_PLACEHOLDER, 'True')
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.common import password_gen
|
from heat.common import password_gen
|
||||||
|
@ -235,7 +233,7 @@ class RandomString(resource.Resource):
|
||||||
if self.resource_id is not None:
|
if self.resource_id is not None:
|
||||||
return self.data().get('value')
|
return self.data().get('value')
|
||||||
else:
|
else:
|
||||||
return six.text_type(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
import six
|
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from heat.common import auth_plugin
|
from heat.common import auth_plugin
|
||||||
|
@ -49,7 +48,7 @@ class TempCACertFile(object):
|
||||||
try:
|
try:
|
||||||
self._cacert_temp_file = tempfile.NamedTemporaryFile()
|
self._cacert_temp_file = tempfile.NamedTemporaryFile()
|
||||||
self._cacert_temp_file.write(
|
self._cacert_temp_file.write(
|
||||||
six.text_type(self._cacert).encode('utf-8'))
|
str(self._cacert).encode('utf-8'))
|
||||||
# Add seek func to make sure the writen context will flush to
|
# Add seek func to make sure the writen context will flush to
|
||||||
# tempfile with python 2.7. we can use flush() for python 2.7
|
# tempfile with python 2.7. we can use flush() for python 2.7
|
||||||
# but not 3.5.
|
# but not 3.5.
|
||||||
|
@ -266,7 +265,7 @@ class RemoteStack(resource.Resource):
|
||||||
location = "remote cloud"
|
location = "remote cloud"
|
||||||
else:
|
else:
|
||||||
location = 'region "%s"' % self._region_name
|
location = 'region "%s"' % self._region_name
|
||||||
exc_info = dict(location=location, exc=six.text_type(ex))
|
exc_info = dict(location=location, exc=str(ex))
|
||||||
msg = _('Cannot establish connection to Heat endpoint at '
|
msg = _('Cannot establish connection to Heat endpoint at '
|
||||||
'%(location)s due to "%(exc)s"') % exc_info
|
'%(location)s due to "%(exc)s"') % exc_info
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
@ -287,7 +286,7 @@ class RemoteStack(resource.Resource):
|
||||||
location = "remote cloud"
|
location = "remote cloud"
|
||||||
else:
|
else:
|
||||||
location = 'region "%s"' % self._region_name
|
location = 'region "%s"' % self._region_name
|
||||||
exc_info = dict(location=location, exc=six.text_type(ex))
|
exc_info = dict(location=location, exc=str(ex))
|
||||||
msg = _('Failed validating stack template using Heat endpoint at '
|
msg = _('Failed validating stack template using Heat endpoint at '
|
||||||
'%(location)s due to "%(exc)s"') % exc_info
|
'%(location)s due to "%(exc)s"') % exc_info
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
@ -155,7 +154,7 @@ class ResourceChain(stack_resource.StackResource):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def _attribute_output_name(self, *attr_path):
|
def _attribute_output_name(self, *attr_path):
|
||||||
return ', '.join(six.text_type(a) for a in attr_path)
|
return ', '.join(str(a) for a in attr_path)
|
||||||
|
|
||||||
def get_attribute(self, key, *path):
|
def get_attribute(self, key, *path):
|
||||||
if key == self.ATTR_ATTRIBUTES and not path:
|
if key == self.ATTR_ATTRIBUTES and not path:
|
||||||
|
@ -198,7 +197,7 @@ class ResourceChain(stack_resource.StackResource):
|
||||||
|
|
||||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||||
for attr in self.referenced_attrs():
|
for attr in self.referenced_attrs():
|
||||||
if isinstance(attr, six.string_types):
|
if isinstance(attr, str):
|
||||||
key, path = attr, []
|
key, path = attr, []
|
||||||
else:
|
else:
|
||||||
key, path = attr[0], list(attr[1:])
|
key, path = attr[0], list(attr[1:])
|
||||||
|
@ -227,7 +226,7 @@ class ResourceChain(stack_resource.StackResource):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _resource_names(resource_types):
|
def _resource_names(resource_types):
|
||||||
"""Returns a list of unique resource names to create."""
|
"""Returns a list of unique resource names to create."""
|
||||||
return [six.text_type(i) for i, t in enumerate(resource_types)]
|
return [str(i) for i, t in enumerate(resource_types)]
|
||||||
|
|
||||||
def _build_resource_definition(self, resource_name, resource_type,
|
def _build_resource_definition(self, resource_name, resource_type,
|
||||||
depends_on=None):
|
depends_on=None):
|
||||||
|
|
|
@ -15,7 +15,6 @@ import collections
|
||||||
import copy
|
import copy
|
||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
import six
|
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
@ -306,7 +305,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
first_name = next(self._resource_names())
|
first_name = next(self._resource_names())
|
||||||
test_tmpl = self._assemble_nested([first_name],
|
test_tmpl = self._assemble_nested([first_name],
|
||||||
include_all=True)
|
include_all=True)
|
||||||
res_def = next(six.itervalues(test_tmpl.resource_definitions(None)))
|
res_def = next(iter(test_tmpl.resource_definitions(None).values()))
|
||||||
# make sure we can resolve the nested resource type
|
# make sure we can resolve the nested resource type
|
||||||
self.stack.env.get_class_to_instantiate(res_def.resource_type)
|
self.stack.env.get_class_to_instantiate(res_def.resource_type)
|
||||||
|
|
||||||
|
@ -339,12 +338,12 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
if self.REMOVAL_RSRC_LIST in r:
|
if self.REMOVAL_RSRC_LIST in r:
|
||||||
# Tolerate string or int list values
|
# Tolerate string or int list values
|
||||||
for n in r[self.REMOVAL_RSRC_LIST]:
|
for n in r[self.REMOVAL_RSRC_LIST]:
|
||||||
str_n = six.text_type(n)
|
str_n = str(n)
|
||||||
if (str_n in current_blacklist or
|
if (str_n in current_blacklist or
|
||||||
self.resource_id is None or
|
self.resource_id is None or
|
||||||
str_n in insp.member_names(include_failed=True)):
|
str_n in insp.member_names(include_failed=True)):
|
||||||
yield str_n
|
yield str_n
|
||||||
elif isinstance(n, six.string_types):
|
elif isinstance(n, str):
|
||||||
try:
|
try:
|
||||||
refids = self.get_output(self.REFS_MAP)
|
refids = self.get_output(self.REFS_MAP)
|
||||||
except (exception.NotFound,
|
except (exception.NotFound,
|
||||||
|
@ -399,9 +398,9 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
def is_blacklisted(name):
|
def is_blacklisted(name):
|
||||||
return name in name_blacklist
|
return name in name_blacklist
|
||||||
|
|
||||||
candidates = six.moves.map(six.text_type, itertools.count())
|
candidates = map(str, itertools.count())
|
||||||
|
|
||||||
return itertools.islice(six.moves.filterfalse(is_blacklisted,
|
return itertools.islice(itertools.filterfalse(is_blacklisted,
|
||||||
candidates),
|
candidates),
|
||||||
size)
|
size)
|
||||||
|
|
||||||
|
@ -488,7 +487,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
def _attribute_output_name(self, *attr_path):
|
def _attribute_output_name(self, *attr_path):
|
||||||
if attr_path[0] == self.REFS:
|
if attr_path[0] == self.REFS:
|
||||||
return self.REFS
|
return self.REFS
|
||||||
return ', '.join(six.text_type(a) for a in attr_path)
|
return ', '.join(str(a) for a in attr_path)
|
||||||
|
|
||||||
def get_attribute(self, key, *path):
|
def get_attribute(self, key, *path):
|
||||||
if key == self.REMOVED_RSRC_LIST:
|
if key == self.REMOVED_RSRC_LIST:
|
||||||
|
@ -546,7 +545,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
|
|
||||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||||
for attr in self.referenced_attrs():
|
for attr in self.referenced_attrs():
|
||||||
if isinstance(attr, six.string_types):
|
if isinstance(attr, str):
|
||||||
key, path = attr, []
|
key, path = attr, []
|
||||||
else:
|
else:
|
||||||
key, path = attr[0], list(attr[1:])
|
key, path = attr[0], list(attr[1:])
|
||||||
|
@ -611,7 +610,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
if isinstance(snippet, collections.Mapping):
|
if isinstance(snippet, collections.Mapping):
|
||||||
return dict((k, ignore_param_resolve(v))
|
return dict((k, ignore_param_resolve(v))
|
||||||
for k, v in snippet.items())
|
for k, v in snippet.items())
|
||||||
elif (not isinstance(snippet, six.string_types) and
|
elif (not isinstance(snippet, str) and
|
||||||
isinstance(snippet, collections.Iterable)):
|
isinstance(snippet, collections.Iterable)):
|
||||||
return [ignore_param_resolve(v) for v in snippet]
|
return [ignore_param_resolve(v) for v in snippet]
|
||||||
|
|
||||||
|
@ -639,7 +638,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
def recurse(x):
|
def recurse(x):
|
||||||
return self._handle_repl_val(res_name, x)
|
return self._handle_repl_val(res_name, x)
|
||||||
|
|
||||||
if isinstance(val, six.string_types):
|
if isinstance(val, str):
|
||||||
return val.replace(repl_var, res_name)
|
return val.replace(repl_var, res_name)
|
||||||
elif isinstance(val, collections.Mapping):
|
elif isinstance(val, collections.Mapping):
|
||||||
return {k: recurse(v) for k, v in val.items()}
|
return {k: recurse(v) for k, v in val.items()}
|
||||||
|
@ -706,7 +705,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||||
|
|
||||||
old_resources = sorted(valid_resources, key=replace_priority)
|
old_resources = sorted(valid_resources, key=replace_priority)
|
||||||
existing_names = set(n for n, d in valid_resources)
|
existing_names = set(n for n, d in valid_resources)
|
||||||
new_names = six.moves.filterfalse(lambda n: n in existing_names,
|
new_names = itertools.filterfalse(lambda n: n in existing_names,
|
||||||
names)
|
names)
|
||||||
res_def = self.get_resource_def(include_all)
|
res_def = self.get_resource_def(include_all)
|
||||||
definitions = scl_template.member_definitions(
|
definitions = scl_template.member_definitions(
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import six
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
|
@ -186,9 +185,9 @@ class AutoScalingPolicy(signal_responder.SignalResponder):
|
||||||
if self.resource_id is None:
|
if self.resource_id is None:
|
||||||
return
|
return
|
||||||
if name == self.ALARM_URL:
|
if name == self.ALARM_URL:
|
||||||
return six.text_type(self._get_ec2_signed_url())
|
return str(self._get_ec2_signed_url())
|
||||||
elif name == self.SIGNAL_URL:
|
elif name == self.SIGNAL_URL:
|
||||||
return six.text_type(self._get_heat_signal_url())
|
return str(self._get_heat_signal_url())
|
||||||
|
|
||||||
|
|
||||||
def resource_mapping():
|
def resource_mapping():
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import six
|
import itertools
|
||||||
from six import itertools
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
@ -749,7 +748,7 @@ class SoftwareDeploymentGroup(resource_group.ResourceGroup):
|
||||||
|
|
||||||
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
def _nested_output_defns(self, resource_names, get_attr_fn, get_res_fn):
|
||||||
for attr in self.referenced_attrs():
|
for attr in self.referenced_attrs():
|
||||||
key = attr if isinstance(attr, six.string_types) else attr[0]
|
key = attr if isinstance(attr, str) else attr[0]
|
||||||
n_attr = self._member_attribute_name(key)
|
n_attr = self._member_attribute_name(key)
|
||||||
output_name = self._attribute_output_name(self.ATTR_ATTRIBUTES,
|
output_name = self._attribute_output_name(self.ATTR_ATTRIBUTES,
|
||||||
n_attr)
|
n_attr)
|
||||||
|
|
Loading…
Reference in New Issue