Remove six package usage

Since py2 is no longer supported, built in methods can replace the
six package usage, as been done in the neutron project.

Change-Id: I435462c940e68fa48a910210e584cf139b3b9d95
This commit is contained in:
asarfaty 2020-07-19 12:07:38 +02:00
parent 6c921f1c93
commit dfe26e5f81
15 changed files with 16 additions and 40 deletions

View File

@ -1,8 +1,7 @@
# The order of packages is significant, because pip processes them in the order # The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration # of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later. # process, which may cause wedges in the gate later.
sphinx!=1.6.6,!=1.6.7,>=1.6.2,<2.0.0;python_version=='2.7' # BSD sphinx>=2.0.0,!=2.1.0 # BSD
sphinx!=1.6.6,!=1.6.7,>=1.6.2;python_version>='3.4' # BSD
oslosphinx>=4.7.0 # Apache-2.0 oslosphinx>=4.7.0 # Apache-2.0
openstackdocstheme>=1.18.1 # Apache-2.0 openstackdocstheme>=1.18.1 # Apache-2.0
oslotest>=3.2.0 # Apache-2.0 oslotest>=3.2.0 # Apache-2.0

View File

@ -20,7 +20,6 @@ python-subunit==1.0.0
pylint==1.7.1 pylint==1.7.1
reno==2.5.0 reno==2.5.0
requests-mock==1.2.0 requests-mock==1.2.0
six==1.10.0
sphinx==1.6.5 sphinx==1.6.5
stestr==1.0.0 stestr==1.0.0
tempest==17.1.0 tempest==17.1.0

View File

@ -8,7 +8,6 @@ decorator>=4.3.0 # BSD
eventlet>=0.24.1 # MIT eventlet>=0.24.1 # MIT
netaddr>=0.7.18 # BSD netaddr>=0.7.18 # BSD
tenacity>=5.0.1 # Apache-2.0 tenacity>=5.0.1 # Apache-2.0
six>=1.10.0 # MIT
oslo.i18n>=3.15.3 # Apache-2.0 oslo.i18n>=3.15.3 # Apache-2.0
oslo.log>=3.36.0 # Apache-2.0 oslo.log>=3.36.0 # Apache-2.0
oslo.serialization>=2.28.1 # Apache-2.0 oslo.serialization>=2.28.1 # Apache-2.0

View File

@ -12,11 +12,11 @@
# implied. # implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import requests from urllib import parse as urlparse
import six.moves.urllib.parse as urlparse
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
from oslo_utils import uuidutils from oslo_utils import uuidutils
import requests
from vmware_nsxlib.v3 import nsx_constants from vmware_nsxlib.v3 import nsx_constants

View File

@ -15,11 +15,11 @@
# #
import unittest import unittest
from unittest import mock from unittest import mock
from urllib import parse as urlparse
from requests import codes from requests import codes
from requests import exceptions as requests_exceptions from requests import exceptions as requests_exceptions
from requests import models from requests import models
import six.moves.urllib.parse as urlparse
from oslo_serialization import jsonutils from oslo_serialization import jsonutils

View File

