Fix: "map" issue for Python 2/3 compatible code
Replace map(func, data) with [func(item) for item in data] Story: 2003433 Task:28377 Change-Id: I0a41561dd6ac7c30c2c5c9eb127946d0a49586bc Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
parent
92f3f4a823
commit
6c3bf61663
|
@ -109,8 +109,7 @@ def get_backup_databases(cinder_config=False):
|
|||
# mentioned in BACKUP_DATABASES. We explicitly list
|
||||
# skip tables in DB_TABLE_SKIP_MAPPING
|
||||
BACKUP_DB_SKIP_TABLES = dict(
|
||||
map(lambda x: [x, DB_TABLE_SKIP_MAPPING.get(x, ())],
|
||||
BACKUP_DATABASES))
|
||||
[[x, DB_TABLE_SKIP_MAPPING.get(x, ())] for x in BACKUP_DATABASES])
|
||||
|
||||
return BACKUP_DATABASES, BACKUP_DB_SKIP_TABLES
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ def _list_opts(obj):
|
|||
if is_opt(attr_obj):
|
||||
opts.append(attr_obj)
|
||||
elif (isinstance(attr_obj, list) and
|
||||
all(map(lambda x: is_opt(x), attr_obj))):
|
||||
all([is_opt(x) for x in attr_obj])):
|
||||
opts.extend(attr_obj)
|
||||
|
||||
ret = {}
|
||||
|
|
|
@ -53,8 +53,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol):
|
|||
# The information whether the API call is being performed against the
|
||||
# public API is required for some other components. Saving it to the
|
||||
# WSGI environment is reasonable thereby.
|
||||
env['is_public_api'] = any(map(lambda pattern: re.match(pattern, path),
|
||||
self.public_api_routes))
|
||||
env['is_public_api'] = any([re.match(pattern, path) for pattern in self.public_api_routes])
|
||||
|
||||
if env['is_public_api']:
|
||||
LOG.debug("Found match request")
|
||||
|
|
|
@ -180,7 +180,7 @@ def execute(*cmd, **kwargs):
|
|||
if run_as_root and os.geteuid() != 0:
|
||||
cmd = ['sudo', 'sysinv-rootwrap', CONF.rootwrap_config] + list(cmd)
|
||||
|
||||
cmd = map(str, cmd)
|
||||
cmd = [str(c) for c in cmd]
|
||||
|
||||
while attempts > 0:
|
||||
attempts -= 1
|
||||
|
|
|
@ -152,7 +152,7 @@ def _list_opts(obj):
|
|||
if is_opt(attr_obj):
|
||||
opts.append(attr_obj)
|
||||
elif (isinstance(attr_obj, list) and
|
||||
all(map(lambda x: is_opt(x), attr_obj))):
|
||||
all([is_opt(x) for x in attr_obj])):
|
||||
opts.extend(attr_obj)
|
||||
|
||||
ret = {}
|
||||
|
|
|
@ -134,7 +134,7 @@ def execute(*cmd, **kwargs):
|
|||
'helper.'))
|
||||
cmd = shlex.split(root_helper) + list(cmd)
|
||||
|
||||
cmd = map(str, cmd)
|
||||
cmd = [str(c) for c in cmd]
|
||||
|
||||
while attempts > 0:
|
||||
attempts -= 1
|
||||
|
|
|
@ -510,7 +510,7 @@ def deserialize_msg(msg):
|
|||
return msg
|
||||
|
||||
base_envelope_keys = (_VERSION_KEY, _MESSAGE_KEY)
|
||||
if not all(map(lambda key: key in msg, base_envelope_keys)):
|
||||
if not all([key in msg for key in base_envelope_keys]):
|
||||
# See #1.b above.
|
||||
return msg
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ class ZmqSocket(object):
|
|||
"""Get socket type as string."""
|
||||
t_enum = ('PUSH', 'PULL', 'PUB', 'SUB', 'REP', 'REQ', 'ROUTER',
|
||||
'DEALER')
|
||||
return dict(map(lambda t: (getattr(zmq, t), t), t_enum))[self.type]
|
||||
return dict([(getattr(zmq, t), t) for t in t_enum])[self.type]
|
||||
|
||||
def subscribe(self, msg_filter):
|
||||
"""Subscribe."""
|
||||
|
@ -222,14 +222,14 @@ class ZmqClient(object):
|
|||
msg_id = msg_id or 0
|
||||
|
||||
if not envelope:
|
||||
self.outq.send(map(bytes,
|
||||
(msg_id, topic, 'cast', _serialize(data))))
|
||||
self.outq.send([bytes(x) for x in
|
||||
(msg_id, topic, 'cast', _serialize(data))])
|
||||
return
|
||||
|
||||
rpc_envelope = rpc_common.serialize_msg(data[1], envelope)
|
||||
zmq_msg = reduce(lambda x, y: x + y, rpc_envelope.items())
|
||||
self.outq.send(map(bytes,
|
||||
(msg_id, topic, 'impl_zmq_v2', data[0]) + zmq_msg))
|
||||
self.outq.send([bytes(x) for x in
|
||||
((msg_id, topic, 'impl_zmq_v2', data[0]) + zmq_msg)])
|
||||
|
||||
def close(self):
|
||||
self.outq.close()
|
||||
|
|
|
@ -100,7 +100,7 @@ class FanoutRingExchange(RingExchange):
|
|||
"see ringfile") % (nkey, )
|
||||
)
|
||||
return []
|
||||
return map(lambda x: (key + '.' + x, x), self.ring[nkey])
|
||||
return [(key + '.' + x, x) for x in self.ring[nkey]]
|
||||
|
||||
|
||||
class MatchMakerRing(mm.MatchMakerBase):
|
||||
|
|
|
@ -25,7 +25,7 @@ class StubGlanceClient(object):
|
|||
def __init__(self, images=None):
|
||||
self._images = []
|
||||
_images = images or []
|
||||
map(lambda image: self.create(**image), _images)
|
||||
[self.create(**image) for image in _images]
|
||||
|
||||
# NOTE(bcwaldon): HACK to get client.images.* to work
|
||||
self.images = lambda: None
|
||||
|
|
Loading…
Reference in New Issue