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
requestsexceptions==1.2.0
simplejson==3.5.1
six==1.10.0
snowballstemmer==1.2.1
stevedore==1.20.0
testrepository==0.0.18
@ -67,6 +66,5 @@ testscenarios==0.4
testtools==2.2.0
tosca-parser==1.6.1
traceback2==1.4.0
unittest2==1.1.0
warlock==1.2.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
PyYAML>=3.13 # MIT
python-dateutil>=2.5.3 # BSD
six>=1.10.0 # MIT
tosca-parser>=1.6.1 # Apache-2.0
keystoneauth1>=3.4.0 # Apache-2.0
python-novaclient>=9.1.0 # Apache-2.0

View File

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

View File

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

View File

@ -1,4 +1,3 @@
#
# 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
# a copy of the License at
@ -12,11 +11,9 @@
# under the License.
from collections import OrderedDict
import yaml
import logging
import os
import six
import yaml
from toscaparser.elements.interfaces import InterfacesDef
from toscaparser.functions import GetInput
@ -402,17 +399,17 @@ class HotResource(object):
def _get_lifecycle_inputs(self, operation):
# check if this lifecycle operation has input values specified
# extract and convert to HOT format
if isinstance(operation.value, six.string_types):
if isinstance(operation.value, str):
# the operation has a static string
return {}
else:
# the operation is a dict {'implemenation': xxx, 'input': yyy}
inputs = operation.value.get('inputs')
deploy_inputs = {}
if inputs:
for name, value in inputs.items():
deploy_inputs[name] = value
return deploy_inputs
# the operation is a dict {'implemenation': xxx, 'input': yyy}
inputs = operation.value.get('inputs')
deploy_inputs = {}
if inputs:
for name, value in inputs.items():
deploy_inputs[name] = value
return deploy_inputs
def _get_connect_inputs(self, config_location, operation):
if config_location == 'target':
@ -588,19 +585,18 @@ class HotResource(object):
@staticmethod
def get_base_type_str(node_type):
if isinstance(node_type, six.string_types):
if isinstance(node_type, str):
return node_type
if node_type.parent_type is not 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
else:
parent_type_str = node_type.parent_type.type
if parent_type_str and parent_type_str.endswith('.Root'):
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

View File

@ -1,4 +1,3 @@
#
# 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
# a copy of the License at
@ -12,7 +11,7 @@
# under the License.
import logging
import six
from toscaparser.utils.gettextutils import _
from translator.hot.syntax.hot_template import HotTemplate
from translator.hot.translate_inputs import TranslateInputs
@ -64,7 +63,7 @@ class TOSCATranslator(object):
yaml_files = self.hot_template.output_to_yaml_files_dict(
"output.yaml",
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":
with open(name, 'w+') as f:
f.write(content)

View File

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

View File

@ -16,7 +16,6 @@ import codecs
import logging
import logging.config
import os
import six
import sys
import uuid
import yaml
@ -289,7 +288,7 @@ class TranslatorShell(object):
if output_file:
path, filename = os.path.split(output_file)
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:
f.write(content)
else:

View File

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