Replace xrange() with six.moves.range()
Add "from six.moves import range" to replace the builtin range() function with six.moves.range() to always create an iterator, instead of creating a temporary list. Replace "xrange" with "range". Don't add the import for ranges of 1024 items or less. Blueprint cinder-python3 Change-Id: If618b4e810e444f7eb6592bb2398805e9d14d548
This commit is contained in:
@@ -24,6 +24,7 @@ from oslo_log import log as logging
|
||||
from oslo_utils import strutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import units
|
||||
from six.moves import range
|
||||
|
||||
from cinder.brick.local_dev import lvm as brick_lvm
|
||||
from cinder import db
|
||||
@@ -443,7 +444,7 @@ def generate_password(length=16, symbolgroups=DEFAULT_PASSWORD_SYMBOLS):
|
||||
|
||||
# then fill with random characters from all symbol groups
|
||||
symbols = ''.join(symbolgroups)
|
||||
password.extend([random.choice(symbols) for _i in xrange(length)])
|
||||
password.extend([random.choice(symbols) for _i in range(length)])
|
||||
|
||||
# finally shuffle to ensure first x characters aren't from a
|
||||
# predictable group
|
||||
|
||||
Reference in New Issue
Block a user