From: Gerhard Sittig Date: Wed, 12 Aug 2020 18:08:35 +0000 (+0200) Subject: sdq: prefer Python's .format() method for string formatting X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=168b01adba98bd36abfd3b678282995ce415cb57;p=libsigrokdecode.git sdq: prefer Python's .format() method for string formatting 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. --- diff --git a/decoders/sdq/pd.py b/decoders/sdq/pd.py index d37458d..66df420 100644 --- a/decoders/sdq/pd.py +++ b/decoders/sdq/pd.py @@ -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