summaryrefslogtreecommitdiff
path: root/heat/objects
diff options
context:
space:
mode:
authorHervé Beraud <hberaud@redhat.com>2019-11-20 19:37:26 +0100
committerHervé Beraud <hberaud@redhat.com>2020-04-23 14:49:12 +0200
commit9bc5c23885afd82731aa037cf80081d66e268b88 (patch)
treec47bb3be16b627eea3bbe12b550a9c84add83dc9 /heat/objects
parent5fa48d67a23cc01babc50735346f12df4ed9bf61 (diff)
downloadheat-9bc5c23885afd82731aa037cf80081d66e268b88.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 14 of a serie of 28 patches Change-Id: Iccb743056c631f2e0728013942d764cd8b1ecfe0
Diffstat (limited to 'heat/objects')
-rw-r--r--heat/objects/fields.py3
-rw-r--r--heat/objects/resource.py11
-rw-r--r--heat/objects/stack.py5
3 files changed, 8 insertions, 11 deletions
diff --git a/heat/objects/fields.py b/heat/objects/fields.py
index 88290150d..19680f6d9 100644
--- a/heat/objects/fields.py
+++ b/heat/objects/fields.py
@@ -15,12 +15,11 @@
from oslo_serialization import jsonutils as json
from oslo_versionedobjects import fields
-import six
class Json(fields.FieldType):
def coerce(self, obj, attr, value):
- if isinstance(value, six.string_types):
+ if isinstance(value, str):
loaded = json.loads(value)
return loaded
return value
diff --git a/heat/objects/resource.py b/heat/objects/resource.py
index 3aba3405f..ecb38c97c 100644
--- a/heat/objects/resource.py
+++ b/heat/objects/resource.py
@@ -21,7 +21,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from oslo_versionedobjects import base
from oslo_versionedobjects import fields
-import six
import tenacity
from heat.common import crypt
@@ -57,7 +56,7 @@ class ResourceCache(object):
self.by_stack_id_name = collections.defaultdict(dict)
def set_by_stack_id(self, resources):
- for res in six.itervalues(resources):
+ for res in resources.values():
self.by_stack_id_name[res.stack_id][res.name] = res
@@ -190,7 +189,7 @@ class Resource(
resource_name,
cls._from_db_object(cls(context), context, resource_db)
)
- for resource_name, resource_db in six.iteritems(resources_db)
+ for resource_name, resource_db in resources_db.items()
]
return dict(resources)
@@ -246,7 +245,7 @@ class Resource(
resource_name,
cls._from_db_object(cls(context), context, resource_db)
)
- for resource_name, resource_db in six.iteritems(resources_db)
+ for resource_name, resource_db in resources_db.items()
]
return dict(resources)
@@ -259,7 +258,7 @@ class Resource(
resource_id,
cls._from_db_object(cls(context), context, resource_db)
)
- for resource_id, resource_db in six.iteritems(resources_db)
+ for resource_id, resource_db in resources_db.items()
]
return dict(resources)
@@ -280,7 +279,7 @@ class Resource(
context,
stack_id,
stack_id_only=True)
- return {db_res.stack_id for db_res in six.itervalues(resources_db)}
+ return {db_res.stack_id for db_res in resources_db.values()}
@classmethod
def purge_deleted(cls, context, stack_id):
diff --git a/heat/objects/stack.py b/heat/objects/stack.py
index a6904865d..349aaada8 100644
--- a/heat/objects/stack.py
+++ b/heat/objects/stack.py
@@ -18,7 +18,6 @@
from oslo_log import log as logging
from oslo_versionedobjects import base
from oslo_versionedobjects import fields
-import six
from heat.common import exception
from heat.common.i18n import _
@@ -117,7 +116,7 @@ class Stack(
def get_by_name_and_owner_id(cls, context, stack_name, owner_id):
db_stack = db_api.stack_get_by_name_and_owner_id(
context,
- six.text_type(stack_name),
+ str(stack_name),
owner_id
)
if not db_stack:
@@ -127,7 +126,7 @@ class Stack(
@classmethod
def get_by_name(cls, context, stack_name):
- db_stack = db_api.stack_get_by_name(context, six.text_type(stack_name))
+ db_stack = db_api.stack_get_by_name(context, str(stack_name))
if not db_stack:
return None
stack = cls._from_db_object(context, cls(context), db_stack)