From 8b5b8c17a0fcd8bdd77b1571fa8470af6a677774 Mon Sep 17 00:00:00 2001 From: niuke Date: Sat, 27 Aug 2022 14:49:57 +0800 Subject: [PATCH] remove unicode prefix from code All strings are considered as unicode string from Python 3. This patch drops the explicit unicode literal (u'...') appearances from the unicode strings. Change-Id: I2985c088d25201edcb0f31fa4a1223a9c840e050 --- README.rst | 2 +- releasenotes/source/conf.py | 16 +++++----- .../content/database_clusters/tests.py | 30 +++++++++---------- .../content/database_configurations/tests.py | 10 +++---- trove_dashboard/content/databases/forms.py | 2 +- trove_dashboard/content/databases/tests.py | 28 ++++++++--------- 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/README.rst b/README.rst index e5d82391..fccc6d7b 100644 --- a/README.rst +++ b/README.rst @@ -170,7 +170,7 @@ to use the same cache like the example below.:: CACHES = { 'default': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': [u'10.2.100.133:11211', u'10.2.100.134:11211''] + 'LOCATION': ['10.2.100.133:11211', '10.2.100.134:11211''] }, } diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 2a83f4f8..e0a6a8ad 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -54,9 +54,9 @@ openstackdocs_bug_tag = '' master_doc = 'index' # General information about the project. -project = u'Trove Dashboard Release Notes' -copyright = u'2016, Trove developers' -author = u'Trove developers' +project = 'Trove Dashboard Release Notes' +copyright = '2016, Trove developers' +author = 'Trove developers' # Release notes are version independent. # The short X.Y version. @@ -126,7 +126,7 @@ html_theme = 'openstackdocs' # The name for this set of Sphinx documents. # " v documentation" by default. -#html_title = u'Trove Dashboard Release Notes vblah' +#html_title = 'Trove Dashboard Release Notes vblah' # A shorter title for the navigation bar. Default is the same as html_title. #html_short_title = None @@ -230,8 +230,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'TroveDashboardReleaseNotes.tex', u'Trove Dashboard Release Notes Documentation', - u'Trove developers', 'manual'), + (master_doc, 'TroveDashboardReleaseNotes.tex', 'Trove Dashboard Release Notes Documentation', + 'Trove developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -260,7 +260,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'trovedashboardreleasenotes', u'Trove Dashboard Release Notes Documentation', + (master_doc, 'trovedashboardreleasenotes', 'Trove Dashboard Release Notes Documentation', [author], 1) ] @@ -274,7 +274,7 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'TroveDashboardReleaseNotes', u'Trove Dashboard Release Notes Documentation', + (master_doc, 'TroveDashboardReleaseNotes', 'Trove Dashboard Release Notes Documentation', author, 'TroveDashboardReleaseNotes', 'One line description of project.', 'Miscellaneous'), ] diff --git a/trove_dashboard/content/database_clusters/tests.py b/trove_dashboard/content/database_clusters/tests.py index 1c9e7f59..b231a02b 100644 --- a/trove_dashboard/content/database_clusters/tests.py +++ b/trove_dashboard/content/database_clusters/tests.py @@ -208,13 +208,13 @@ class ClustersTests(test.TestCase): self.mock_cluster_create.return_value = self.trove_clusters.first() - cluster_name = u'MyCluster' + cluster_name = 'MyCluster' cluster_volume = 1 - cluster_flavor = u'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' + cluster_flavor = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' cluster_instances = 3 - cluster_datastore = u'mongodb' - cluster_datastore_version = u'2.6' - cluster_network = u'' + cluster_datastore = 'mongodb' + cluster_datastore_version = '2.6' + cluster_network = '' field_name = self._build_flavor_widget_name(cluster_datastore, cluster_datastore_version) @@ -268,13 +268,13 @@ class ClustersTests(test.TestCase): self.mock_cluster_create.return_value = self.trove_clusters.first() - cluster_name = u'MyCluster' + cluster_name = 'MyCluster' cluster_volume = 1 - cluster_flavor = u'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' + cluster_flavor = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' cluster_instances = 3 - cluster_datastore = u'mongodb' - cluster_datastore_version = u'2.6' - cluster_network = u'82288d84-e0a5-42ac-95be-e6af08727e42' + cluster_datastore = 'mongodb' + cluster_datastore_version = '2.6' + cluster_network = '82288d84-e0a5-42ac-95be-e6af08727e42' field_name = self._build_flavor_widget_name(cluster_datastore, cluster_datastore_version) @@ -329,13 +329,13 @@ class ClustersTests(test.TestCase): self.mock_cluster_create.side_effect = self.exceptions.trove - cluster_name = u'MyCluster' + cluster_name = 'MyCluster' cluster_volume = 1 - cluster_flavor = u'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' + cluster_flavor = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' cluster_instances = 3 - cluster_datastore = u'mongodb' - cluster_datastore_version = u'2.6' - cluster_network = u'' + cluster_datastore = 'mongodb' + cluster_datastore_version = '2.6' + cluster_network = '' field_name = self._build_flavor_widget_name(cluster_datastore, cluster_datastore_version) diff --git a/trove_dashboard/content/database_configurations/tests.py b/trove_dashboard/content/database_configurations/tests.py index ff1ea985..633e137f 100644 --- a/trove_dashboard/content/database_configurations/tests.py +++ b/trove_dashboard/content/database_configurations/tests.py @@ -92,7 +92,7 @@ class DatabaseConfigurationsTests(test.TestCase): @test.create_mocks({ api.trove: ('datastore_list', 'datastore_version_list', 'configuration_create')}) - def _test_create_test_configuration(self, config_description=u''): + def _test_create_test_configuration(self, config_description=''): self.mock_datastore_list.return_value = self.datastores.list() self.mock_datastore_version_list.return_value = ( self.datastore_versions.list()) @@ -100,7 +100,7 @@ class DatabaseConfigurationsTests(test.TestCase): self.mock_configuration_create.return_value = ( self.database_configurations.first()) - name = u'config1' + name = 'config1' values = "{}" ds = self._get_test_datastore('mysql') dsv = self._get_test_datastore_version(ds.id, '5.5') @@ -129,7 +129,7 @@ class DatabaseConfigurationsTests(test.TestCase): self.assertMessageCount(success=1) def test_create_test_configuration(self): - self._test_create_test_configuration(u'description of config1') + self._test_create_test_configuration('description of config1') def test_create_test_configuration_with_no_description(self): self._test_create_test_configuration() @@ -144,9 +144,9 @@ class DatabaseConfigurationsTests(test.TestCase): self.mock_configuration_create.side_effect = self.exceptions.trove - name = u'config1' + name = 'config1' values = "{}" - config_description = u'description of config1' + config_description = 'description of config1' ds = self._get_test_datastore('mysql') dsv = self._get_test_datastore_version(ds.id, '5.5') config_datastore = ds.name diff --git a/trove_dashboard/content/databases/forms.py b/trove_dashboard/content/databases/forms.py index 2c2b00a7..bb0adc23 100644 --- a/trove_dashboard/content/databases/forms.py +++ b/trove_dashboard/content/databases/forms.py @@ -188,7 +188,7 @@ class CreateUserForm(forms.SelfHandlingForm): def _get_databases(self, data): databases = [] db_value = data['databases'] - if db_value and db_value != u'': + if db_value and db_value != '': dbs = data['databases'] databases = [{'name': d.strip()} for d in dbs.split(',')] return databases diff --git a/trove_dashboard/content/databases/tests.py b/trove_dashboard/content/databases/tests.py index 7cbeb03a..2acda287 100644 --- a/trove_dashboard/content/databases/tests.py +++ b/trove_dashboard/content/databases/tests.py @@ -488,8 +488,8 @@ class DatabaseTests(test.TestCase): res = self.client.post(url, post) self.mock_database_create.assert_called_once_with( - test.IsHttpRequest(), u'id', u'NewDB', character_set=u'', - collation=u'') + test.IsHttpRequest(), 'id', 'NewDB', character_set='', + collation='') self.assertNoFormErrors(res) self.assertMessageCount(success=1) @@ -506,14 +506,14 @@ class DatabaseTests(test.TestCase): res = self.client.post(url, post) self.mock_database_create.assert_called_once_with( - test.IsHttpRequest(), u'id', u'NewDB', character_set=u'', - collation=u'') + test.IsHttpRequest(), 'id', 'NewDB', character_set='', + collation='') self.assertEqual(res.status_code, 302) @test.create_mocks({api.trove: ('instance_get', 'root_show')}) def test_show_root(self): database = self.databases.first() - database.id = u'id' + database.id = 'id' user = self.database_user_roots.first() self.mock_instance_get.return_value = database @@ -543,7 +543,7 @@ class DatabaseTests(test.TestCase): self.mock_instance_get.assert_called_once_with( test.IsHttpRequest(), test.IsA(str)) self.mock_root_show.assert_called_once_with( - test.IsHttpRequest(), u'id') + test.IsHttpRequest(), 'id') self.assertRedirectsNoFollow(res, DETAILS_URL) @test.create_mocks({api.trove: ('root_enable',)}) @@ -565,7 +565,7 @@ class DatabaseTests(test.TestCase): table.maybe_handle() self.mock_root_enable.assert_called_once_with( - test.IsHttpRequest(), [u'id']) + test.IsHttpRequest(), ['id']) self.assertEqual(table.data[0].enabled, True) self.assertEqual(table.data[0].password, "password") @@ -588,7 +588,7 @@ class DatabaseTests(test.TestCase): table.maybe_handle() self.mock_root_enable.assert_called_once_with( - test.IsHttpRequest(), [u'id']) + test.IsHttpRequest(), ['id']) self.assertNotEqual(table.data[0].enabled, True) self.assertNotEqual(table.data[0].password, "password") @@ -610,7 +610,7 @@ class DatabaseTests(test.TestCase): table.maybe_handle() self.mock_root_disable.assert_called_once_with( - test.IsHttpRequest(), u'id') + test.IsHttpRequest(), 'id') self.assertEqual(table.data[0].enabled, True) self.assertIsNone(table.data[0].password) @@ -634,7 +634,7 @@ class DatabaseTests(test.TestCase): table.maybe_handle() self.mock_root_disable.assert_called_once_with( - test.IsHttpRequest(), u'id') + test.IsHttpRequest(), 'id') self.assertEqual(table.data[0].enabled, True) self.assertEqual(table.data[0].password, "password") @@ -713,8 +713,8 @@ class DatabaseTests(test.TestCase): res = self.client.post(url, post) self.mock_user_create.assert_called_once_with( - test.IsHttpRequest(), database.id, user.name, u'password', - host=u'', databases=[]) + test.IsHttpRequest(), database.id, user.name, 'password', + host='', databases=[]) self.assertNoFormErrors(res) self.assertMessageCount(success=1) @@ -732,8 +732,8 @@ class DatabaseTests(test.TestCase): res = self.client.post(url, post) self.mock_user_create.assert_called_once_with( - test.IsHttpRequest(), u'id', u'name', u'password', - host=u'', databases=[]) + test.IsHttpRequest(), 'id', 'name', 'password', + host='', databases=[]) self.assertEqual(res.status_code, 302) @test.create_mocks({api.trove: ('user_update_attributes',)})