Skip to content

Commit a48c05b

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove usage of six"
2 parents 960004d + c2df921 commit a48c05b

15 files changed

Lines changed: 30 additions & 51 deletions

File tree

doc/source/contributor/developing.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ Example
203203
204204
from osc_lib.api import auth
205205
from osc_lib import utils
206-
import six
207206
208207
from openstackclient import shell
209208
from openstackclient.tests import utils

lower-constraints.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ rfc3986==0.3.1
119119
Routes==2.3.1
120120
rsd-lib==0.1.0
121121
simplejson==3.5.1
122-
six==1.10.0
123122
smmap==0.9.0
124123
statsd==3.2.1
125124
stestr==1.0.0

openstackclient/api/object_store_v1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import logging
1818
import os
1919
import sys
20+
import urllib
2021

2122
from osc_lib import utils
22-
from six.moves import urllib
2323

2424
from openstackclient.api import api
2525

openstackclient/common/sdk_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
# License for the specific language governing permissions and limitations
1111
# under the License.
1212

13-
import six
14-
1513

1614
def get_osc_show_columns_for_sdk_resource(
1715
sdk_resource,
@@ -44,7 +42,7 @@ def get_osc_show_columns_for_sdk_resource(
4442
for col_name in invisible_columns:
4543
if col_name in display_columns:
4644
display_columns.remove(col_name)
47-
for sdk_attr, osc_attr in six.iteritems(osc_column_map):
45+
for sdk_attr, osc_attr in osc_column_map.items():
4846
if sdk_attr in display_columns:
4947
attr_map[osc_attr] = sdk_attr
5048
display_columns.remove(sdk_attr)

openstackclient/compute/v2/server.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from osc_lib import exceptions
3131
from osc_lib import utils
3232
from oslo_utils import timeutils
33-
import six
3433

3534
from openstackclient.i18n import _
3635
from openstackclient.identity import common as identity_common
@@ -97,7 +96,7 @@ def _get_ip_address(addresses, address_type, ip_address_family):
9796
for network in addresses:
9897
for addy in addresses[network]:
9998
# Case where it is list of strings
100-
if isinstance(addy, six.string_types):
99+
if isinstance(addy, str):
101100
if new_address_type == 'fixed':
102101
return addresses[network][0]
103102
else:
@@ -894,7 +893,7 @@ def _match_image(image_api, wanted_properties):
894893
boot_args = [parsed_args.server_name, image, flavor]
895894

896895
# Handle block device by device name order, like: vdb -> vdc -> vdd
897-
for dev_name in sorted(six.iterkeys(parsed_args.block_device_mapping)):
896+
for dev_name in sorted(parsed_args.block_device_mapping):
898897
dev_map = parsed_args.block_device_mapping[dev_name]
899898
dev_map = dev_map.split(':')
900899
if dev_map[0]:

openstackclient/identity/v3/access_rule.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from osc_lib.command import command
2121
from osc_lib import exceptions
2222
from osc_lib import utils
23-
import six
2423

2524
from openstackclient.i18n import _
2625
from openstackclient.identity import common
@@ -115,4 +114,4 @@ def take_action(self, parsed_args):
115114

116115
access_rule._info.pop('links', None)
117116

118-
return zip(*sorted(six.iteritems(access_rule._info)))
117+
return zip(*sorted(access_rule._info.items()))

openstackclient/network/common.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import openstack.exceptions
1919
from osc_lib.command import command
2020
from osc_lib import exceptions
21-
import six
2221

2322
from openstackclient.i18n import _
2423

@@ -54,8 +53,7 @@ def check_missing_extension_if_error(client_manager, attrs):
5453
raise
5554

5655

57-
@six.add_metaclass(abc.ABCMeta)
58-
class NetDetectionMixin(object):
56+
class NetDetectionMixin(metaclass=abc.ABCMeta):
5957
"""Convenience methods for nova-network vs. neutron decisions.
6058
6159
A live environment detects which network type it is running and creates its
@@ -166,8 +164,8 @@ def take_action_compute(self, client, parsed_args):
166164
pass
167165

168166

169-
@six.add_metaclass(abc.ABCMeta)
170-
class NetworkAndComputeCommand(NetDetectionMixin, command.Command):
167+
class NetworkAndComputeCommand(NetDetectionMixin, command.Command,
168+
metaclass=abc.ABCMeta):
171169
"""Network and Compute Command
172170
173171
Command class for commands that support implementation via
@@ -178,8 +176,8 @@ class NetworkAndComputeCommand(NetDetectionMixin, command.Command):
178176
pass
179177

180178

181-
@six.add_metaclass(abc.ABCMeta)
182-
class NetworkAndComputeDelete(NetworkAndComputeCommand):
179+
class NetworkAndComputeDelete(NetworkAndComputeCommand,
180+
metaclass=abc.ABCMeta):
183181
"""Network and Compute Delete
184182
185183
Delete class for commands that support implementation via
@@ -222,8 +220,8 @@ def take_action(self, parsed_args):
222220
raise exceptions.CommandError(msg)
223221

224222

225-
@six.add_metaclass(abc.ABCMeta)
226-
class NetworkAndComputeLister(NetDetectionMixin, command.Lister):
223+
class NetworkAndComputeLister(NetDetectionMixin, command.Lister,
224+
metaclass=abc.ABCMeta):
227225
"""Network and Compute Lister
228226
229227
Lister class for commands that support implementation via
@@ -234,8 +232,8 @@ class NetworkAndComputeLister(NetDetectionMixin, command.Lister):
234232
pass
235233

236234

237-
@six.add_metaclass(abc.ABCMeta)
238-
class NetworkAndComputeShowOne(NetDetectionMixin, command.ShowOne):
235+
class NetworkAndComputeShowOne(NetDetectionMixin, command.ShowOne,
236+
metaclass=abc.ABCMeta):
239237
"""Network and Compute ShowOne
240238
241239
ShowOne class for commands that support implementation via
@@ -255,5 +253,5 @@ def take_action(self, parsed_args):
255253
except openstack.exceptions.HttpException as exc:
256254
msg = _("Error while executing command: %s") % exc.message
257255
if exc.details:
258-
msg += ", " + six.text_type(exc.details)
256+
msg += ", " + str(exc.details)
259257
raise exceptions.CommandError(msg)

openstackclient/shell.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@
1616

1717
"""Command-line interface to the OpenStack APIs"""
1818

19-
import locale
2019
import sys
2120

2221
from osc_lib.api import auth
2322
from osc_lib.command import commandmanager
2423
from osc_lib import shell
25-
import six
2624

2725
import openstackclient
2826
from openstackclient.common import clientmanager
@@ -143,12 +141,6 @@ def initialize_app(self, argv):
143141
def main(argv=None):
144142
if argv is None:
145143
argv = sys.argv[1:]
146-
if six.PY2:
147-
# Emulate Py3, decode argv into Unicode based on locale so that
148-
# commands always see arguments as text instead of binary data
149-
encoding = locale.getpreferredencoding()
150-
if encoding:
151-
argv = map(lambda arg: arg.decode(encoding), argv)
152144

153145
return OpenStackShell().run(argv)
154146

openstackclient/tests/unit/compute/v2/test_server.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
from osc_lib import exceptions
2525
from osc_lib import utils as common_utils
2626
from oslo_utils import timeutils
27-
import six
2827

2928
from openstackclient.compute.v2 import server
3029
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
@@ -1908,7 +1907,7 @@ def test_server_create_volume_boot_from_volume_conflict(self):
19081907
self.cmd.take_action, parsed_args)
19091908
# Assert it is the error we expect.
19101909
self.assertIn('--volume is not allowed with --boot-from-volume',
1911-
six.text_type(ex))
1910+
str(ex))
19121911

19131912
def test_server_create_image_property(self):
19141913
arglist = [
@@ -3289,7 +3288,7 @@ def test_server_migrate_with_host_pre_2_56(self):
32893288
# Make sure it's the error we expect.
32903289
self.assertIn('--os-compute-api-version 2.56 or greater is required '
32913290
'to use --host without --live-migration.',
3292-
six.text_type(ex))
3291+
str(ex))
32933292

32943293
self.servers_mock.get.assert_called_with(self.server.id)
32953294
self.assertNotCalled(self.servers_mock.live_migrate)
@@ -3324,7 +3323,7 @@ def test_server_live_migrate(self):
33243323
# A warning should have been logged for using --live.
33253324
mock_warning.assert_called_once()
33263325
self.assertIn('The --live option has been deprecated.',
3327-
six.text_type(mock_warning.call_args[0][0]))
3326+
str(mock_warning.call_args[0][0]))
33283327

33293328
def test_server_live_migrate_host_pre_2_30(self):
33303329
# Tests that the --host option is not supported for --live-migration
@@ -3347,7 +3346,7 @@ def test_server_live_migrate_host_pre_2_30(self):
33473346

33483347
# Make sure it's the error we expect.
33493348
self.assertIn('--os-compute-api-version 2.30 or greater is required '
3350-
'when using --host', six.text_type(ex))
3349+
'when using --host', str(ex))
33513350

33523351
self.servers_mock.get.assert_called_with(self.server.id)
33533352
self.assertNotCalled(self.servers_mock.live_migrate)
@@ -3437,7 +3436,7 @@ def test_server_live_migrate_without_host_override_live(self):
34373436
# A warning should have been logged for using --live.
34383437
mock_warning.assert_called_once()
34393438
self.assertIn('The --live option has been deprecated.',
3440-
six.text_type(mock_warning.call_args[0][0]))
3439+
str(mock_warning.call_args[0][0]))
34413440

34423441
def test_server_live_migrate_live_and_host_mutex(self):
34433442
# Tests specifying both the --live and --host options which are in a
@@ -4353,7 +4352,7 @@ def test_server_resize_confirm(self):
43534352
# A warning should have been logged for using --confirm.
43544353
mock_warning.assert_called_once()
43554354
self.assertIn('The --confirm option has been deprecated.',
4356-
six.text_type(mock_warning.call_args[0][0]))
4355+
str(mock_warning.call_args[0][0]))
43574356

43584357
def test_server_resize_revert(self):
43594358
arglist = [
@@ -4378,7 +4377,7 @@ def test_server_resize_revert(self):
43784377
# A warning should have been logged for using --revert.
43794378
mock_warning.assert_called_once()
43804379
self.assertIn('The --revert option has been deprecated.',
4381-
six.text_type(mock_warning.call_args[0][0]))
4380+
str(mock_warning.call_args[0][0]))
43824381

43834382
@mock.patch.object(common_utils, 'wait_for_status', return_value=True)
43844383
def test_server_resize_with_wait_ok(self, mock_wait_for_status):

openstackclient/tests/unit/compute/v2/test_service.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
from novaclient import api_versions
2020
from osc_lib import exceptions
21-
import six
2221

2322
from openstackclient.compute.v2 import service
2423
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
@@ -502,7 +501,7 @@ def test_service_set_find_service_by_host_and_binary_no_results(self):
502501
self.cmd._find_service_by_host_and_binary,
503502
self.service_mock, 'fake-host', 'nova-compute')
504503
self.assertIn('Compute service for host "fake-host" and binary '
505-
'"nova-compute" not found.', six.text_type(ex))
504+
'"nova-compute" not found.', str(ex))
506505

507506
def test_service_set_find_service_by_host_and_binary_many_results(self):
508507
# Tests that more than one compute service is found by host and binary.
@@ -512,4 +511,4 @@ def test_service_set_find_service_by_host_and_binary_many_results(self):
512511
self.service_mock, 'fake-host', 'nova-compute')
513512
self.assertIn('Multiple compute services found for host "fake-host" '
514513
'and binary "nova-compute". Unable to proceed.',
515-
six.text_type(ex))
514+
str(ex))

0 commit comments

Comments
 (0)