Skip to content

Commit 931809c

Browse files
committed
Remove remaining six.moves usage
Change-Id: Ibca3884e1ea3d0fb170bcc9e70a176d144ee24cc Signed-off-by: Stephen Finucane <[email protected]>
1 parent 87ba561 commit 931809c

File tree

10 files changed

+31
-40
lines changed

10 files changed

+31
-40
lines changed

HACKING.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,4 @@ glance Specific Commandments
1818
- [G327] Prevent use of deprecated contextlib.nested
1919
- [G328] Must use a dict comprehension instead of a dict constructor with
2020
a sequence of key-value pairs
21-
- [G329] Python 3: Do not use xrange.
2221
- [G330] Log.warn is deprecated. Enforce use of LOG.warning.

glance/cmd/cache_manage.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
from oslo_utils import encodeutils
3232
import prettytable
3333

34-
from six.moves import input
35-
3634
# If ../glance/__init__.py exists, add ../ to Python search path, so that
3735
# it will override what happens to be installed in /usr/(local/)lib/python...
3836
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),

glance/common/property_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15+
import configparser
1516
import re
1617

1718
from oslo_config import cfg
1819
from oslo_log import log as logging
1920
from oslo_policy import policy
20-
from six.moves import configparser
2121

2222
import glance.api.policy
2323
from glance.common import exception

glance/common/swift_store_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
14+
15+
import configparser
16+
1417
from oslo_config import cfg
1518
from oslo_log import log as logging
16-
from six.moves import configparser
1719

1820
from glance.common import exception
1921
from glance.i18n import _, _LE

glance/hacking/checks.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,6 @@ def dict_constructor_with_list_copy(logical_line):
116116
yield (0, msg)
117117

118118

119-
@core.flake8ext
120-
def check_python3_xrange(logical_line):
121-
if re.search(r"\bxrange\s*\(", logical_line):
122-
yield(0, "G329: Do not use xrange. Use range, or six.moves.range for "
123-
"large loops.")
124-
125-
126119
@core.flake8ext
127120
def no_log_warn(logical_line):
128121
"""Disallow 'LOG.warn('

glance/tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# License for the specific language governing permissions and limitations
1414
# under the License.
1515

16+
import builtins
1617
import os
1718

1819
import eventlet
@@ -36,8 +37,7 @@
3637

3738
# See http://code.google.com/p/python-nose/issues/detail?id=373
3839
# The code below enables tests to work with i18n _() blocks
39-
import six.moves.builtins as __builtin__
40-
setattr(__builtin__, '_', lambda x: x)
40+
setattr(builtins, '_', lambda x: x)
4141

4242
# Set up logging to output debugging
4343
import logging

glance/tests/functional/db/base.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
import copy
1919
import datetime
20+
import functools
2021
from unittest import mock
2122
import uuid
2223

2324
from oslo_db import exception as db_exception
2425
from oslo_db.sqlalchemy import utils as sqlalchemyutils
25-
from six.moves import reduce
2626
from sqlalchemy.dialects import sqlite
2727

2828
from glance.common import exception
@@ -1508,14 +1508,18 @@ def setUp(self):
15081508
self.db_api.image_create(self.context1, fixture)
15091509

15101510
def test_storage_quota(self):
1511-
total = reduce(lambda x, y: x + y,
1512-
[f['size'] for f in self.owner1_fixtures])
1511+
total = functools.reduce(
1512+
lambda x, y: x + y,
1513+
[f['size'] for f in self.owner1_fixtures],
1514+
)
15131515
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
15141516
self.assertEqual(total, x)
15151517

15161518
def test_storage_quota_without_image_id(self):
1517-
total = reduce(lambda x, y: x + y,
1518-
[f['size'] for f in self.owner1_fixtures])
1519+
total = functools.reduce(
1520+
lambda x, y: x + y,
1521+
[f['size'] for f in self.owner1_fixtures],
1522+
)
15191523
total = total - self.owner1_fixtures[0]['size']
15201524
x = self.db_api.user_get_storage_usage(
15211525
self.context1, self.owner_id1,
@@ -1534,8 +1538,10 @@ def test_storage_quota_multiple_locations(self):
15341538
'status': 'active'})
15351539
self.db_api.image_create(self.context1, new_fixture)
15361540

1537-
total = reduce(lambda x, y: x + y,
1538-
[f['size'] for f in self.owner1_fixtures]) + (sz * 2)
1541+
total = functools.reduce(
1542+
lambda x, y: x + y,
1543+
[f['size'] for f in self.owner1_fixtures],
1544+
) + (sz * 2)
15391545
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
15401546
self.assertEqual(total, x)
15411547

@@ -1555,8 +1561,10 @@ def test_storage_quota_deleted_image(self):
15551561
'status': 'active'})
15561562
self.db_api.image_create(self.context1, new_fixture)
15571563

1558-
total = reduce(lambda x, y: x + y,
1559-
[f['size'] for f in self.owner1_fixtures])
1564+
total = functools.reduce(
1565+
lambda x, y: x + y,
1566+
[f['size'] for f in self.owner1_fixtures],
1567+
)
15601568
x = self.db_api.user_get_storage_usage(self.context1, self.owner_id1)
15611569
self.assertEqual(total + (sz * 2), x)
15621570

glance/tests/test_hacking.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ def test_dict_constructor_with_list_copy(self):
9090
self.assertEqual(0, len(list(checks.dict_constructor_with_list_copy(
9191
" self._render_dict(xml, data_el, data.__dict__)"))))
9292

93-
def test_check_python3_xrange(self):
94-
func = checks.check_python3_xrange
95-
self.assertEqual(1, len(list(func('for i in xrange(10)'))))
96-
self.assertEqual(1, len(list(func('for i in xrange (10)'))))
97-
self.assertEqual(0, len(list(func('for i in range(10)'))))
98-
self.assertEqual(0, len(list(func('for i in six.moves.range(10)'))))
99-
self.assertEqual(0, len(list(func('testxrange(10)'))))
100-
10193
def test_no_log_warn(self):
10294
code = """
10395
LOG.warn("LOG.warn is deprecated")

