Remove remaining six.moves usage
Change-Id: Ibca3884e1ea3d0fb170bcc9e70a176d144ee24cc Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
parent
87ba56161b
commit
931809c037
@ -18,5 +18,4 @@ glance Specific Commandments
|
|||||||
- [G327] Prevent use of deprecated contextlib.nested
|
- [G327] Prevent use of deprecated contextlib.nested
|
||||||
- [G328] Must use a dict comprehension instead of a dict constructor with
|
- [G328] Must use a dict comprehension instead of a dict constructor with
|
||||||
a sequence of key-value pairs
|
a sequence of key-value pairs
|
||||||
- [G329] Python 3: Do not use xrange.
|
|
||||||
- [G330] Log.warn is deprecated. Enforce use of LOG.warning.
|
- [G330] Log.warn is deprecated. Enforce use of LOG.warning.
|
||||||
|
@ -31,8 +31,6 @@ import uuid
|
|||||||
from oslo_utils import encodeutils
|
from oslo_utils import encodeutils
|
||||||
import prettytable
|
import prettytable
|
||||||
|
|
||||||
from six.moves import input
|
|
||||||
|
|
||||||
# If ../glance/__init__.py exists, add ../ to Python search path, so that
|
# If ../glance/__init__.py exists, add ../ to Python search path, so that
|
||||||
# it will override what happens to be installed in /usr/(local/)lib/python...
|
# it will override what happens to be installed in /usr/(local/)lib/python...
|
||||||
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_policy import policy
|
from oslo_policy import policy
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
import glance.api.policy
|
import glance.api.policy
|
||||||
from glance.common import exception
|
from glance.common import exception
|
||||||
|
@ -11,9 +11,11 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import configparser
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from six.moves import configparser
|
|
||||||
|
|
||||||
from glance.common import exception
|
from glance.common import exception
|
||||||
from glance.i18n import _, _LE
|
from glance.i18n import _, _LE
|
||||||
|
@ -116,13 +116,6 @@ def dict_constructor_with_list_copy(logical_line):
|
|||||||
yield (0, msg)
|
yield (0, msg)
|
||||||
|
|
||||||
|
|
||||||
@core.flake8ext
|
|
||||||
def check_python3_xrange(logical_line):
|
|
||||||
if re.search(r"\bxrange\s*\(", logical_line):
|
|
||||||
yield(0, "G329: Do not use xrange. Use range, or six.moves.range for "
|
|
||||||
"large loops.")
|
|
||||||
|
|
||||||
|
|
||||||
@core.flake8ext
|
@core.flake8ext
|
||||||
def no_log_warn(logical_line):
|
def no_log_warn(logical_line):
|
||||||
"""Disallow 'LOG.warn('
|
"""Disallow 'LOG.warn('
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import builtins
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
@ -36,8 +37,7 @@ glance.async_.set_threadpool_model('eventlet')
|
|||||||
|
|
||||||
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
# See http://code.google.com/p/python-nose/issues/detail?id=373
|
||||||
# The code below enables tests to work with i18n _() blocks
|
# The code below enables tests to work with i18n _() blocks
|
||||||
import six.moves.builtins as __builtin__
|
setattr(builtins, '_', lambda x: x)
|
||||||
setattr(__builtin__, '_', lambda x: x)
|
|
||||||
|
|
||||||
# Set up logging to output debugging
|
# Set up logging to output debugging
|
||||||
import logging
|
import logging
|
||||||
|
@ -17,12 +17,12 @@
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import datetime
|
import datetime
|
||||||
|
import functools
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from oslo_db import exception as db_exception
|
from oslo_db import exception as db_exception
|
||||||
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
from oslo_db.sqlalchemy import utils as sqlalchemyutils
|
||||||
from six.moves import reduce
|
|
||||||
from sqlalchemy.dialects import sqlite
|
from sqlalchemy.dialects import sqlite
|
||||||
|
|
||||||
from glance.common import exception
|
from glance.common import exception
|
||||||
@ -1508,14 +1508,18 @@ class DriverQuotaTests(test_utils.BaseTestCase):
|
|||||||
self.db_api.image_create(self.context1, fixture)
|
self.db_api.image_create(self.context1, fixture)
|
||||||
|
|
||||||
def test_storage_quota(self):
|
def test_storage_quota(self):
|
||||||
total = reduce(lambda x, y: x + y,
|
total = functools.reduce(
|
||||||
[f['size'] for f in self.owner1_fixtures])
|
lambda x, y: x + y,
|
||||||
|
[f['size'] for f in self.owner1_fixtures],
|
||||||
|
)
|
||||||
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
|
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
|
||||||
self.assertEqual(total, x)
|
self.assertEqual(total, x)
|
||||||
|
|
||||||
def test_storage_quota_without_image_id(self):
|
def test_storage_quota_without_image_id(self):
|
||||||
total = reduce(lambda x, y: x + y,
|
total = functools.reduce(
|
||||||
[f['size'] for f in self.owner1_fixtures])
|
lambda x, y: x + y,
|
||||||
|
[f['size'] for f in self.owner1_fixtures],
|
||||||
|
)
|
||||||
total = total - self.owner1_fixtures[0]['size']
|
total = total - self.owner1_fixtures[0]['size']
|
||||||
x = self.db_api.user_get_storage_usage(
|
x = self.db_api.user_get_storage_usage(
|
||||||
self.context1, self.owner_id1,
|
self.context1, self.owner_id1,
|
||||||
@ -1534,8 +1538,10 @@ class DriverQuotaTests(test_utils.BaseTestCase):
|
|||||||
'status': 'active'})
|
'status': 'active'})
|
||||||
self.db_api.image_create(self.context1, new_fixture)
|
self.db_api.image_create(self.context1, new_fixture)
|
||||||
|
|
||||||
total = reduce(lambda x, y: x + y,
|
total = functools.reduce(
|
||||||
[f['size'] for f in self.owner1_fixtures]) + (sz * 2)
|
lambda x, y: x + y,
|
||||||
|
[f['size'] for f in self.owner1_fixtures],
|
||||||
|
) + (sz * 2)
|
||||||
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
|
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
|
||||||
self.assertEqual(total, x)
|
self.assertEqual(total, x)
|
||||||
|
|
||||||
@ -1555,8 +1561,10 @@ class DriverQuotaTests(test_utils.BaseTestCase):
|
|||||||
'status': 'active'})
|
'status': 'active'})
|
||||||
self.db_api.image_create(self.context1, new_fixture)
|
self.db_api.image_create(self.context1, new_fixture)
|
||||||
|
|
||||||
total = reduce(lambda x, y: x + y,
|
total = functools.reduce(
|
||||||
[f['size'] for f in self.owner1_fixtures])
|
lambda x, y: x + y,
|
||||||
|
[f['size'] for f in self.owner1_fixtures],
|
||||||
|
)
|
||||||
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
|
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
|
||||||
self.assertEqual(total + (sz * 2), x)
|
self.assertEqual(total + (sz * 2), x)
|
||||||
|
|
||||||
|
@ -90,14 +90,6 @@ class HackingTestCase(utils.BaseTestCase):
|
|||||||
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
|
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
|
||||||
" self._render_dict(xml, data_el, data.__dict__)"))))
|
" self._render_dict(xml, data_el, data.__dict__)"))))
|
||||||
|
|
||||||
def test_check_python3_xrange(self):
|
|
||||||
func = checks.check_python3_xrange
|
|
||||||
self.assertEqual(1, len(list(func('for i in xrange(10)'))))
|
|
||||||
self.assertEqual(1, len(list(func('for i in xrange (10)'))))
|
|
||||||
self.assertEqual(0, len(list(func('for i in range(10)'))))
|
|
||||||
self.assertEqual(0, len(list(func('for i in six.moves.range(10)'))))
|
|
||||||
self.assertEqual(0, len(list(func('testxrange(10)'))))
|
|
||||||
|
|
||||||
def test_no_log_warn(self):
|
def test_no_log_warn(self):
|
||||||
code = """
|
code = """
|
||||||
LOG.warn("LOG.warn is deprecated")
|
LOG.warn("LOG.warn is deprecated")
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import collections
|
||||||
import http.client as http
|
import http.client as http
|
||||||
import io
|
import io
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
@ -23,7 +24,6 @@ import uuid
|
|||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from six import moves
|
|
||||||
import webob
|
import webob
|
||||||
|
|
||||||
from glance.cmd import replicator as glance_replicator
|
from glance.cmd import replicator as glance_replicator
|
||||||
@ -306,7 +306,7 @@ def get_image_service():
|
|||||||
|
|
||||||
|
|
||||||
def check_no_args(command, args):
|
def check_no_args(command, args):
|
||||||
options = moves.UserDict()
|
options = collections.UserDict()
|
||||||
no_args_error = False
|
no_args_error = False
|
||||||
|
|
||||||
orig_img_service = glance_replicator.get_image_service
|
orig_img_service = glance_replicator.get_image_service
|
||||||
@ -323,7 +323,7 @@ def check_no_args(command, args):
|
|||||||
|
|
||||||
|
|
||||||
def check_bad_args(command, args):
|
def check_bad_args(command, args):
|
||||||
options = moves.UserDict()
|
options = collections.UserDict()
|
||||||
bad_args_error = False
|
bad_args_error = False
|
||||||
|
|
||||||
orig_img_service = glance_replicator.get_image_service
|
orig_img_service = glance_replicator.get_image_service
|
||||||
@ -351,7 +351,7 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
|||||||
self.assertEqual(2, mock_lookup_command.call_count)
|
self.assertEqual(2, mock_lookup_command.call_count)
|
||||||
|
|
||||||
def test_replication_size(self):
|
def test_replication_size(self):
|
||||||
options = moves.UserDict()
|
options = collections.UserDict()
|
||||||
options.targettoken = 'targettoken'
|
options.targettoken = 'targettoken'
|
||||||
args = ['localhost:9292']
|
args = ['localhost:9292']
|
||||||
|
|
||||||
@ -405,7 +405,7 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
|||||||
def test_replication_dump(self):
|
def test_replication_dump(self):
|
||||||
tempdir = self.useFixture(fixtures.TempDir()).path
|
tempdir = self.useFixture(fixtures.TempDir()).path
|
||||||
|
|
||||||
options = moves.UserDict()
|
options = collections.UserDict()
|
||||||
options.chunksize = 4096
|
options.chunksize = 4096
|
||||||
options.sourcetoken = 'sourcetoken'
|
options.sourcetoken = 'sourcetoken'
|
||||||
options.metaonly = False
|
options.metaonly = False
|
||||||
@ -492,7 +492,7 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
|||||||
f.write(jsonutils.dumps([1, 2, 3, 4, 5]))
|
f.write(jsonutils.dumps([1, 2, 3, 4, 5]))
|
||||||
|
|
||||||
# Finally, we're ready to test
|
# Finally, we're ready to test
|
||||||
options = moves.UserDict()
|
options = collections.UserDict()
|
||||||
options.dontreplicate = 'dontrepl dontreplabsent'
|
options.dontreplicate = 'dontrepl dontreplabsent'
|
||||||
options.targettoken = 'targettoken'
|
options.targettoken = 'targettoken'
|
||||||
args = ['localhost:9292', tempdir]
|
args = ['localhost:9292', tempdir]
|
||||||
@ -520,7 +520,7 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
|||||||
self.assertTrue(check_bad_args(command, args))
|
self.assertTrue(check_bad_args(command, args))
|
||||||
|
|
||||||
def test_replication_livecopy(self):
|
def test_replication_livecopy(self):
|
||||||
options = moves.UserDict()
|
options = collections.UserDict()
|
||||||
options.chunksize = 4096
|
options.chunksize = 4096
|
||||||
options.dontreplicate = 'dontrepl dontreplabsent'
|
options.dontreplicate = 'dontrepl dontreplabsent'
|
||||||
options.sourcetoken = 'livesourcetoken'
|
options.sourcetoken = 'livesourcetoken'
|
||||||
@ -548,7 +548,7 @@ class ReplicationCommandsTestCase(test_utils.BaseTestCase):
|
|||||||
self.assertTrue(check_bad_args(command, args))
|
self.assertTrue(check_bad_args(command, args))
|
||||||
|
|
||||||
def test_replication_compare(self):
|
def test_replication_compare(self):
|
||||||
options = moves.UserDict()
|
options = collections.UserDict()
|
||||||
options.chunksize = 4096
|
options.chunksize = 4096
|
||||||
options.dontreplicate = 'dontrepl dontreplabsent'
|
options.dontreplicate = 'dontrepl dontreplabsent'
|
||||||
options.sourcetoken = 'livesourcetoken'
|
options.sourcetoken = 'livesourcetoken'
|
||||||
|
1
tox.ini
1
tox.ini
@ -146,7 +146,6 @@ extension =
|
|||||||
G319 = checks:no_translate_debug_logs
|
G319 = checks:no_translate_debug_logs
|
||||||
G327 = checks:check_no_contextlib_nested
|
G327 = checks:check_no_contextlib_nested
|
||||||
G328 = checks:dict_constructor_with_list_copy
|
G328 = checks:dict_constructor_with_list_copy
|
||||||
G329 = checks:check_python3_xrange
|
|
||||||
G330 = checks:no_log_warn
|
G330 = checks:no_log_warn
|
||||||
paths = ./glance/hacking
|
paths = ./glance/hacking
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user