From 026be6c91c531d77bc35c1ac465b6e8eca78b949 Mon Sep 17 00:00:00 2001 From: Christoph Deil Date: Thu, 12 Nov 2020 13:04:44 +0100 Subject: [PATCH 1/2] Fix whisper-fetch.py --drop timestamps --- bin/whisper-fetch.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bin/whisper-fetch.py b/bin/whisper-fetch.py index f6b2f4a0..988dccbf 100755 --- a/bin/whisper-fetch.py +++ b/bin/whisper-fetch.py @@ -64,14 +64,12 @@ except (whisper.WhisperException, IOError) as exc: raise SystemExit('[ERROR] %s' % str(exc)) -if options.drop: - fcn = _DROP_FUNCTIONS.get(options.drop) - values = [x for x in values if fcn(x)] +keep = _DROP_FUNCTIONS.get(options.drop, lambda: True) (start, end, step) = timeInfo if options.json: - values_json = str(values).replace('None', 'null') + values_json = str([x for x in values if keep(x)]).replace('None', 'null') print('''{ "start" : %d, "end" : %d, @@ -82,6 +80,10 @@ t = start for value in values: + if not keep(value): + t += step + continue + if options.pretty: if options.time_format: timestr = time.strftime(options.time_format, time.localtime(t)) From 8afd813aa712905a239f218867e4b1526b123cef Mon Sep 17 00:00:00 2001 From: Christoph Deil Date: Thu, 12 Nov 2020 16:59:44 +0100 Subject: [PATCH 2/2] Update bin/whisper-fetch.py --- bin/whisper-fetch.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/whisper-fetch.py b/bin/whisper-fetch.py index 988dccbf..7d35e1f2 100755 --- a/bin/whisper-fetch.py +++ b/bin/whisper-fetch.py @@ -64,12 +64,14 @@ except (whisper.WhisperException, IOError) as exc: raise SystemExit('[ERROR] %s' % str(exc)) -keep = _DROP_FUNCTIONS.get(options.drop, lambda: True) +keep = _DROP_FUNCTIONS.get(options.drop, lambda x: True) (start, end, step) = timeInfo if options.json: - values_json = str([x for x in values if keep(x)]).replace('None', 'null') + if options.drop is not None: + values = [x for x in values if keep(x)] + values_json = str(values).replace('None', 'null') print('''{ "start" : %d, "end" : %d, @@ -80,9 +82,10 @@ t = start for value in values: - if not keep(value): - t += step - continue + if options.drop is not None: + if not keep(value): + t += step + continue if options.pretty: if options.time_format: