Merge "Drop Python 2 support"

This commit is contained in:
Zuul 2020-12-26 18:21:25 +00:00 committed by Gerrit Code Review
commit 3c5d2b6441
10 changed files with 20 additions and 33 deletions

View File

@ -29,7 +29,6 @@ pytz==2013.6
PyYAML==3.12
requests==2.14.2
requestsexceptions==1.2.0
six==1.10.0
snowballstemmer==1.2.1
stestr==2.0.0
stevedore==1.20.0

View File

@ -6,6 +6,5 @@ Babel!=2.4.0,>=2.3.4 # BSD
cliff!=2.9.0,>=2.8.0 # Apache-2.0
PyYAML>=3.12 # MIT
python-dateutil>=2.5.3 # BSD
six>=1.10.0 # MIT
stevedore>=1.20.0 # Apache-2.0
requests>=2.14.2 # Apache-2.0

View File

@ -13,7 +13,6 @@
import abc
import six
import toscaparser.elements.interfaces
from toscaparser.common.exception import ExceptionCollector
@ -42,8 +41,7 @@ SOURCE = 'SOURCE'
HOSTED_ON = 'tosca.relationships.HostedOn'
@six.add_metaclass(abc.ABCMeta)
class Function(object):
class Function(object, metaclass=abc.ABCMeta):
"""An abstract type for representing a Tosca template function."""
def __init__(self, tosca_tpl, context, name, args):

View File

@ -13,11 +13,12 @@
import os.path
import requests
import shutil
import six
import tempfile
import yaml
import zipfile
from io import BytesIO
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import URLException
from toscaparser.common.exception import ValidationError
@ -26,10 +27,6 @@ from toscaparser.utils.gettextutils import _
from toscaparser.utils.urlutils import UrlUtils
from toscaparser.utils import yamlparser
try: # Python 2.x
from BytesIO import BytesIO
except ImportError: # Python 3.x
from io import BytesIO
TOSCA_META = 'TOSCA-Metadata/TOSCA.meta'
@ -218,7 +215,7 @@ class CSAR(object):
artifacts = node_template['artifacts']
for artifact_key in artifacts:
artifact = artifacts[artifact_key]
if isinstance(artifact, six.string_types):
if isinstance(artifact, str):
self._validate_external_reference(
template,
artifact)
@ -239,7 +236,7 @@ class CSAR(object):
interface = interfaces[interface_key]
for opertation_key in interface:
operation = interface[opertation_key]
if isinstance(operation, six.string_types):
if isinstance(operation, str):
self._validate_external_reference(
template,
operation,

View File

@ -11,7 +11,7 @@
# under the License.
import os
import six
from toscaparser.common import exception
from toscaparser import functions
from toscaparser.tests.base import TestCase
@ -239,11 +239,11 @@ class GetAttributeTest(TestCase):
err = self.assertRaises(ValueError,
functions.get_function, None, None,
{'get_attribute': []})
self.assertIn(expected_msg, six.text_type(err))
self.assertIn(expected_msg, str(err))
err = self.assertRaises(ValueError,
functions.get_function, None, None,
{'get_attribute': ['x']})
self.assertIn(expected_msg, six.text_type(err))
self.assertIn(expected_msg, str(err))
def test_get_attribute_unknown_node_template_name(self):
self.assertRaises(

View File

@ -11,7 +11,7 @@
# under the License.
import os
import six
from toscaparser.common import exception
import toscaparser.elements.interfaces as ifaces
from toscaparser.elements.nodetype import NodeType
@ -468,7 +468,7 @@ class ToscaTemplateTest(TestCase):
lambda: NodeTemplate(name, nodetemplates,
custom_def).get_capabilities_objects())
self.assertEqual('Type "tosca.capabilities.TestCapability" is not '
'a valid type.', six.text_type(err))
'a valid type.', str(err))
def test_capability_without_properties(self):
expected_version = "tosca_simple_yaml_1_0"

View File

@ -11,7 +11,6 @@
# under the License.
import os
import six
from toscaparser.common import exception
from toscaparser.imports import ImportsLoader
@ -1441,7 +1440,7 @@ heat-translator/master/translator/tests/data/custom_types/wordpress.yaml
rel_template = RelationshipTemplate(rel_template[name], name)
err = self.assertRaises(exception.MissingRequiredFieldError,
rel_template.validate)
self.assertEqual(expectedmessage, six.text_type(err))
self.assertEqual(expectedmessage, str(err))
def test_invalid_template_version(self):
tosca_tpl = os.path.join(

View File

@ -11,18 +11,14 @@
# under the License.
from six.moves.urllib.parse import urljoin
from six.moves.urllib.parse import urlparse
import urllib.request as urllib2
from urllib.parse import urljoin
from urllib.parse import urlparse
from toscaparser.common.exception import ExceptionCollector
from toscaparser.utils.gettextutils import _
try:
# Python 3.x
import urllib.request as urllib2
except ImportError:
# Python 2.x
import urllib2
class UrlUtils(object):

View File

@ -15,7 +15,6 @@ import dateutil.parser
import logging
import numbers
import re
import six
# from toscaparser.elements import constraints
from toscaparser.common.exception import ExceptionCollector
@ -64,7 +63,7 @@ def validate_float(value):
def validate_string(value):
if not isinstance(value, six.string_types):
if not isinstance(value, str):
ExceptionCollector.appendException(
ValueError(_('"%s" is not a string.') % value))
return value

View File

@ -11,11 +11,11 @@
# under the License.
import codecs
from collections import OrderedDict
from six.moves import urllib
import urllib
import yaml
from collections import OrderedDict
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import URLException
from toscaparser.utils.gettextutils import _