From 033e7d4db76f2e2a289d5567e9532f26201cfa74 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Wed, 16 Dec 2015 18:14:30 +0100 Subject: usb_power_delivery: Use "if not self.samplerate" form. Use the "if not self.samplerate" form, which catches both the case where self.samplerate is None, as well as the case where it is 0. This is also consistent with all the other PDs. --- decoders/usb_power_delivery/pd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'decoders/usb_power_delivery') diff --git a/decoders/usb_power_delivery/pd.py b/decoders/usb_power_delivery/pd.py index e8d0afb..034c4a9 100644 --- a/decoders/usb_power_delivery/pd.py +++ b/decoders/usb_power_delivery/pd.py @@ -468,7 +468,7 @@ class Decoder(srd.Decoder): ) def us2samples(self, us): - if self.samplerate is None: + if not self.samplerate: raise Exception('Need the samplerate.') return int(us * self.samplerate / 1000000) @@ -527,7 +527,7 @@ class Decoder(srd.Decoder): self.put(es, ss, self.out_binary, (0, bytes(self.bits))) def decode(self, ss, es, data): - if self.samplerate is None: + if not self.samplerate: raise Exception('Cannot decode without samplerate.') for (self.samplenum, pins) in data: # find edges ... -- cgit v1.2.3-70-g09d2