From 5dff65da224309ceed8bee01b204bb2ec789e80e Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 29 Nov 2012 12:33:46 +0100 Subject: [PATCH] opcodes: Replace manual loop with map Also remove a superfluous empty line in test file. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- lib/opcodes.py | 4 ++-- test/ganeti.opcodes_unittest.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/opcodes.py b/lib/opcodes.py index d0dc45fa6..959d56b0e 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -1340,8 +1340,8 @@ class OpInstanceMultiAlloc(OpCode): type(state)) if "instances" in state: - insts = [OpCode.LoadOpCode(inst) for inst in state["instances"]] - state["instances"] = insts + state["instances"] = map(OpCode.LoadOpCode, state["instances"]) + return OpCode.__setstate__(self, state) def Validate(self, set_defaults): diff --git a/test/ganeti.opcodes_unittest.py b/test/ganeti.opcodes_unittest.py index a5e36d2ab..c310ecc6c 100755 --- a/test/ganeti.opcodes_unittest.py +++ b/test/ganeti.opcodes_unittest.py @@ -297,7 +297,6 @@ class TestOpcodes(unittest.TestCase): self.assertEqual(op.value2, "world") self.assertEqual(op.debug_level, 123) - def testOpInstanceMultiAlloc(self): inst = dict([(name, []) for name in opcodes.OpInstanceCreate.GetAllSlots()]) inst_op = opcodes.OpInstanceCreate(**inst) -- GitLab