]> sigrok.org Git - libsigrokdecode.git/commitdiff
atsha204a: Use the Python 'in' keyword to improve readability.
authorUwe Hermann <redacted>
Fri, 25 May 2018 22:32:14 +0000 (00:32 +0200)
committerUwe Hermann <redacted>
Fri, 25 May 2018 22:34:28 +0000 (00:34 +0200)
decoders/atsha204a/pd.py

index 3d6fd41c5b196e250a8cdc48c4a5a4d98f108686..3b7ee53cf8c074a589b0e7f640c915aff2589aa2 100644 (file)
@@ -163,10 +163,8 @@ class Decoder(srd.Decoder):
         self.put(data[0], data[1], self.out_ann, [2, ['Opcode: %s' % OPCODES[data[2]]]])
 
     def display_param1(self, data):
-        if (self.opcode == OPCODE_CHECK_MAC) or (self.opcode == OPCODE_DEV_REV) or \
-           (self.opcode == OPCODE_HMAC) or (self.opcode == OPCODE_MAC) or \
-           (self.opcode == OPCODE_NONCE) or (self.opcode == OPCODE_RANDOM) or \
-           (self.opcode == OPCODE_SHA):
+        if self.opcode in (OPCODE_CHECK_MAC, OPCODE_DEV_REV, OPCODE_HMAC, \
+                OPCODE_MAC, OPCODE_NONCE, OPCODE_RANDOM, OPCODE_SHA):
             self.put(data[0], data[1], self.out_ann, [3, ['Mode: %02X' % data[2]]])
         elif self.opcode == OPCODE_DERIVE_KEY:
             self.put(data[0], data[1], self.out_ann, [3, ['Random: %s' % data[2]]])
@@ -190,14 +188,13 @@ class Decoder(srd.Decoder):
     def display_param2(self, data):
         if self.opcode == OPCODE_DERIVE_KEY:
             self.put(data[0][0], data[1][1], self.out_ann, [4, ['TargetKey: {:02x} {:02x}'.format(data[1][2], data[0][2])]])
-        elif (self.opcode == OPCODE_NONCE) or (self.opcode == OPCODE_PAUSE) or (self.opcode == OPCODE_RANDOM):
+        elif self.opcode in (OPCODE_NONCE, OPCODE_PAUSE, OPCODE_RANDOM):
             self.put(data[0][0], data[1][1], self.out_ann, [4, ['Zero: {:02x} {:02x}'.format(data[1][2], data[0][2])]])
-        elif (self.opcode == OPCODE_HMAC) or (self.opcode == OPCODE_MAC) or \
-             (self.opcode == OPCODE_CHECK_MAC) or (self.opcode == OPCODE_GEN_DIG):
+        elif self.opcode in (OPCODE_HMAC, OPCODE_MAC, OPCODE_CHECK_MAC, OPCODE_GEN_DIG):
             self.put(data[0][0], data[1][1], self.out_ann, [4, ['SlotID: {:02x} {:02x}'.format(data[1][2], data[0][2])]])
         elif self.opcode == OPCODE_LOCK:
             self.put(data[0][0], data[1][1], self.out_ann, [4, ['Summary: {:02x} {:02x}'.format(data[1][2], data[0][2])]])
-        elif (self.opcode == OPCODE_READ) or (self.opcode == OPCODE_WRITE):
+        elif self.opcode in (OPCODE_READ, OPCODE_WRITE):
             self.put(data[0][0], data[1][1], self.out_ann, [4, ['Address: {:02x} {:02x}'.format(data[1][2], data[0][2])]])
         elif self.opcode == OPCODE_UPDATE_EXTRA:
             self.put(data[0][0], data[1][1], self.out_ann, [4, ['NewValue: {:02x}'.format(data[0][2])]])