diff options
author | Hervé Beraud <hberaud@redhat.com> | 2019-11-20 19:37:26 +0100 |
---|---|---|
committer | Hervé Beraud <hberaud@redhat.com> | 2020-04-22 12:23:44 +0200 |
commit | 5877da06a15644086a6fc15019d94a7947a09210 (patch) | |
tree | 53b2c01c4c1bb695f7262f86a44f969264a1fd3e /heat/common | |
parent | fccd3128715a02a9ade74095d75ba18414bf997d (diff) | |
download | heat-5877da06a15644086a6fc15019d94a7947a09210.tar.gz |
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 4 of a serie of 28 patches
Change-Id: I871c2dad10abc35790e730c7c4c5272f499b7623
Diffstat (limited to 'heat/common')
-rw-r--r-- | heat/common/template_format.py | 7 | ||||
-rw-r--r-- | heat/common/urlfetch.py | 4 | ||||
-rw-r--r-- | heat/common/wsgi.py | 8 |
3 files changed, 9 insertions, 10 deletions
diff --git a/heat/common/template_format.py b/heat/common/template_format.py index 282487889..9978bf0ab 100644 --- a/heat/common/template_format.py +++ b/heat/common/template_format.py @@ -15,7 +15,6 @@ import collections from oslo_config import cfg from oslo_serialization import jsonutils -import six import yaml from heat.common import exception @@ -73,7 +72,7 @@ def simple_parse(tmpl_str, tmpl_url=None): except yaml.YAMLError as yea: if tmpl_url is None: tmpl_url = '[root stack]' - yea = six.text_type(yea) + yea = str(yea) msg = _('Error parsing template %(tmpl)s ' '%(yea)s') % {'tmpl': tmpl_url, 'yea': yea} raise ValueError(msg) @@ -111,7 +110,7 @@ def parse(tmpl_str, tmpl_url=None): # TODO(ricolin): Move this validation to api side. # Validate nested stack template. - validate_template_limit(six.text_type(tmpl_str)) + validate_template_limit(str(tmpl_str)) tpl = simple_parse(tmpl_str, tmpl_url) # Looking for supported version keys in the loaded template @@ -136,7 +135,7 @@ def convert_json_to_yaml(json_str): def top_level_items(tpl): yield ("HeatTemplateFormatVersion", '2012-12-12') - for k, v in six.iteritems(tpl): + for k, v in tpl.items(): if k != 'AWSTemplateFormatVersion': yield k, v diff --git a/heat/common/urlfetch.py b/heat/common/urlfetch.py index 54cc90027..633c309c0 100644 --- a/heat/common/urlfetch.py +++ b/heat/common/urlfetch.py @@ -14,12 +14,14 @@ """Utility for fetching a resource (e.g. a template) from a URL.""" import socket +import urllib.error +import urllib.parse +import urllib.request from oslo_config import cfg from oslo_log import log as logging import requests from requests import exceptions -from six.moves import urllib from heat.common import exception from heat.common.i18n import _ diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index 15ec9e58e..ed673ce7b 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -40,7 +40,6 @@ from oslo_utils import encodeutils from oslo_utils import importutils from paste.deploy import loadwsgi from routes import middleware -import six import webob.dec import webob.exc @@ -648,7 +647,7 @@ class Debug(Middleware): resp = req.get_response(self.application) print(("*" * 40) + " RESPONSE HEADERS") - for (key, value) in six.iteritems(resp.headers): + for (key, value) in resp.headers.items(): print(key, "=", value) print('') @@ -823,7 +822,7 @@ class JSONRequestDeserializer(object): raise exception.RequestLimitExceeded(message=msg) return jsonutils.loads(datastring) except ValueError as ex: - raise webob.exc.HTTPBadRequest(six.text_type(ex)) + raise webob.exc.HTTPBadRequest(str(ex)) def default(self, request): if self.has_body(request): @@ -1004,8 +1003,7 @@ def translate_exception(exc, locale): return exc -@six.add_metaclass(abc.ABCMeta) -class BasePasteFactory(object): +class BasePasteFactory(object, metaclass=abc.ABCMeta): """A base class for paste app and filter factories. Sub-classes must override the KEY class attribute and provide |