opcodes: Replace manual loop with map
authorMichael Hanselmann <hansmi@google.com>
Thu, 29 Nov 2012 11:33:46 +0000 (12:33 +0100)
committerMichael Hanselmann <hansmi@google.com>
Fri, 30 Nov 2012 05:10:46 +0000 (06:10 +0100)
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
test/ganeti.opcodes_unittest.py

index d0dc45f..959d56b 100644 (file)
@@ -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):
index a5e36d2..c310ecc 100755 (executable)
@@ -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)