@ -16,7 +16,6 @@
from unittest import mock from unittest import mock
from oslo_utils import uuidutils from oslo_utils import uuidutils
import six
from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase from vmware_nsxlib.tests.unit.v3 import nsxlib_testcase
from vmware_nsxlib.tests.unit.v3 import test_constants from vmware_nsxlib.tests.unit.v3 import test_constants
@ -482,7 +481,7 @@ class TestNsxLibNSGroup(nsxlib_testcase.NsxClientTestCase):
def test_get_nsgroup_lp_complex_expression(self): def test_get_nsgroup_lp_complex_expression(self):
port_tags = {'app': 'foo', 'project': 'myproject'} port_tags = {'app': 'foo', 'project': 'myproject'}
port_exp = [self.nsxlib.ns_group.get_port_tag_expression(k, v) port_exp = [self.nsxlib.ns_group.get_port_tag_expression(k, v)
for k, v in six.iteritems(port_tags)] for k, v in port_tags.items()]
complex_exp = self.nsxlib.ns_group.get_nsgroup_complex_expression( complex_exp = self.nsxlib.ns_group.get_nsgroup_complex_expression(
expressions=port_exp) expressions=port_exp)
expected_exp = {'resource_type': const.NSGROUP_COMPLEX_EXP, expected_exp = {'resource_type': const.NSGROUP_COMPLEX_EXP,
@ -492,7 +491,7 @@ class TestNsxLibNSGroup(nsxlib_testcase.NsxClientTestCase):
def test_get_nsgroup_ls_complex_expression(self): def test_get_nsgroup_ls_complex_expression(self):
switch_tags = {'app': 'foo', 'project': 'myproject'} switch_tags = {'app': 'foo', 'project': 'myproject'}
switch_exp = [self.nsxlib.ns_group.get_switch_tag_expression(k, v) switch_exp = [self.nsxlib.ns_group.get_switch_tag_expression(k, v)
for k, v in six.iteritems(switch_tags)] for k, v in switch_tags.items()]
complex_exp = self.nsxlib.ns_group.get_nsgroup_complex_expression( complex_exp = self.nsxlib.ns_group.get_nsgroup_complex_expression(
expressions=switch_exp) expressions=switch_exp)
expected_exp = {'resource_type': const.NSGROUP_COMPLEX_EXP, expected_exp = {'resource_type': const.NSGROUP_COMPLEX_EXP,

View File

@ -15,11 +15,12 @@
# #
import re import re
import time import time
from urllib import parse as urlparse
from oslo_log import log from oslo_log import log
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
import requests import requests
import six.moves.urllib.parse as urlparse
from vmware_nsxlib._i18n import _ from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import exceptions from vmware_nsxlib.v3 import exceptions
from vmware_nsxlib.v3 import utils from vmware_nsxlib.v3 import utils

View File

@ -23,6 +23,8 @@ import itertools
import logging import logging
import re import re
import time import time
from urllib import parse as urlparse
import urllib3
import eventlet import eventlet
from eventlet import greenpool from eventlet import greenpool
@ -32,9 +34,6 @@ from oslo_log import log
from oslo_service import loopingcall from oslo_service import loopingcall
import requests import requests
from requests import adapters from requests import adapters
import six
import six.moves.urllib.parse as urlparse
import urllib3
from vmware_nsxlib._i18n import _ from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import client as nsx_client from vmware_nsxlib.v3 import client as nsx_client
@ -53,8 +52,7 @@ logging.getLogger(
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
@six.add_metaclass(abc.ABCMeta) class AbstractHTTPProvider(object, metaclass=abc.ABCMeta):
class AbstractHTTPProvider(object):
"""Interface for providers of HTTP connections. """Interface for providers of HTTP connections.
which are responsible for creating and validating connections which are responsible for creating and validating connections

View File

@ -15,7 +15,6 @@
# #
from oslo_utils import excutils from oslo_utils import excutils
import six
from vmware_nsxlib._i18n import _ from vmware_nsxlib._i18n import _
@ -40,10 +39,6 @@ class NsxLibException(Exception):
# at least get the core message out if something happened # at least get the core message out if something happened
super(NsxLibException, self).__init__(self.message) super(NsxLibException, self).__init__(self.message)
if six.PY2:
def __unicode__(self):
return unicode(self.msg) if six.PY2 else self.msg # noqa
def __str__(self): def __str__(self):
return self.msg return self.msg

View File

@ -17,7 +17,6 @@ import abc
from distutils import version from distutils import version
from oslo_log import log from oslo_log import log
import six
from vmware_nsxlib._i18n import _ from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import client from vmware_nsxlib.v3 import client
@ -29,8 +28,7 @@ from vmware_nsxlib.v3 import utils
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@six.add_metaclass(abc.ABCMeta) class NsxLibBase(object, metaclass=abc.ABCMeta):
class NsxLibBase(object):
def __init__(self, nsxlib_config): def __init__(self, nsxlib_config):
self.nsx_version = None self.nsx_version = None

View File

@ -18,7 +18,6 @@ import abc
from distutils import version from distutils import version
from oslo_log import log as logging from oslo_log import log as logging
import six
from vmware_nsxlib.v3 import exceptions from vmware_nsxlib.v3 import exceptions
from vmware_nsxlib.v3 import nsx_constants from vmware_nsxlib.v3 import nsx_constants
@ -70,8 +69,7 @@ TIER1_LOCALE_SERVICES_PATH_PATTERN = (TIER1S_PATH_PATTERN +
"%s/locale-services/") "%s/locale-services/")
@six.add_metaclass(abc.ABCMeta) class ResourceDef(object, metaclass=abc.ABCMeta):
class ResourceDef(object):
def __init__(self, nsx_version=None, **kwargs): def __init__(self, nsx_version=None, **kwargs):
self.attrs = kwargs self.attrs = kwargs

View File

@ -22,7 +22,6 @@ import decorator
import eventlet import eventlet
from oslo_log import log as logging from oslo_log import log as logging
from oslo_utils import uuidutils from oslo_utils import uuidutils
import six
from vmware_nsxlib._i18n import _ from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import exceptions from vmware_nsxlib.v3 import exceptions
@ -56,8 +55,7 @@ def check_allowed_passthrough(f, *args, **kwargs):
return f(*args, **kwargs) return f(*args, **kwargs)
@six.add_metaclass(abc.ABCMeta) class NsxPolicyResourceBase(object, metaclass=abc.ABCMeta):
class NsxPolicyResourceBase(object):
"""Abstract class for NSX policy resources """Abstract class for NSX policy resources
declaring the basic apis each policy resource should support, declaring the basic apis each policy resource should support,

View File

@ -14,11 +14,9 @@
# under the License. # under the License.
# #
import abc
import copy import copy
from oslo_log import log as logging from oslo_log import log as logging
import six
from vmware_nsxlib._i18n import _ from vmware_nsxlib._i18n import _
from vmware_nsxlib.v3 import exceptions as nsxlib_exc from vmware_nsxlib.v3 import exceptions as nsxlib_exc
@ -1080,7 +1078,6 @@ class NsxPolicyLoadBalancerVirtualServerAPI(NsxPolicyResourceBase):
sleep=sleep, max_attempts=max_attempts) sleep=sleep, max_attempts=max_attempts)
@six.add_metaclass(abc.ABCMeta)
class NsxPolicyLBMonitorProfileBase(NsxPolicyResourceBase): class NsxPolicyLBMonitorProfileBase(NsxPolicyResourceBase):
"""NSX Policy LB monitor profile""" """NSX Policy LB monitor profile"""

View File

@ -15,13 +15,10 @@
import abc import abc
import six
# NOTE: Consider inheriting from an abstract TokenProvider class to share # NOTE: Consider inheriting from an abstract TokenProvider class to share
# interface with XSRF token # interface with XSRF token
@six.add_metaclass(abc.ABCMeta) class AbstractJWTProvider(object, metaclass=abc.ABCMeta):
class AbstractJWTProvider(object):
"""Interface for providers of JSON Web Tokens(JWT) """Interface for providers of JSON Web Tokens(JWT)
Responsible to provide the token value and refresh it once expired, Responsible to provide the token value and refresh it once expired,

View File

@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import six
from vmware_nsxlib.v3 import exceptions as nsxlib_exc from vmware_nsxlib.v3 import exceptions as nsxlib_exc
from vmware_nsxlib.v3 import utils from vmware_nsxlib.v3 import utils
@ -98,7 +96,7 @@ class NsxLibTrustManagement(utils.NsxLibApiBase):
def find_cert_and_identity(self, name, cert_pem): def find_cert_and_identity(self, name, cert_pem):
certs = self.get_certs() certs = self.get_certs()
if not isinstance(cert_pem, six.text_type): if not isinstance(cert_pem, str):
cert_pem = cert_pem.decode('ascii') cert_pem = cert_pem.decode('ascii')
cert_ids = [cert['id'] for cert in certs cert_ids = [cert['id'] for cert in certs