Remove six support

This update is to remove six support for dropping python2 from
heat-translator. Only the example of dockerfile is remained in which
it's expected libs are installed under `/usr/local/lib/python2.7`, so
it should also be considered to be updated later.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
Change-Id: Iafbd1588674c95d6b6ec6b5429f2d34fb23081d0
This commit is contained in:
Yasufumi Ogawa 2020-12-11 16:59:10 +00:00
parent 1823e8595d
commit 4809045ed5
9 changed files with 22 additions and 34 deletions

View File

@ -59,7 +59,6 @@ PyYAML==3.13
requests==2.18.0 requests==2.18.0
requestsexceptions==1.2.0 requestsexceptions==1.2.0
simplejson==3.5.1 simplejson==3.5.1
six==1.10.0
snowballstemmer==1.2.1 snowballstemmer==1.2.1
stevedore==1.20.0 stevedore==1.20.0
testrepository==0.0.18 testrepository==0.0.18
@ -67,6 +66,5 @@ testscenarios==0.4
testtools==2.2.0 testtools==2.2.0
tosca-parser==1.6.1 tosca-parser==1.6.1
traceback2==1.4.0 traceback2==1.4.0
unittest2==1.1.0
warlock==1.2.0 warlock==1.2.0
wrapt==1.7.0 wrapt==1.7.0

View File

@ -6,7 +6,6 @@ Babel!=2.4.0,>=2.3.4 # BSD
cliff!=2.9.0,>=2.8.0 # Apache-2.0 cliff!=2.9.0,>=2.8.0 # Apache-2.0
PyYAML>=3.13 # MIT PyYAML>=3.13 # MIT
python-dateutil>=2.5.3 # BSD python-dateutil>=2.5.3 # BSD
six>=1.10.0 # MIT
tosca-parser>=1.6.1 # Apache-2.0 tosca-parser>=1.6.1 # Apache-2.0
keystoneauth1>=3.4.0 # Apache-2.0 keystoneauth1>=3.4.0 # Apache-2.0
python-novaclient>=9.1.0 # Apache-2.0 python-novaclient>=9.1.0 # Apache-2.0

View File

@ -18,9 +18,8 @@ import numbers
import os import os
import re import re
import requests import requests
import six
from six.moves.urllib.parse import urlparse
import tempfile import tempfile
from urllib.parse import urlparse
import yaml import yaml
import zipfile import zipfile
@ -278,7 +277,7 @@ class UrlUtils(object):
def str_to_num(value): def str_to_num(value):
"""Convert a string representation of a number into a numeric type.""" """Convert a string representation of a number into a numeric type."""
if isinstance(value, numbers.Number) \ if isinstance(value, numbers.Number) \
or isinstance(value, six.integer_types) \ or isinstance(value, int) \
or isinstance(value, float): or isinstance(value, float):
return value return value
try: try:

View File

@ -12,10 +12,9 @@
# under the License. # under the License.
''' Provide a global configuration for the TOSCA translator''' ''' Provide a global configuration for the TOSCA translator'''
import configparser
import os import os
from six.moves import configparser
from toscaparser.utils.gettextutils import _ from toscaparser.utils.gettextutils import _
import translator.common.exception as exception import translator.common.exception as exception

View File

@ -1,4 +1,3 @@
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
@ -12,11 +11,9 @@
# under the License. # under the License.
from collections import OrderedDict from collections import OrderedDict
import yaml
import logging import logging
import os import os
import six import yaml
from toscaparser.elements.interfaces import InterfacesDef from toscaparser.elements.interfaces import InterfacesDef
from toscaparser.functions import GetInput from toscaparser.functions import GetInput
@ -402,10 +399,10 @@ class HotResource(object):
def _get_lifecycle_inputs(self, operation): def _get_lifecycle_inputs(self, operation):
# check if this lifecycle operation has input values specified # check if this lifecycle operation has input values specified
# extract and convert to HOT format # extract and convert to HOT format
if isinstance(operation.value, six.string_types): if isinstance(operation.value, str):
# the operation has a static string # the operation has a static string
return {} return {}
else:
# the operation is a dict {'implemenation': xxx, 'input': yyy} # the operation is a dict {'implemenation': xxx, 'input': yyy}
inputs = operation.value.get('inputs') inputs = operation.value.get('inputs')
deploy_inputs = {} deploy_inputs = {}
@ -588,18 +585,17 @@ class HotResource(object):
@staticmethod @staticmethod
def get_base_type_str(node_type): def get_base_type_str(node_type):
if isinstance(node_type, six.string_types): if isinstance(node_type, str):
return node_type return node_type
if node_type.parent_type is not None: if node_type.parent_type is not None:
parent_type_str = None parent_type_str = None
if isinstance(node_type.parent_type, six.string_types): if isinstance(node_type.parent_type, str):
parent_type_str = node_type.parent_type parent_type_str = node_type.parent_type
else: else:
parent_type_str = node_type.parent_type.type parent_type_str = node_type.parent_type.type
if parent_type_str and parent_type_str.endswith('.Root'): if parent_type_str and parent_type_str.endswith('.Root'):
return node_type.type return node_type.type
else:
return HotResource.get_base_type_str(node_type.parent_type) return HotResource.get_base_type_str(node_type.parent_type)
return node_type.type return node_type.type

