usb_power_delivery: fixup a Python style nit (dict lookup fallback)
authorGerhard Sittig <gerhard.sittig@gmx.net>
Fri, 22 Dec 2017 17:37:29 +0000 (18:37 +0100)
committerGerhard Sittig <gerhard.sittig@gmx.net>
Fri, 22 Dec 2017 17:58:43 +0000 (18:58 +0100)
Use the dictionary's .get() method in combination with a default result
parameter, instead of an explicit "k in dictvar" test and a conditional
assignment.

decoders/usb_power_delivery/pd.py

index ef9a97c7e70ec7aa687db3857b3ff57a799a1c54..de6f39418c6930f647384b75186a0a5382ddfb37 100644 (file)
@@ -412,7 +412,7 @@ class Decoder(srd.Decoder):
         for i in range(len(self.bits) - 19):
             k = (self.get_sym(i, rec=False), self.get_sym(i+5, rec=False),
                  self.get_sym(i+10, rec=False), self.get_sym(i+15, rec=False))
-            sym = START_OF_PACKETS[k] if k in START_OF_PACKETS else None
+            sym = START_OF_PACKETS.get(k, None)
             if not sym:
                 sym = self.find_corrupted_sop(k)
             # We have an interesting symbol sequence