glance/tests/unit/test_glance_replicator.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15+
import collections
1516
import http.client as http
1617
import io
1718
from unittest import mock
@@ -23,7 +24,6 @@
2324

2425
import fixtures
2526
from oslo_serialization import jsonutils
26-
from six import moves
2727
import webob
2828

2929
from glance.cmd import replicator as glance_replicator
@@ -306,7 +306,7 @@ def get_image_service():
306306

307307

308308
def check_no_args(command, args):
309-
options = moves.UserDict()
309+
options = collections.UserDict()
310310
no_args_error = False
311311

312312
orig_img_service = glance_replicator.get_image_service
@@ -323,7 +323,7 @@ def check_no_args(command, args):
323323

324324

325325
def check_bad_args(command, args):
326-
options = moves.UserDict()
326+
options = collections.UserDict()
327327
bad_args_error = False
328328

329329
orig_img_service = glance_replicator.get_image_service
@@ -351,7 +351,7 @@ def test_help(self, mock_lookup_command):
351351
self.assertEqual(2, mock_lookup_command.call_count)
352352

353353
def test_replication_size(self):
354-
options = moves.UserDict()
354+
options = collections.UserDict()
355355
options.targettoken = 'targettoken'
356356
args = ['localhost:9292']
357357

@@ -405,7 +405,7 @@ def test_human_readable_size(self):
405405
def test_replication_dump(self):
406406
tempdir = self.useFixture(fixtures.TempDir()).path
407407

408-
options = moves.UserDict()
408+
options = collections.UserDict()
409409
options.chunksize = 4096
410410
options.sourcetoken = 'sourcetoken'
411411
options.metaonly = False
@@ -492,7 +492,7 @@ def write_image(img, data):
492492
f.write(jsonutils.dumps([1, 2, 3, 4, 5]))
493493

494494
# Finally, we're ready to test
495-
options = moves.UserDict()
495+
options = collections.UserDict()
496496
options.dontreplicate = 'dontrepl dontreplabsent'
497497
options.targettoken = 'targettoken'
498498
args = ['localhost:9292', tempdir]
@@ -520,7 +520,7 @@ def test_replication_load_with_bad_args(self):
520520
self.assertTrue(check_bad_args(command, args))
521521

522522
def test_replication_livecopy(self):
523-
options = moves.UserDict()
523+
options = collections.UserDict()
524524
options.chunksize = 4096
525525
options.dontreplicate = 'dontrepl dontreplabsent'
526526
options.sourcetoken = 'livesourcetoken'
@@ -548,7 +548,7 @@ def test_replication_livecopy_with_bad_args(self):
548548
self.assertTrue(check_bad_args(command, args))
549549

550550
def test_replication_compare(self):
551-
options = moves.UserDict()
551+
options = collections.UserDict()
552552
options.chunksize = 4096
553553
options.dontreplicate = 'dontrepl dontreplabsent'
554554
options.sourcetoken = 'livesourcetoken'

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ extension =
146146
G319 = checks:no_translate_debug_logs
147147
G327 = checks:check_no_contextlib_nested
148148
G328 = checks:dict_constructor_with_list_copy
149-
G329 = checks:check_python3_xrange
150149
G330 = checks:no_log_warn
151150
paths = ./glance/hacking
152151

0 commit comments

Comments
 (0)