View File

@ -1,4 +1,3 @@
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
# a copy of the License at # a copy of the License at
@ -12,7 +11,7 @@
# under the License. # under the License.
import logging import logging
import six
from toscaparser.utils.gettextutils import _ from toscaparser.utils.gettextutils import _
from translator.hot.syntax.hot_template import HotTemplate from translator.hot.syntax.hot_template import HotTemplate
from translator.hot.translate_inputs import TranslateInputs from translator.hot.translate_inputs import TranslateInputs
@ -64,7 +63,7 @@ class TOSCATranslator(object):
yaml_files = self.hot_template.output_to_yaml_files_dict( yaml_files = self.hot_template.output_to_yaml_files_dict(
"output.yaml", "output.yaml",
self.node_translator.hot_template_version) self.node_translator.hot_template_version)
for name, content in six.iteritems(yaml_files): for name, content in yaml_files.items():
if name != "output.yaml": if name != "output.yaml":
with open(name, 'w+') as f: with open(name, 'w+') as f:
f.write(content) f.write(content)

View File

@ -15,7 +15,6 @@ import copy
import importlib import importlib
import logging import logging
import os import os
import six
from collections import OrderedDict from collections import OrderedDict
from toscaparser.functions import Concat from toscaparser.functions import Concat
@ -140,7 +139,7 @@ log = logging.getLogger('heat-translator')
TOSCA_TO_HOT_TYPE = _generate_type_map() TOSCA_TO_HOT_TYPE = _generate_type_map()
BASE_TYPES = six.string_types + six.integer_types + (dict, OrderedDict) BASE_TYPES = (str, int, dict, OrderedDict)
BASE_POLICY_TYPES = [ BASE_POLICY_TYPES = [
'tosca.policies.Scaling', 'tosca.policies.Scaling',
@ -326,7 +325,7 @@ class TranslateNodeTemplates(object):
else: else:
target = details target = details
if (target and relation and if (target and relation and
not isinstance(relation, six.string_types)): not isinstance(relation, str)):
interfaces = relation.get('interfaces') interfaces = relation.get('interfaces')
connectsto_resources += \ connectsto_resources += \
self._create_connect_configs(node, self._create_connect_configs(node,

View File

@ -16,7 +16,6 @@ import codecs
import logging import logging
import logging.config import logging.config
import os import os
import six
import sys import sys
import uuid import uuid
import yaml import yaml
@ -289,7 +288,7 @@ class TranslatorShell(object):
if output_file: if output_file:
path, filename = os.path.split(output_file) path, filename = os.path.split(output_file)
yaml_files = translator.translate_to_yaml_files_dict(filename) yaml_files = translator.translate_to_yaml_files_dict(filename)
for name, content in six.iteritems(yaml_files): for name, content in yaml_files.items():
with open(os.path.join(path, name), 'w+') as f: with open(os.path.join(path, name), 'w+') as f:
f.write(content) f.write(content)
else: else:

View File

@ -36,7 +36,7 @@ def reload_config(func):
class ConfTest(TestCase): class ConfTest(TestCase):
@reload_config @reload_config
@mock.patch('six.moves.configparser.ConfigParser') @mock.patch('configparser.ConfigParser')
def test_load_config(self, mock_config_parser): def test_load_config(self, mock_config_parser):
translatorConfig._translator_config.read = mock.MagicMock() translatorConfig._translator_config.read = mock.MagicMock()
translatorConfig._load_config('fake_file.conf') translatorConfig._load_config('fake_file.conf')