summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2019-09-02 20:01:06 +0200
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2019-09-02 20:01:06 +0200
commit4240f49f79543623c56ada4c212505a227634e19 (patch)
tree6f86a35e167f0cbceda937c1cb5a88a05a6605f8
parentadd internal device id to glucose measurements (and other entries) to prepare for better sorting (diff)
downloadglucometerutils-4240f49f79543623c56ada4c212505a227634e19.tar
glucometerutils-4240f49f79543623c56ada4c212505a227634e19.tar.gz
glucometerutils-4240f49f79543623c56ada4c212505a227634e19.tar.bz2
glucometerutils-4240f49f79543623c56ada4c212505a227634e19.tar.lz
glucometerutils-4240f49f79543623c56ada4c212505a227634e19.tar.xz
glucometerutils-4240f49f79543623c56ada4c212505a227634e19.tar.zst
glucometerutils-4240f49f79543623c56ada4c212505a227634e19.zip
-rw-r--r--glucometerutils/common.py6
-rw-r--r--glucometerutils/drivers/fslibre.py8
2 files changed, 8 insertions, 6 deletions
diff --git a/glucometerutils/common.py b/glucometerutils/common.py
index 4c7694c..c11ff2c 100644
--- a/glucometerutils/common.py
+++ b/glucometerutils/common.py
@@ -66,7 +66,7 @@ class GlucoseReading:
default=MeasurementMethod.BLOOD_SAMPLE,
validator=attr.validators.in_(
MeasurementMethod)) # type: MeasurementMethod
- device_id = attr.ib(default=None) # type: int
+ extra_data = attr.ib(factory=dict)
def get_value_as(self, to_unit):
# type: (Unit) -> float
@@ -90,7 +90,7 @@ class KetoneReading:
timestamp = attr.ib() # type: datetime.datetime
value = attr.ib() # type: float
comment = attr.ib(default='') # type: Text
- device_id = attr.ib(default=None) # type: int
+ extra_data = attr.ib(factory=dict)
def as_csv(self, unit):
"""Returns the reading as a formatted comma-separated value string."""
@@ -108,7 +108,7 @@ class TimeAdjustment:
default=MeasurementMethod.TIME,
validator=attr.validators.in_(
MeasurementMethod)) # type: MeasurementMethod
- device_id = attr.ib(default=None) # type: int
+ extra_data = attr.ib(factory=dict)
def as_csv(self, unit):
del unit
diff --git a/glucometerutils/drivers/fslibre.py b/glucometerutils/drivers/fslibre.py
index 0e62aa6..e6ea85a 100644
--- a/glucometerutils/drivers/fslibre.py
+++ b/glucometerutils/drivers/fslibre.py
@@ -118,7 +118,8 @@ def _parse_arresult(record):
return common.TimeAdjustment(
_extract_timestamp(parsed_record),
_extract_timestamp(parsed_record, 'old_'),
- device_id=parsed_record['device_id'])
+ extra_data={'device_id': parsed_record['device_id']},
+ )
else:
return None
@@ -198,7 +199,8 @@ def _parse_arresult(record):
value,
comment='; '.join(comment_parts),
measure_method=measure_method,
- device_id=parsed_record['device_id'])
+ extra_data={'device_id': parsed_record['device_id']},
+ )
class Device(freestyle.FreeStyleHidDevice):
"""Glucometer driver for FreeStyle Libre devices."""
@@ -241,7 +243,7 @@ class Device(freestyle.FreeStyleHidDevice):
parsed_record['value'],
comment='(Sensor)',
measure_method=common.MeasurementMethod.CGM,
- device_id=parsed_record['device_id']
+ extra_data={'device_id': parsed_record['device_id']},
)
# Then get the results of explicit scans and blood tests (and other