]> sigrok.org Git - libsigrokdecode.git/commitdiff
sdq: prefer Python's .format() method for string formatting
authorGerhard Sittig <redacted>
Wed, 12 Aug 2020 18:08:35 +0000 (20:08 +0200)
committerGerhard Sittig <redacted>
Wed, 12 Aug 2020 18:19:06 +0000 (20:19 +0200)
Prefer the .format() method over the % operator. Also vertically align
the non-trivial text alternatives for different zoom levels to simplify
comparison and adjustment during maintenance.

decoders/sdq/pd.py

index d37458d0e05d06e27c977d92c39f0aa6180ded30..66df42025f1b9343d75678ff16fa3652e03b62ab 100644 (file)
@@ -83,11 +83,17 @@ class Decoder(srd.Decoder):
 
     def handle_bit(self, bit):
         self.bits.append(bit)
-        self.putetu([Ann.BIT, ['Bit: %d' % bit, '%d' % bit]])
+        self.putetu([Ann.BIT, [
+            'Bit: {:d}'.format(bit),
+            '{:d}'.format(bit),
+        ]])
 
         if len(self.bits) == 8:
             byte = bitpack(self.bits)
-            self.putbetu([Ann.BYTE, ['Byte: %#04x' % byte, '%#04x' % byte]])
+            self.putbetu([Ann.BYTE, [
+                'Byte: 0x{:02x}'.format(byte),
+                '0x{:02x}'.format(byte),
+            ]])
             self.bits = []
             self.bytepos = 0