eeprom93cxx: Shorten put_word() a bit.
authorUwe Hermann <uwe@hermann-uwe.de>
Wed, 3 May 2017 20:37:15 +0000 (22:37 +0200)
committerUwe Hermann <uwe@hermann-uwe.de>
Sat, 6 May 2017 17:56:55 +0000 (19:56 +0200)
decoders/eeprom93cxx/pd.py

index 0fd6969401d4f9b6f8abe161e830458a78be8943..06d92fb318af1f831cb4111e4f4e7c036652b2a9 100644 (file)
@@ -62,16 +62,11 @@ class Decoder(srd.Decoder):
         # Decode word (MSb first).
         word = 0
         for b in range(len(data)):
-            if si:
-                word += (data[b]['si'] << (len(data) - b - 1))
-            else:
-                word += (data[b]['so'] << (len(data) - b - 1))
-        if si:
-            self.put(data[0]['ss'], data[-1]['se'],
-                     self.out_ann, [0, ['Data: 0x%x' % word, '0x%x' % word]])
-        else:
-            self.put(data[0]['ss'], data[-1]['se'],
-                     self.out_ann, [1, ['Data: 0x%x' % word, '0x%x' % word]])
+            idx = 'si' if si else 'so'
+            word += (data[b][idx] << (len(data) - b - 1))
+        idx = 0 if si else 1
+        self.put(data[0]['ss'], data[-1]['se'],
+                 self.out_ann, [idx, ['Data: 0x%x' % word, '0x%x' % word]])
 
     def decode(self, ss, es, data):
         if len(data) < (2 + self.addresssize):