summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-08-12 20:08:35 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-08-12 20:19:06 +0200
commit168b01adba98bd36abfd3b678282995ce415cb57 (patch)
tree19c75e4e45b9a5755c2b06ba2a8838bbce1382c2
parent65c6eed857b94c4ab8712c5ca4926d463529c4ff (diff)
downloadlibsigrokdecode-168b01adba98bd36abfd3b678282995ce415cb57.tar.gz
libsigrokdecode-168b01adba98bd36abfd3b678282995ce415cb57.zip
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.
-rw-r--r--decoders/sdq/pd.py10
1 files changed, 8 insertions, 2 deletions
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