summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2017-05-30 09:33:12 +0200
committerGitHub <noreply@github.com>2017-05-30 09:33:12 +0200
commit0f99a35e1719a32b334288be74b98258b81c79d1 (patch)
tree727bd3a96df362c78570a8416d909a98683eb1e2
parentAdd the Optium Neo as an untested supported device. (diff)
parentFix IndexError and KeyError: (diff)
downloadglucometerutils-0f99a35e1719a32b334288be74b98258b81c79d1.tar
glucometerutils-0f99a35e1719a32b334288be74b98258b81c79d1.tar.gz
glucometerutils-0f99a35e1719a32b334288be74b98258b81c79d1.tar.bz2
glucometerutils-0f99a35e1719a32b334288be74b98258b81c79d1.tar.lz
glucometerutils-0f99a35e1719a32b334288be74b98258b81c79d1.tar.xz
glucometerutils-0f99a35e1719a32b334288be74b98258b81c79d1.tar.zst
glucometerutils-0f99a35e1719a32b334288be74b98258b81c79d1.zip
-rw-r--r--glucometerutils/drivers/fslibre.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/glucometerutils/drivers/fslibre.py b/glucometerutils/drivers/fslibre.py
index 47d2a8b..b364cc2 100644
--- a/glucometerutils/drivers/fslibre.py
+++ b/glucometerutils/drivers/fslibre.py
@@ -68,10 +68,12 @@ def _parse_record(record, entry_map):
if not record:
return {}
- return {
- key: int(record[idx])
- for idx, key in entry_map
- }
+ try:
+ return {
+ key: int(record[idx]) for idx, key in entry_map
+ }
+ except IndexError:
+ return {}
def _extract_timestamp(parsed_record):
@@ -145,7 +147,9 @@ def _parse_arresult(record):
comment_parts.append('Long-acting insulin')
if parsed_record['rapid-acting-flag']:
- if parsed_record['double-rapid-acting-insulin']:
+ # provide default value, as this record does not always exist
+ # (even if rapid-acting-flag is set)
+ if parsed_record.get('double-rapid-acting-insulin', 0):
comment_parts.append(
'Rapid-acting insulin (%d)' %
(parsed_record['double-rapid-acting-insulin']/2))