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 11 of a serie of 28 patches Change-Id: I1d796ac4dbe29217ed87015cde21597dbcd4cf9b
This commit is contained in:
parent
e6a6468eef
commit
e8c52040da
|
@ -14,7 +14,6 @@
|
|||
import copy
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
import yaml
|
||||
|
||||
from heat.common import exception
|
||||
|
@ -555,7 +554,7 @@ class Workflow(signal_responder.SignalResponder,
|
|||
if props.get(self.TASK_DEFAULTS) is not None:
|
||||
definition[defn_name][self.TASK_DEFAULTS.replace('_', '-')] = {
|
||||
k.replace('_', '-'): v for k, v in
|
||||
six.iteritems(props.get(self.TASK_DEFAULTS)) if v}
|
||||
props.get(self.TASK_DEFAULTS).items() if v}
|
||||
|
||||
return yaml.dump(definition, Dumper=yaml.CSafeDumper
|
||||
if hasattr(yaml, 'CSafeDumper')
|
||||
|
@ -647,8 +646,8 @@ class Workflow(signal_responder.SignalResponder,
|
|||
'created_at': execution.created_at,
|
||||
'updated_at': execution.updated_at,
|
||||
'state': execution.state,
|
||||
'input': jsonutils.loads(six.text_type(execution.input)),
|
||||
'output': jsonutils.loads(six.text_type(execution.output))
|
||||
'input': jsonutils.loads(str(execution.input)),
|
||||
'output': jsonutils.loads(str(execution.output))
|
||||
}
|
||||
|
||||
return [parse_execution_response(
|
||||
|
@ -661,7 +660,7 @@ class Workflow(signal_responder.SignalResponder,
|
|||
self.INPUT: self.properties.get(self.INPUT)}
|
||||
|
||||
elif name == self.ALARM_URL and self.resource_id is not None:
|
||||
return six.text_type(self._get_ec2_signed_url())
|
||||
return str(self._get_ec2_signed_url())
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
# under the License.
|
||||
|
||||
import re
|
||||
from six.moves import urllib
|
||||
from urllib import parse
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -115,7 +115,7 @@ class MonascaNotification(resource.Resource):
|
|||
|
||||
if self.properties[self.TYPE] == self.WEBHOOK:
|
||||
try:
|
||||
parsed_address = urllib.parse.urlparse(address)
|
||||
parsed_address = parse.urlparse(address)
|
||||
except Exception:
|
||||
msg = _('Address "%(addr)s" should have correct format '
|
||||
'required by "%(wh)s" type of "%(type)s" '
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import constraints
|
||||
|
@ -62,7 +60,7 @@ class ExtraRoute(neutron.NeutronResource):
|
|||
|
||||
def add_dependencies(self, deps):
|
||||
super(ExtraRoute, self).add_dependencies(deps)
|
||||
for resource in six.itervalues(self.stack):
|
||||
for resource in self.stack.values():
|
||||
# depend on any RouterInterface in this template with the same
|
||||
# router_id as this router_id
|
||||
if resource.has_interface('OS::Neutron::RouterInterface'):
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
@ -238,7 +237,7 @@ class FloatingIP(neutron.NeutronResource):
|
|||
except Exception as exc:
|
||||
LOG.info("Ignoring Neutron error while "
|
||||
"getting FloatingIP dependencies: %s",
|
||||
six.text_type(exc))
|
||||
str(exc))
|
||||
return False
|
||||
else:
|
||||
try:
|
||||
|
@ -265,7 +264,7 @@ class FloatingIP(neutron.NeutronResource):
|
|||
def add_dependencies(self, deps):
|
||||
super(FloatingIP, self).add_dependencies(deps)
|
||||
|
||||
for resource in six.itervalues(self.stack):
|
||||
for resource in self.stack.values():
|
||||
# depend on any RouterGateway in this template with the same
|
||||
# network_id as this floating_network_id
|
||||
if resource.has_interface('OS::Neutron::RouterGateway'):
|
||||
|
@ -388,7 +387,7 @@ class FloatingIPAssociation(neutron.NeutronResource):
|
|||
def add_dependencies(self, deps):
|
||||
super(FloatingIPAssociation, self).add_dependencies(deps)
|
||||
|
||||
for resource in six.itervalues(self.stack):
|
||||
for resource in self.stack.values():
|
||||
if resource.has_interface('OS::Neutron::RouterInterface'):
|
||||
|
||||
def port_on_subnet(resource, subnet):
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
# under the License.
|
||||
|
||||
import collections
|
||||
import six
|
||||
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import properties
|
||||
|
@ -111,7 +110,7 @@ class L2Gateway(neutron.NeutronResource):
|
|||
return dict((k, L2Gateway._remove_none_value_props(v)) for k, v
|
||||
in props.items() if v is not None)
|
||||
elif (isinstance(props, collections.Sequence) and
|
||||
not isinstance(props, six.string_types)):
|
||||
not isinstance(props, str)):
|
||||
return list(L2Gateway._remove_none_value_props(l) for l in props
|
||||
if l is not None)
|
||||
return props
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
from oslo_log import log as logging
|
||||
from oslo_serialization import jsonutils
|
||||
import six
|
||||
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
|
@ -437,7 +436,7 @@ class Port(neutron.NeutronResource):
|
|||
# It is not known which subnet a port might be assigned
|
||||
# to so all subnets in a network should be created before
|
||||
# the ports in that network.
|
||||
for res in six.itervalues(self.stack):
|
||||
for res in self.stack.values():
|
||||
if res.has_interface('OS::Neutron::Subnet'):
|
||||
try:
|
||||
dep_network = res.properties.get(subnet.Subnet.NETWORK)
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
from heat.engine import attributes
|
||||
|
@ -266,7 +264,7 @@ class Router(neutron.NeutronResource):
|
|||
external_gw = self.properties[self.EXTERNAL_GATEWAY]
|
||||
if external_gw:
|
||||
external_gw_net = external_gw.get(self.EXTERNAL_GATEWAY_NETWORK)
|
||||
for res in six.itervalues(self.stack):
|
||||
for res in self.stack.values():
|
||||
if res.has_interface('OS::Neutron::Subnet'):
|
||||
try:
|
||||
subnet_net = res.properties.get(subnet.Subnet.NETWORK)
|
||||
|
@ -639,7 +637,7 @@ class RouterGateway(neutron.NeutronResource):
|
|||
|
||||
def add_dependencies(self, deps):
|
||||
super(RouterGateway, self).add_dependencies(deps)
|
||||
for resource in six.itervalues(self.stack):
|
||||
for resource in self.stack.values():
|
||||
# depend on any RouterInterface in this template with the same
|
||||
# router_id as this router_id
|
||||
if resource.has_interface('OS::Neutron::RouterInterface'):
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -123,7 +122,7 @@ class NovaFloatingIp(resource.Resource):
|
|||
self.POOL_ATTR: floating_ip['floatingip']['floating_network_id'],
|
||||
self.IP: floating_ip['floatingip']['floating_ip_address']
|
||||
}
|
||||
return six.text_type(attributes[key])
|
||||
return str(attributes[key])
|
||||
|
||||
|
||||
class NovaFloatingIpAssociation(resource.Resource):
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -192,7 +191,7 @@ class KeyPair(resource.Resource):
|
|||
def _resolve_attribute(self, key):
|
||||
attr_fn = {self.PRIVATE_KEY_ATTR: self.private_key,
|
||||
self.PUBLIC_KEY_ATTR: self.public_key}
|
||||
return six.text_type(attr_fn[key])
|
||||
return str(attr_fn[key])
|
||||
|
||||
def get_reference_id(self):
|
||||
return self.resource_id
|
||||
|
|
|
@ -16,7 +16,6 @@ import copy
|
|||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common.i18n import _
|
||||
|
@ -944,8 +943,8 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin,
|
|||
server, server_data = resource_data
|
||||
result = {
|
||||
# there's a risk that flavor id will be int type, so cast to str
|
||||
self.FLAVOR: six.text_type(server_data.get(self.FLAVOR)['id']),
|
||||
self.IMAGE: six.text_type(server_data.get(self.IMAGE)['id']),
|
||||
self.FLAVOR: str(server_data.get(self.FLAVOR)['id']),
|
||||
self.IMAGE: str(server_data.get(self.IMAGE)['id']),
|
||||
self.NAME: server_data.get(self.NAME),
|
||||
self.METADATA: server_data.get(self.METADATA),
|
||||
self.NETWORKS: self._get_live_networks(server, resource_properties)
|
||||
|
@ -985,7 +984,7 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin,
|
|||
reality_net_ids.get(net_id).pop(idx)
|
||||
break
|
||||
|
||||
for key, value in six.iteritems(reality_nets):
|
||||
for key, value in reality_nets.items():
|
||||
for address in reality_nets[key]:
|
||||
new_net = {self.NETWORK_ID: key,
|
||||
self.NETWORK_FIXED_IP: address['addr']}
|
||||
|
@ -1232,7 +1231,7 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin,
|
|||
return
|
||||
if not nets:
|
||||
return
|
||||
for res in six.itervalues(self.stack):
|
||||
for res in self.stack.values():
|
||||
if res.has_interface('OS::Neutron::Subnet'):
|
||||
try:
|
||||
subnet_net = res.properties.get(subnet.Subnet.NETWORK)
|
||||
|
|
Loading…
Reference in New Issue