From a150665d56051406383774110ed4e5f925e1cdda Mon Sep 17 00:00:00 2001 From: manchandavishal Date: Tue, 14 Jan 2020 04:07:45 +0000 Subject: [PATCH] Remove six usage This repo does not support Python 2 anymore, so we don't need six for compatibility between Python2 and 3, convert six usage to Python 3 code. Note that six.text_type is "str" in Python 3, so we can remove the clause completly. Change-Id: Icfb44404971b18ff865e28e551687707d52f3762 --- manila_ui/api/manila.py | 5 ++--- manila_ui/dashboards/admin/share_group_types/tables.py | 3 +-- manila_ui/dashboards/admin/share_groups/tables.py | 5 ++--- manila_ui/dashboards/admin/share_instances/tables.py | 5 ++--- manila_ui/dashboards/admin/share_networks/tables.py | 5 ++--- manila_ui/dashboards/admin/share_servers/tables.py | 5 ++--- manila_ui/dashboards/admin/share_types/tables.py | 3 +-- manila_ui/dashboards/admin/shares/forms.py | 3 +-- manila_ui/dashboards/project/share_groups/forms.py | 3 +-- manila_ui/dashboards/project/share_groups/tables.py | 5 ++--- manila_ui/dashboards/project/shares/forms.py | 4 +--- manila_ui/dashboards/project/shares/replicas/tables.py | 3 +-- manila_ui/tests/dashboards/project/shares/tests.py | 3 +-- requirements.txt | 1 - 14 files changed, 19 insertions(+), 34 deletions(-) diff --git a/manila_ui/api/manila.py b/manila_ui/api/manila.py index a40e1dde..31780544 100644 --- a/manila_ui/api/manila.py +++ b/manila_ui/api/manila.py @@ -23,7 +23,6 @@ from django.conf import settings from horizon import exceptions import logging from openstack_dashboard.api import base -import six from manilaclient import client as manila_client @@ -116,8 +115,8 @@ def share_delete(request, share_id, share_group_id=None): def share_update(request, share_id, name, description, is_public=''): share_data = {'display_name': name, 'display_description': description} - if not isinstance(is_public, six.string_types): - is_public = six.text_type(is_public) + if not isinstance(is_public, str): + is_public = str(is_public) if is_public and is_public.lower() != 'none': share_data['is_public'] = is_public return manilaclient(request).shares.update(share_id, **share_data) diff --git a/manila_ui/dashboards/admin/share_group_types/tables.py b/manila_ui/dashboards/admin/share_group_types/tables.py index d608f335..ee0c7d1f 100644 --- a/manila_ui/dashboards/admin/share_group_types/tables.py +++ b/manila_ui/dashboards/admin/share_group_types/tables.py @@ -16,7 +16,6 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from horizon import tables -import six from manila_ui.api import manila @@ -94,7 +93,7 @@ class ShareGroupTypesTable(tables.DataTable): return share_group_type.name def get_object_id(self, share_group_type): - return six.text_type(share_group_type.id) + return str(share_group_type.id) class Meta(object): name = "share_group_types" diff --git a/manila_ui/dashboards/admin/share_groups/tables.py b/manila_ui/dashboards/admin/share_groups/tables.py index acaaad31..c18b29ec 100644 --- a/manila_ui/dashboards/admin/share_groups/tables.py +++ b/manila_ui/dashboards/admin/share_groups/tables.py @@ -17,7 +17,6 @@ from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from horizon import tables -import six from manila_ui.api import manila @@ -108,10 +107,10 @@ class ShareGroupsTable(tables.DataTable): link=get_share_server_link) def get_object_display(self, share_group): - return six.text_type(share_group.id) + return str(share_group.id) def get_object_id(self, share_group): - return six.text_type(share_group.id) + return str(share_group.id) class Meta(object): name = "share_groups" diff --git a/manila_ui/dashboards/admin/share_instances/tables.py b/manila_ui/dashboards/admin/share_instances/tables.py index c2c2bf7e..371544dc 100644 --- a/manila_ui/dashboards/admin/share_instances/tables.py +++ b/manila_ui/dashboards/admin/share_instances/tables.py @@ -13,7 +13,6 @@ from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from horizon import tables -import six class ShareInstancesTable(tables.DataTable): @@ -87,7 +86,7 @@ class ShareInstancesTable(tables.DataTable): link=get_share_link) def get_object_display(self, share_instance): - return six.text_type(share_instance.id) + return str(share_instance.id) def get_object_id(self, share_instance): - return six.text_type(share_instance.id) + return str(share_instance.id) diff --git a/manila_ui/dashboards/admin/share_networks/tables.py b/manila_ui/dashboards/admin/share_networks/tables.py index a654989a..06db2277 100644 --- a/manila_ui/dashboards/admin/share_networks/tables.py +++ b/manila_ui/dashboards/admin/share_networks/tables.py @@ -12,7 +12,6 @@ from django.utils.translation import ugettext_lazy as _ from horizon import tables -import six import manila_ui.dashboards.project.share_networks.tables as sn_tables @@ -32,10 +31,10 @@ class ShareNetworksTable(tables.DataTable): "segmentation_id", verbose_name=_("Segmentation Id")) def get_object_display(self, share_network): - return share_network.name or six.text_type(share_network.id) + return share_network.name or str(share_network.id) def get_object_id(self, share_network): - return six.text_type(share_network.id) + return str(share_network.id) class Meta(object): name = "share_networks" diff --git a/manila_ui/dashboards/admin/share_servers/tables.py b/manila_ui/dashboards/admin/share_servers/tables.py index 3184bfcc..30fc4320 100644 --- a/manila_ui/dashboards/admin/share_servers/tables.py +++ b/manila_ui/dashboards/admin/share_servers/tables.py @@ -16,7 +16,6 @@ from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from horizon import tables -import six from manila_ui.api import manila @@ -99,10 +98,10 @@ class ShareServersTable(tables.DataTable): display_choices=STATUS_DISPLAY_CHOICES) def get_object_display(self, share_server): - return six.text_type(share_server.id) + return str(share_server.id) def get_object_id(self, share_server): - return six.text_type(share_server.id) + return str(share_server.id) class Meta(object): name = "share_servers" diff --git a/manila_ui/dashboards/admin/share_types/tables.py b/manila_ui/dashboards/admin/share_types/tables.py index d4c43d6e..680881da 100644 --- a/manila_ui/dashboards/admin/share_types/tables.py +++ b/manila_ui/dashboards/admin/share_types/tables.py @@ -13,7 +13,6 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from horizon import tables -import six from manila_ui.api import manila @@ -94,7 +93,7 @@ class ShareTypesTable(tables.DataTable): return share_type.name def get_object_id(self, share_type): - return six.text_type(share_type.id) + return str(share_type.id) class Meta(object): name = "share_types" diff --git a/manila_ui/dashboards/admin/shares/forms.py b/manila_ui/dashboards/admin/shares/forms.py index af46667e..59239a9c 100644 --- a/manila_ui/dashboards/admin/shares/forms.py +++ b/manila_ui/dashboards/admin/shares/forms.py @@ -21,7 +21,6 @@ from horizon import exceptions from horizon import forms from horizon import messages from oslo_utils import strutils -import six from manila_ui.api import manila from manila_ui.dashboards import utils @@ -251,7 +250,7 @@ class ManageShare(forms.SelfHandlingForm): driver_options_error_msg = _( "Got improper value for field 'driver_options'. " "Expected only pairs of key=value.") - if driver_options and isinstance(driver_options, six.string_types): + if driver_options and isinstance(driver_options, str): try: set_dict, unset_list = utils.parse_str_meta(driver_options) if unset_list: diff --git a/manila_ui/dashboards/project/share_groups/forms.py b/manila_ui/dashboards/project/share_groups/forms.py index d7cd2673..abd2640c 100644 --- a/manila_ui/dashboards/project/share_groups/forms.py +++ b/manila_ui/dashboards/project/share_groups/forms.py @@ -20,7 +20,6 @@ from horizon import exceptions from horizon import forms from horizon import messages from horizon.utils import memoized -import six from manila_ui.api import manila @@ -197,7 +196,7 @@ class CreateShareGroupForm(forms.SelfHandlingForm): if share_group_type: cleaned_data["share_types"] = cleaned_data.get( self.st_field_name_prefix + share_group_type) - if isinstance(cleaned_data["share_types"], six.string_types): + if isinstance(cleaned_data["share_types"], str): cleaned_data["share_types"] = [cleaned_data["share_types"]] else: self.errors.pop("sgt", None) diff --git a/manila_ui/dashboards/project/share_groups/tables.py b/manila_ui/dashboards/project/share_groups/tables.py index 59791192..2da055a8 100644 --- a/manila_ui/dashboards/project/share_groups/tables.py +++ b/manila_ui/dashboards/project/share_groups/tables.py @@ -17,7 +17,6 @@ from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from horizon import tables -import six from manila_ui.api import manila import manila_ui.dashboards.project.share_group_snapshots.tables as sgs_tables @@ -139,10 +138,10 @@ class ShareGroupsTable(tables.DataTable): link=get_source_share_group_snapshot_link) def get_object_display(self, share_group): - return six.text_type(share_group.id) + return str(share_group.id) def get_object_id(self, share_group): - return six.text_type(share_group.id) + return str(share_group.id) class Meta(object): name = "share_groups" diff --git a/manila_ui/dashboards/project/shares/forms.py b/manila_ui/dashboards/project/shares/forms.py index a943c8b0..9b1aa0fd 100644 --- a/manila_ui/dashboards/project/shares/forms.py +++ b/manila_ui/dashboards/project/shares/forms.py @@ -21,7 +21,6 @@ from horizon import exceptions from horizon import forms from horizon import messages from horizon.utils.memoized import memoized -import six from manila_ui.api import manila from manila_ui.dashboards import utils @@ -78,8 +77,7 @@ class CreateForm(forms.SelfHandlingForm): dhss = extra_specs.get('driver_handles_share_servers') # NOTE(vponomaryov): Set and tie share-network field only for # share types with enabled handling of share servers. - if (isinstance(dhss, six.string_types) and - dhss.lower() in ['true', '1']): + if (isinstance(dhss, str) and dhss.lower() in ['true', '1']): sn_choices = ( [('', '')] + [(sn.id, sn.name or sn.id) for sn in share_networks]) diff --git a/manila_ui/dashboards/project/shares/replicas/tables.py b/manila_ui/dashboards/project/shares/replicas/tables.py index 99e3464d..9d958a71 100644 --- a/manila_ui/dashboards/project/shares/replicas/tables.py +++ b/manila_ui/dashboards/project/shares/replicas/tables.py @@ -18,7 +18,6 @@ from django.urls import reverse from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy -import six from horizon import messages from horizon import tables @@ -176,7 +175,7 @@ class ReplicasTable(tables.DataTable): return obj.id def get_object_id(self, obj): - return six.text_type(obj.id) + return str(obj.id) class Meta(object): name = "replicas" diff --git a/manila_ui/tests/dashboards/project/shares/tests.py b/manila_ui/tests/dashboards/project/shares/tests.py index 5b4f8507..0a833f82 100644 --- a/manila_ui/tests/dashboards/project/shares/tests.py +++ b/manila_ui/tests/dashboards/project/shares/tests.py @@ -18,7 +18,6 @@ from django.urls import reverse from horizon import messages as horizon_messages import mock from openstack_dashboard.api import neutron -import six from manila_ui.api import manila as api_manila from manila_ui.dashboards.project.shares import forms @@ -290,7 +289,7 @@ class ShareViewTests(test.APITestCase): self.assertRedirectsNoFollow(res, INDEX_URL) api_manila.share_update.assert_called_once_with( mock.ANY, self.share, formData['name'], formData['description'], - is_public=six.text_type(formData['is_public'])) + is_public=str(formData['is_public'])) api_manila.share_get.assert_has_calls( [mock.call(mock.ANY, self.share.id) for i in (1, 2)]) diff --git a/requirements.txt b/requirements.txt index d114d40f..455a9479 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,6 +10,5 @@ iso8601>=0.1.11 # MIT oslo.utils>=3.33.0 # Apache-2.0 python-keystoneclient>=3.8.0 # Apache-2.0 python-manilaclient>=1.16.0 # Apache-2.0 -six>=1.10.0 # MIT horizon>=17.1.0 # Apache-2.0