Stop using six library
Since we've dropped support for Python 2.7, it's time to look at the bright future that Python 3.x will bring and stop forcing compatibility with older versions. This patch removes the six library from requirements, not looking back. Change-Id: I19384db89fc2a68376efc3f9f2e05fbd05046fd6
This commit is contained in:
@@ -10,6 +10,5 @@ pbr==2.0.0
|
|||||||
PrettyTable==0.7.2
|
PrettyTable==0.7.2
|
||||||
Pygments==2.2.0
|
Pygments==2.2.0
|
||||||
requests==2.18.4
|
requests==2.18.4
|
||||||
six==1.10.0
|
|
||||||
stestr==1.0.0
|
stestr==1.0.0
|
||||||
testtools==2.2.0
|
testtools==2.2.0
|
||||||
|
@@ -17,7 +17,6 @@ import logging
|
|||||||
|
|
||||||
from openstack import connection
|
from openstack import connection
|
||||||
from openstack import exceptions as os_exc
|
from openstack import exceptions as os_exc
|
||||||
import six
|
|
||||||
|
|
||||||
from metalsmith import _instance
|
from metalsmith import _instance
|
||||||
from metalsmith import _nics
|
from metalsmith import _nics
|
||||||
@@ -143,7 +142,7 @@ class Provisioner(object):
|
|||||||
"""Create an allocation with given parameters."""
|
"""Create an allocation with given parameters."""
|
||||||
if candidates:
|
if candidates:
|
||||||
candidates = [
|
candidates = [
|
||||||
(node.id if not isinstance(node, six.string_types) else node)
|
(node.id if not isinstance(node, str) else node)
|
||||||
for node in candidates
|
for node in candidates
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -370,7 +369,7 @@ class Provisioner(object):
|
|||||||
"""
|
"""
|
||||||
if config is None:
|
if config is None:
|
||||||
config = instance_config.GenericConfig()
|
config = instance_config.GenericConfig()
|
||||||
if isinstance(image, six.string_types):
|
if isinstance(image, str):
|
||||||
image = sources.GlanceImage(image)
|
image = sources.GlanceImage(image)
|
||||||
|
|
||||||
_utils.check_hostname(hostname)
|
_utils.check_hostname(hostname)
|
||||||
@@ -620,7 +619,7 @@ class Provisioner(object):
|
|||||||
|
|
||||||
def _get_node(self, node, refresh=False):
|
def _get_node(self, node, refresh=False):
|
||||||
"""A helper to find and return a node."""
|
"""A helper to find and return a node."""
|
||||||
if isinstance(node, six.string_types):
|
if isinstance(node, str):
|
||||||
return self.connection.baremetal.get_node(node)
|
return self.connection.baremetal.get_node(node)
|
||||||
elif hasattr(node, 'node'):
|
elif hasattr(node, 'node'):
|
||||||
# Instance object
|
# Instance object
|
||||||
@@ -635,7 +634,7 @@ class Provisioner(object):
|
|||||||
|
|
||||||
def _find_node_and_allocation(self, node, refresh=False):
|
def _find_node_and_allocation(self, node, refresh=False):
|
||||||
try:
|
try:
|
||||||
if (not isinstance(node, six.string_types)
|
if (not isinstance(node, str)
|
||||||
or not _utils.is_hostname_safe(node)):
|
or not _utils.is_hostname_safe(node)):
|
||||||
return self._get_node(node, refresh=refresh), None
|
return self._get_node(node, refresh=refresh), None
|
||||||
|
|
||||||
|
@@ -17,8 +17,6 @@ import abc
|
|||||||
import collections
|
import collections
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import six
|
|
||||||
|
|
||||||
from metalsmith import _utils
|
from metalsmith import _utils
|
||||||
from metalsmith import exceptions
|
from metalsmith import exceptions
|
||||||
|
|
||||||
@@ -26,8 +24,7 @@ from metalsmith import exceptions
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class Filter(object, metaclass=abc.ABCMeta):
|
||||||
class Filter(object):
|
|
||||||
"""Base class for filters."""
|
"""Base class for filters."""
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
@@ -19,7 +19,6 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from openstack import exceptions as os_exc
|
from openstack import exceptions as os_exc
|
||||||
import six
|
|
||||||
|
|
||||||
from metalsmith import exceptions
|
from metalsmith import exceptions
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ def is_hostname_safe(hostname):
|
|||||||
:param hostname: The hostname to be validated.
|
:param hostname: The hostname to be validated.
|
||||||
:returns: True if valid. False if not.
|
:returns: True if valid. False if not.
|
||||||
"""
|
"""
|
||||||
if not isinstance(hostname, six.string_types) or len(hostname) > 255:
|
if not isinstance(hostname, str) or len(hostname) > 255:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return _HOSTNAME_RE.match(hostname) is not None
|
return _HOSTNAME_RE.match(hostname) is not None
|
||||||
@@ -144,4 +143,4 @@ def reraise_os_exc(reraise_as, failure_message='Clean up failed'):
|
|||||||
if is_expected:
|
if is_expected:
|
||||||
raise reraise_as(str(exc_info[1]))
|
raise reraise_as(str(exc_info[1]))
|
||||||
else:
|
else:
|
||||||
six.reraise(*exc_info)
|
raise exc_info[1]
|
||||||
|
@@ -18,11 +18,11 @@
|
|||||||
import abc
|
import abc
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import openstack.exceptions
|
import openstack.exceptions
|
||||||
import requests
|
import requests
|
||||||
import six
|
|
||||||
from six.moves.urllib import parse as urlparse
|
|
||||||
|
|
||||||
from metalsmith import _utils
|
from metalsmith import _utils
|
||||||
from metalsmith import exceptions
|
from metalsmith import exceptions
|
||||||
@@ -31,8 +31,7 @@ from metalsmith import exceptions
|
|||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@six.add_metaclass(abc.ABCMeta)
|
class _Source(object, metaclass=abc.ABCMeta):
|
||||||
class _Source(object):
|
|
||||||
|
|
||||||
def _validate(self, connection, root_size_gb):
|
def _validate(self, connection, root_size_gb):
|
||||||
"""Validate the source."""
|
"""Validate the source."""
|
||||||
|
@@ -13,12 +13,12 @@
|
|||||||
# 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 io
|
||||||
import json
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from metalsmith import _cmd
|
from metalsmith import _cmd
|
||||||
@@ -146,7 +146,7 @@ class TestDeploy(testtools.TestCase):
|
|||||||
|
|
||||||
args = ['deploy', '--network', 'mynet', '--image', 'myimg',
|
args = ['deploy', '--network', 'mynet', '--image', 'myimg',
|
||||||
'--resource-class', 'compute']
|
'--resource-class', 'compute']
|
||||||
fake_io = six.StringIO()
|
fake_io = io.StringIO()
|
||||||
with mock.patch('sys.stdout', fake_io):
|
with mock.patch('sys.stdout', fake_io):
|
||||||
self._check(mock_pr, args, {}, {}, formatter='json')
|
self._check(mock_pr, args, {}, {}, formatter='json')
|
||||||
self.assertEqual(json.loads(fake_io.getvalue()),
|
self.assertEqual(json.loads(fake_io.getvalue()),
|
||||||
@@ -601,7 +601,7 @@ class TestUndeploy(testtools.TestCase):
|
|||||||
node.to_dict.return_value = {'node': 'dict'}
|
node.to_dict.return_value = {'node': 'dict'}
|
||||||
|
|
||||||
args = ['--format', 'json', 'undeploy', '123456']
|
args = ['--format', 'json', 'undeploy', '123456']
|
||||||
fake_io = six.StringIO()
|
fake_io = io.StringIO()
|
||||||
with mock.patch('sys.stdout', fake_io):
|
with mock.patch('sys.stdout', fake_io):
|
||||||
_cmd.main(args)
|
_cmd.main(args)
|
||||||
self.assertEqual(json.loads(fake_io.getvalue()),
|
self.assertEqual(json.loads(fake_io.getvalue()),
|
||||||
@@ -747,7 +747,7 @@ class TestShowWait(testtools.TestCase):
|
|||||||
mock_pr.return_value.show_instances.return_value = self.instances
|
mock_pr.return_value.show_instances.return_value = self.instances
|
||||||
args = ['--format', 'json', 'show', 'uuid1', 'hostname2']
|
args = ['--format', 'json', 'show', 'uuid1', 'hostname2']
|
||||||
|
|
||||||
fake_io = six.StringIO()
|
fake_io = io.StringIO()
|
||||||
with mock.patch('sys.stdout', fake_io):
|
with mock.patch('sys.stdout', fake_io):
|
||||||
_cmd.main(args)
|
_cmd.main(args)
|
||||||
self.assertEqual(json.loads(fake_io.getvalue()),
|
self.assertEqual(json.loads(fake_io.getvalue()),
|
||||||
@@ -773,7 +773,7 @@ class TestShowWait(testtools.TestCase):
|
|||||||
mock_pr.return_value.list_instances.return_value = self.instances
|
mock_pr.return_value.list_instances.return_value = self.instances
|
||||||
args = ['--format', 'json', 'list']
|
args = ['--format', 'json', 'list']
|
||||||
|
|
||||||
fake_io = six.StringIO()
|
fake_io = io.StringIO()
|
||||||
with mock.patch('sys.stdout', fake_io):
|
with mock.patch('sys.stdout', fake_io):
|
||||||
_cmd.main(args)
|
_cmd.main(args)
|
||||||
self.assertEqual(json.loads(fake_io.getvalue()),
|
self.assertEqual(json.loads(fake_io.getvalue()),
|
||||||
@@ -786,7 +786,7 @@ class TestShowWait(testtools.TestCase):
|
|||||||
self.instances)
|
self.instances)
|
||||||
args = ['--format', 'json', 'wait', 'uuid1', 'hostname2']
|
args = ['--format', 'json', 'wait', 'uuid1', 'hostname2']
|
||||||
|
|
||||||
fake_io = six.StringIO()
|
fake_io = io.StringIO()
|
||||||
with mock.patch('sys.stdout', fake_io):
|
with mock.patch('sys.stdout', fake_io):
|
||||||
_cmd.main(args)
|
_cmd.main(args)
|
||||||
self.assertEqual(json.loads(fake_io.getvalue()),
|
self.assertEqual(json.loads(fake_io.getvalue()),
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
import six
|
|
||||||
|
|
||||||
from metalsmith import _instance
|
from metalsmith import _instance
|
||||||
from metalsmith.test import test_provisioner
|
from metalsmith.test import test_provisioner
|
||||||
@@ -136,7 +135,7 @@ class TestInstanceStates(test_provisioner.Base):
|
|||||||
'uuid': self.node.id},
|
'uuid': self.node.id},
|
||||||
to_dict)
|
to_dict)
|
||||||
# States are converted to strings
|
# States are converted to strings
|
||||||
self.assertIsInstance(to_dict['state'], six.string_types)
|
self.assertIsInstance(to_dict['state'], str)
|
||||||
|
|
||||||
@mock.patch.object(_instance.Instance, 'ip_addresses', autospec=True)
|
@mock.patch.object(_instance.Instance, 'ip_addresses', autospec=True)
|
||||||
def test_to_dict_with_allocation(self, mock_ips):
|
def test_to_dict_with_allocation(self, mock_ips):
|
||||||
@@ -156,4 +155,4 @@ class TestInstanceStates(test_provisioner.Base):
|
|||||||
'uuid': self.node.id},
|
'uuid': self.node.id},
|
||||||
to_dict)
|
to_dict)
|
||||||
# States are converted to strings
|
# States are converted to strings
|
||||||
self.assertIsInstance(to_dict['state'], six.string_types)
|
self.assertIsInstance(to_dict['state'], str)
|
||||||
|
@@ -4,5 +4,4 @@
|
|||||||
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
||||||
openstacksdk>=0.29.0 # Apache-2.0
|
openstacksdk>=0.29.0 # Apache-2.0
|
||||||
requests>=2.18.4 # Apache-2.0
|
requests>=2.18.4 # Apache-2.0
|
||||||
six>=1.10.0 # MIT
|
|
||||||
PrettyTable<0.8,>=0.7.2 # BSD
|
PrettyTable<0.8,>=0.7.2 # BSD
|
||||||
|
Reference in New Issue
Block a user