From af96a07010d53babfecdb516733f4419ed893699 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Mon, 15 Feb 2016 20:39:55 +0000 Subject: otultra2: make the before/after meal constants in common module. This will lead the way to providing meal information with future drivers. --- glucometerutils/common.py | 7 ++++++- glucometerutils/drivers/otultra2.py | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/glucometerutils/common.py b/glucometerutils/common.py index a9968c2..32402a6 100644 --- a/glucometerutils/common.py +++ b/glucometerutils/common.py @@ -16,6 +16,11 @@ UNIT_MMOLL = 'mmol/L' VALID_UNITS = [UNIT_MGDL, UNIT_MMOLL] +# Constants for meal information +NO_MEAL = '' +BEFORE_MEAL = 'Before Meal' +AFTER_MEAL = 'After Meal' + # Constants for date format DATETIME_12HR = '12 hours' DATETIME_24HR = '24 hours' @@ -54,7 +59,7 @@ _ReadingBase = collections.namedtuple( '_ReadingBase', ['timestamp', 'value', 'meal', 'comment']) class Reading(_ReadingBase): - def __new__(cls, timestamp, value, meal='', comment=''): + def __new__(cls, timestamp, value, meal=NO_MEAL, comment=''): """Constructor for the reading object. Args: diff --git a/glucometerutils/drivers/otultra2.py b/glucometerutils/drivers/otultra2.py index f44450a..b72c4eb 100644 --- a/glucometerutils/drivers/otultra2.py +++ b/glucometerutils/drivers/otultra2.py @@ -17,9 +17,9 @@ from glucometerutils.drivers import lifescan_common # The following two hashes are taken directly from LifeScan's documentation _MEAL_CODES = { - 'N': '', - 'B': 'Before Meal', - 'A': 'After Meal', + 'N': common.NO_MEAL, + 'B': common.BEFORE_MEAL, + 'A': common.AFTER_MEAL, } _COMMENT_CODES = { -- cgit v1.2.3