diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2018-04-16 21:12:16 +0200 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2018-04-23 23:25:43 +0200 |
commit | aad263bb83593a66d4a834b30acf8e8a2f1b5c4c (patch) | |
tree | 65181123ce6c5b917528ffdc0a00658ed2f61eff | |
parent | 3f3c4614b551855d7cf56e83ec7fb883592050ab (diff) | |
download | libsigrokdecode-aad263bb83593a66d4a834b30acf8e8a2f1b5c4c.tar.gz libsigrokdecode-aad263bb83593a66d4a834b30acf8e8a2f1b5c4c.zip |
dcf77, lpc: rephrase bit string formatting
Create the text representation of a bit string by means of the builtin
.format() method and an appropriate specifier. Drop the non-obvious
sequence of bin() and slice and zfill() calls.
-rw-r--r-- | decoders/dcf77/pd.py | 2 | ||||
-rw-r--r-- | decoders/lpc/pd.py | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py index 7b180ce..4789b66 100644 --- a/decoders/dcf77/pd.py +++ b/decoders/dcf77/pd.py @@ -127,7 +127,7 @@ class Decoder(srd.Decoder): else: self.tmp |= (bit << (c - 1)) if c == 14: - s = bin(self.tmp)[2:].zfill(14) + s = '{:014b}'.format(self.tmp) self.putb([1, ['Special bits: %s' % s, 'SB: %s' % s]]) elif c == 15: s = '' if (bit == 1) else 'not ' diff --git a/decoders/lpc/pd.py b/decoders/lpc/pd.py index 7242208..452e647 100644 --- a/decoders/lpc/pd.py +++ b/decoders/lpc/pd.py @@ -340,7 +340,7 @@ class Decoder(srd.Decoder): # Most (but not all) states need this. if self.state != 'IDLE': lad = (lad3 << 3) | (lad2 << 2) | (lad1 << 1) | lad0 - lad_bits = bin(lad)[2:].zfill(4) + lad_bits = '{:04b}'.format(lad) # self.putb([0, ['LAD: %s' % lad_bits]]) # TODO: Only memory read/write is currently supported/tested. |