Commit 0f049140 authored by Julien Muchembled's avatar Julien Muchembled

Simplify some code by using 'map()'

parent cbb992b2
......@@ -931,8 +931,7 @@ class Application(object):
# Reorder tids
ordered_tids = sorted(tid_set, reverse=True)
neo.lib.logging.debug(
"UndoLog tids %s", [dump(x) for x in ordered_tids])
neo.lib.logging.debug("UndoLog tids %s", map(dump, ordered_tids))
# For each transaction, get info
undo_info = []
append = undo_info.append
......
......@@ -118,7 +118,7 @@ class AdministrationHandler(MasterHandler):
app.broadcastNodesInformation([node])
def addPendingNodes(self, conn, uuid_list):
uuids = ', '.join([dump(uuid) for uuid in uuid_list])
uuids = ', '.join(map(dump, uuid_list))
neo.lib.logging.debug('Add nodes %s' % uuids)
app = self.app
nm = app.nm
......@@ -139,10 +139,10 @@ class AdministrationHandler(MasterHandler):
neo.lib.logging.warning('No nodes added')
conn.answer(Errors.Ack('No nodes added'))
return
uuids = ', '.join([dump(uuid) for uuid in uuid_set])
uuids = ', '.join(map(dump, uuid_set))
neo.lib.logging.info('Adding nodes %s' % uuids)
# switch nodes to running state
node_list = [nm.getByUUID(uuid) for uuid in uuid_set]
node_list = map(nm.getByUUID, uuid_set)
for node in node_list:
new_cells = pt.addNode(node)
cell_list.extend(new_cells)
......
......@@ -114,8 +114,8 @@ class Transaction(object):
self.__class__.__name__,
self._node,
dump(self._tid),
[dump(x) for x in self._oid_list or ()],
[dump(x) for x in self._uuid_set or ()],
map(dump, self._oid_list or ()),
map(dump, self._uuid_set or ()),
time() - self._birth,
id(self),
)
......
......@@ -198,7 +198,7 @@ class VerificationManager(BaseServiceHandler):
def answerUnfinishedTransactions(self, conn, max_tid, tid_list):
uuid = conn.getUUID()
neo.lib.logging.info('got unfinished transactions %s from %r',
[dump(tid) for tid in tid_list], conn)
map(dump, tid_list), conn)
if not self._gotAnswerFrom(uuid):
return
self._tid_set.update(tid_list)
......
......@@ -167,7 +167,7 @@ class TerminalNeoCTL(object):
node_list = self.neoctl.getNodeList(NodeTypes.STORAGE)
uuid_list = [node[2] for node in node_list]
else:
uuid_list = [self.asNode(x) for x in params]
uuid_list = map(self.asNode, params)
return self.neoctl.enableStorageList(uuid_list)
def dropNode(self, params):
......
......@@ -709,7 +709,7 @@ class MySQLDatabaseManager(DatabaseManager):
q = self.query
r = q("""SELECT tid FROM trans WHERE partition in (%s)
ORDER BY tid DESC LIMIT %d,%d""" \
% (','.join([str(p) for p in partition_list]), offset, length))
% (','.join(map(str, partition_list)), offset, length))
return [util.p64(t[0]) for t in r]
def getReplicationTIDList(self, min_tid, max_tid, length, num_partitions,
......
......@@ -165,7 +165,7 @@ class ReplicationHandler(EventHandler):
for oid, serial in missing_object_set:
if not app.dm.objectPresent(oid, serial):
ask(Packets.AskObject(oid, serial, None), timeout=300)
if sum((len(x) for x in object_dict.itervalues())) == MIN_RANGE_LENGTH:
if sum(map(len, object_dict.itervalues())) == MIN_RANGE_LENGTH:
max_tid = self.app.replicator.getCurrentCriticalTID()
ask(self._doAskCheckSerialRange(max_oid, add64(max_serial, 1),
max_tid, RANGE_LENGTH))
......
......@@ -207,7 +207,7 @@ class Replicator(object):
def setUnfinishedTIDList(self, max_tid, ttid_list):
"""This is a callback from MasterOperationHandler."""
neo.lib.logging.debug('setting unfinished TTIDs %s',
','.join([dump(tid) for tid in ttid_list]))
','.join(map(dump, ttid_list)))
# all new outdated partition must wait those ttid
new_partition_set = self.new_partition_set
while new_partition_set:
......
......@@ -140,8 +140,8 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
tid_list.remove(tid)
break
else:
raise AssertionFailed, '%s not found in %r' % (dump(ptid),
[dump(x) for x in tid_list])
raise AssertionFailed('%s not found in %r'
% (dump(ptid), map(dump, tid_list)))
def _checkPacketSerialList(self, conn, object_list, next_oid, next_serial, app):
packet_list = [x.getParam(0) for x in conn.mockGetNamedCalls('ask')]
......@@ -228,7 +228,7 @@ class StorageReplicationHandlerTests(NeoUnitTestBase):
oid_3 = self.getOID(3)
oid_4 = self.getOID(4)
oid_5 = self.getOID(5)
tid_list = [self.getOID(x) for x in xrange(7)]
tid_list = map(self.getOID, xrange(7))
oid_dict = FakeDict((
(oid_1, [tid_list[0], tid_list[1]]),
(oid_2, [tid_list[2], tid_list[3]]),
......
......@@ -510,7 +510,7 @@ class ProtocolTests(NeoUnitTestBase):
tid = self.getNextTID()
ltid = self.getNextTID()
undone_tid = self.getNextTID()
oid_list = [self.getOID(x) for x in xrange(4)]
oid_list = map(self.getOID, xrange(4))
p = Packets.AskObjectUndoSerial(tid, ltid, undone_tid, oid_list)
ptid, pltid, pundone_tid, poid_list = p.decode()
self.assertEqual(tid, ptid)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment