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. Change-Id: Ib1659e903aded26994cc5cd56881a21e102964fe Needed-By: https://review.opendev.org/701743
This commit is contained in:
parent
bfce75ee8c
commit
2525137219
|
@ -12,7 +12,6 @@
|
|||
|
||||
from django.urls import reverse
|
||||
import mock
|
||||
import six
|
||||
|
||||
from sahara_dashboard import api
|
||||
from sahara_dashboard.test import helpers as test
|
||||
|
@ -42,7 +41,7 @@ class DataProcessingPluginsTests(test.TestCase):
|
|||
res = self.client.get(DETAILS_URL)
|
||||
self.assert_mock_multiple_calls_with_same_arguments(
|
||||
self.mock_plugin_get, 2, mock.call(test.IsHttpRequest(),
|
||||
test.IsA(six.text_type)))
|
||||
test.IsA(str)))
|
||||
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
|
||||
self.assertContains(res, 'vanilla')
|
||||
self.assertContains(res, 'plugin')
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from saharaclient.api import base as api_base
|
||||
import six
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
@ -44,8 +43,7 @@ class UpdateLabelsAction(workflows.Action):
|
|||
for name, label in labels.items():
|
||||
if not label['mutable']:
|
||||
continue
|
||||
res_name_translated = "%s: %s" % (six.text_type(prefix_trans),
|
||||
name)
|
||||
res_name_translated = "%s: %s" % (prefix_trans, name)
|
||||
res_name = "label_%s%s" % (prefix, name)
|
||||
self.fields[res_name] = forms.BooleanField(
|
||||
label=res_name_translated,
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
from django.urls import reverse
|
||||
import mock
|
||||
import six
|
||||
|
||||
from sahara_dashboard import api
|
||||
from sahara_dashboard.test import helpers as test
|
||||
|
@ -127,9 +126,9 @@ class DataProcessingDataSourceTests(test.TestCase):
|
|||
res = self.client.post(EDIT_URL, form_data)
|
||||
|
||||
self.mock_data_source_get.assert_called_once_with(
|
||||
IsHttpRequest(), IsA(six.text_type))
|
||||
IsHttpRequest(), IsA(str))
|
||||
self.mock_data_source_update.assert_called_once_with(
|
||||
IsHttpRequest(), IsA(six.text_type), api_data)
|
||||
IsHttpRequest(), IsA(str), api_data)
|
||||
self.assertNoFormErrors(res)
|
||||
self.assertRedirectsNoFollow(res, INDEX_URL)
|
||||
self.assertMessageCount(success=1)
|
||||
|
@ -161,9 +160,9 @@ class DataProcessingDataSourceTests(test.TestCase):
|
|||
IsHttpRequest(), IsA(str))
|
||||
self.mock_data_source_create.assert_called_once_with(
|
||||
IsHttpRequest(),
|
||||
IsA(six.text_type),
|
||||
IsA(six.text_type),
|
||||
IsA(six.text_type),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
'', '', is_public=False, is_protected=False, s3_credentials=None)
|
||||
self.mock_share_list.assert_called_once_with(IsHttpRequest())
|
||||
|
@ -186,11 +185,11 @@ class DataProcessingDataSourceTests(test.TestCase):
|
|||
self.mock_data_source_create.return_value = True
|
||||
self.mock_data_source_create.assert_called_once_with(
|
||||
IsHttpRequest(),
|
||||
IsA(six.text_type),
|
||||
IsA(six.text_type),
|
||||
IsA(six.text_type),
|
||||
IsA(six.text_type),
|
||||
IsA(six.text_type),
|
||||
IsA(six.text_type),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
IsA(str),
|
||||
is_public=False, is_protected=False, s3_credentials=IsA(dict))
|
||||
self.assertNoFormErrors(res)
|
||||
|
|
|
@ -11,8 +11,9 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from urllib import parse
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import six
|
||||
|
||||
from horizon import exceptions
|
||||
|
||||
|
@ -61,14 +62,12 @@ class EditDataSource(create.CreateDataSource):
|
|||
if self.FIELD_MAP[field]:
|
||||
if (field == "data_source_url" and
|
||||
data_source.type == "manila"):
|
||||
fields[field].initial = (
|
||||
six.moves.urllib.parse.urlparse(
|
||||
data_source.url).path)
|
||||
fields[field].initial = parse.urlparse(
|
||||
data_source.url).path
|
||||
elif (field == "data_source_manila_share"
|
||||
and data_source.type == "manila"):
|
||||
fields[field].initial = (
|
||||
six.moves.urllib.parse.urlparse(
|
||||
data_source.url).netloc)
|
||||
fields[field].initial = parse.urlparse(
|
||||
data_source.url).netloc
|
||||
else:
|
||||
fields[field].initial = (
|
||||
getattr(data_source,
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from urllib import parse
|
||||
import uuid
|
||||
|
||||
from django.forms import widgets
|
||||
|
@ -19,7 +20,6 @@ from django.template import defaultfilters
|
|||
from django.utils.encoding import force_text
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import six
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
@ -245,7 +245,7 @@ class JobBinaryCreateForm(forms.SelfHandlingForm):
|
|||
getattr(jb, self.FIELD_MAP[field], None))
|
||||
|
||||
def set_initial_values_by_type(self, url):
|
||||
parsed = six.moves.urllib.parse.urlparse(url)
|
||||
parsed = parse.urlparse(url)
|
||||
self.fields["job_binary_type"].initial = parsed.scheme
|
||||
if parsed.scheme == "manila":
|
||||
self.fields["job_binary_manila_share"].initial = parsed.netloc
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
from django.urls import reverse
|
||||
import mock
|
||||
import six
|
||||
|
||||
from sahara_dashboard import api
|
||||
from sahara_dashboard.test import helpers as test
|
||||
|
@ -51,7 +50,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
|
|||
self.assertTemplateUsed(res, 'horizon/common/_detail.html')
|
||||
self.assert_mock_multiple_calls_with_same_arguments(
|
||||
self.mock_job_binary_get, 2,
|
||||
mock.call(test.IsHttpRequest(), test.IsA(six.text_type)))
|
||||
mock.call(test.IsHttpRequest(), test.IsA(str)))
|
||||
|
||||
@test.create_mocks({api.sahara: ('job_binary_list',
|
||||
'job_binary_get',
|
||||
|
@ -71,7 +70,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
|
|||
self.mock_job_binary_list.assert_called_once_with(
|
||||
test.IsHttpRequest())
|
||||
self.mock_job_binary_get.assert_called_once_with(
|
||||
test.IsHttpRequest(), test.IsA(six.text_type))
|
||||
test.IsHttpRequest(), test.IsA(str))
|
||||
self.mock_job_binary_delete.assert_called_once_with(
|
||||
test.IsHttpRequest(), jb_list[0].id)
|
||||
self.mock_job_binary_internal_delete.assert_called_once_with(
|
||||
|
@ -92,7 +91,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
|
|||
self.assertTrue(res.has_header('content-disposition'))
|
||||
|
||||
self.mock_job_binary_get.assert_called_once_with(
|
||||
test.IsHttpRequest(), test.IsA(six.text_type))
|
||||
test.IsHttpRequest(), test.IsA(str))
|
||||
self.mock_job_binary_get_file.assert_called_once_with(
|
||||
test.IsHttpRequest(), jb.id)
|
||||
|
||||
|
@ -113,7 +112,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
|
|||
'attachment; filename="%s"' % jb.name
|
||||
)
|
||||
self.mock_job_binary_get.assert_called_once_with(
|
||||
test.IsHttpRequest(), test.IsA(six.text_type))
|
||||
test.IsHttpRequest(), test.IsA(str))
|
||||
self.mock_job_binary_get_file.assert_called_once_with(
|
||||
test.IsHttpRequest(), jb.id)
|
||||
|
||||
|
@ -141,7 +140,7 @@ class DataProcessingJobBinaryTests(test.TestCase):
|
|||
res = self.client.post(EDIT_URL, form_data)
|
||||
self.assertNoFormErrors(res)
|
||||
self.mock_job_binary_get.assert_called_once_with(
|
||||
test.IsHttpRequest(), test.IsA(six.text_type))
|
||||
test.IsHttpRequest(), test.IsA(str))
|
||||
self.mock_job_binary_update.assert_called_once_with(
|
||||
test.IsHttpRequest(), test.IsA(str), test.IsA(dict))
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# limitations under the License.
|
||||
|
||||
from pytz import timezone as ptz
|
||||
import six
|
||||
|
||||
from django.template import defaultfilters as filters
|
||||
from django.utils import timezone
|
||||
|
@ -149,7 +148,7 @@ class Helpers(object):
|
|||
end_datetime = timeutils.utcnow(True)
|
||||
end_datetime = end_datetime.replace(microsecond=0)
|
||||
|
||||
return six.text_type(end_datetime - start_datetime)
|
||||
return str(end_datetime - start_datetime)
|
||||
|
||||
def to_time_zone(self, datetime, tzone=None,
|
||||
input_fmt=None, localize=False):
|
||||
|
|
|
@ -16,7 +16,6 @@ from oslo_log import log as logging
|
|||
from django.core.exceptions import ValidationError
|
||||
from django.utils import safestring
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import six
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
@ -180,7 +179,7 @@ def parse_configs_from_context(context, defaults):
|
|||
configs_dict[service] = dict()
|
||||
if val is None:
|
||||
continue
|
||||
if six.text_type(defaults[service][config]) == six.text_type(val):
|
||||
if str(defaults[service][config]) == str(val):
|
||||
continue
|
||||
configs_dict[service][config] = val
|
||||
return configs_dict
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
import base64
|
||||
import copy
|
||||
import six
|
||||
from six.moves.urllib import parse
|
||||
from urllib import parse
|
||||
|
||||
|
||||
def serialize(obj):
|
||||
|
@ -27,8 +26,7 @@ def serialize(obj):
|
|||
result = base64.urlsafe_b64encode(obj)
|
||||
# this workaround is needed because in case of python 3 the
|
||||
# urlsafe_b64encode method returns string of 'bytes' class.
|
||||
if six.PY3:
|
||||
result = result.decode()
|
||||
result = result.decode()
|
||||
return result
|
||||
|
||||
|
||||
|
@ -40,8 +38,7 @@ def deserialize(obj):
|
|||
result = base64.urlsafe_b64decode(obj)
|
||||
# this workaround is needed because in case of python 3 the
|
||||
# urlsafe_b64decode method returns string of 'bytes' class
|
||||
if six.PY3:
|
||||
result = result.decode()
|
||||
result = result.decode()
|
||||
return result
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue