From: Daniel Elstner Date: Tue, 15 Sep 2015 09:42:05 +0000 (+0200) Subject: jitter, pwm: Avoid Unicode string literals X-Git-Tag: libsigrokdecode-0.4.0~59 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=750e122d2bcdf05e600112ffda431f97608db387;p=libsigrokdecode.git jitter, pwm: Avoid Unicode string literals It seems the Python we ship along our Windows binaries does not support u"..." strings, even though it's been a language feature since Python 2. Remove the "u" prefix to avoid a syntax error. Also, consistently use format "%.1f" at all scales. This fixes bug #569. --- diff --git a/decoders/jitter/pd.py b/decoders/jitter/pd.py index d6db8e5..d572c36 100644 --- a/decoders/jitter/pd.py +++ b/decoders/jitter/pd.py @@ -91,17 +91,17 @@ class Decoder(srd.Decoder): def putx(self, delta): # Adjust granularity. if delta == 0 or delta >= 1: - delta_s = u"%us" % (delta) + delta_s = "%.1fs" % (delta) elif delta <= 1e-12: - delta_s = u"%.1ffs" % (delta * 1e15) + delta_s = "%.1ffs" % (delta * 1e15) elif delta <= 1e-9: - delta_s = u"%.1fps" % (delta * 1e12) + delta_s = "%.1fps" % (delta * 1e12) elif delta <= 1e-6: - delta_s = u"%.1fns" % (delta * 1e9) + delta_s = "%.1fns" % (delta * 1e9) elif delta <= 1e-3: - delta_s = u"%.1fμs" % (delta * 1e6) + delta_s = "%.1fμs" % (delta * 1e6) else: - delta_s = u"%.1fms" % (delta * 1e3) + delta_s = "%.1fms" % (delta * 1e3) self.put(self.clk_start, self.sig_start, self.out_ann, [0, [delta_s]]) diff --git a/decoders/pwm/pd.py b/decoders/pwm/pd.py index 45e96e2..e0203a3 100644 --- a/decoders/pwm/pd.py +++ b/decoders/pwm/pd.py @@ -77,17 +77,17 @@ class Decoder(srd.Decoder): def putp(self, period_t): # Adjust granularity. if period_t == 0 or period_t >= 1: - period_s = u'%u s' % (period_t) + period_s = '%.1f s' % (period_t) elif period_t <= 1e-12: - period_s = u'%.1f fs' % (period_t * 1e15) + period_s = '%.1f fs' % (period_t * 1e15) elif period_t <= 1e-9: - period_s = u'%.1f ps' % (period_t * 1e12) + period_s = '%.1f ps' % (period_t * 1e12) elif period_t <= 1e-6: - period_s = u'%.1f ns' % (period_t * 1e9) + period_s = '%.1f ns' % (period_t * 1e9) elif period_t <= 1e-3: - period_s = u'%.1f μs' % (period_t * 1e6) + period_s = '%.1f μs' % (period_t * 1e6) else: - period_s = u'%.1f ms' % (period_t * 1e3) + period_s = '%.1f ms' % (period_t * 1e3) self.put(self.ss, self.es, self.out_ann, [1, [period_s]])