From d8310057c9b618196f61e5f1e61806b54c59fbfe Mon Sep 17 00:00:00 2001 From: Samuel Martin Date: Sat, 23 Sep 2017 11:47:33 +0200 Subject: glucometer.py: add --with-ketone option to the dump action --- glucometer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/glucometer.py b/glucometer.py index 385653c..88c44b4 100755 --- a/glucometer.py +++ b/glucometer.py @@ -54,6 +54,9 @@ def main(): '--sort-by', action='store', default='timestamp', choices=common._ReadingBase._fields, help='Field to order the dumped data by.') + parser_dump.add_argument( + '--with-ketone', action='store_true', default=False, + help='Enable ketone reading if available on the glucometer.') parser_date = subparsers.add_parser( 'datetime', help='Reads or sets the date and time of the glucometer.') @@ -99,6 +102,10 @@ def main(): readings = device.get_readings() + if not args.with_ketone: + readings = (reading for reading in readings + if not isinstance(reading, common.KetoneReading)) + if args.sort_by is not None: readings = sorted( readings, key=lambda reading: getattr(reading, args.sort_by)) -- cgit v1.2.3