From c8796bf2101575c5f5b1afcc30a2aa51f7d2b40f Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 10 May 2018 23:14:42 +0200 Subject: [PATCH] Fix treatment entries. --- freestyle_to_nightscout.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/freestyle_to_nightscout.py b/freestyle_to_nightscout.py index 8455ea9..0b7c35f 100644 --- a/freestyle_to_nightscout.py +++ b/freestyle_to_nightscout.py @@ -94,6 +94,7 @@ def main(): entries.append(entry) elif comment.get('type') == 'treatment': + print("here") for t in ( 'long-acting', 'rapid-acting', 'food', 'sport' ): if comment.get(t) is not None: treatment = { @@ -138,6 +139,7 @@ def main(): (entries[i], entries[i+1]) = calculate_entry_delta(entries[i], entries[i+1]) #pp.pprint(entries) + #pp.pprint(treatments) sys.exit(1) # Remove this line to upload! ''' Upload data (either treatment or entry) to Nightscout ''' @@ -240,7 +242,6 @@ def parse_comments(data): rscantype = re.compile('\((Sensor|Scan|Blood|Ketone)\)', flags=re.IGNORECASE) rrelevant = re.compile('(Sport|Food|Rapid-acting insulin|Long-acting insulin|Direction)(?: \((.*?)(?: g)?\))', flags=re.IGNORECASE) for part in data.get('comment').split('; '): - scantype = rscantype.search(part) if scantype is not None: if scantype.group(1) == 'Blood': @@ -254,6 +255,7 @@ def parse_comments(data): if relevant is not None: comment_type = relevant.group(1) comment_value = relevant.group(2) + print(comment_type) if comment_type == 'Long-acting insulin': comment['type'] = 'treatment' comment['long-acting'] = comment_value @@ -281,7 +283,7 @@ def parse_comments(data): comment['direction'] = 'FortyFiveDown' elif comment_value == 'down-fast': comment['direction'] = 'SingleDown' - return comment + return comment def verify_units(units = None): ''' Standardise units for output and for the A1c calculations ''' @@ -342,7 +344,7 @@ def parse_arguments(): default='mmol/L', choices=(UNIT_MGDL, UNIT_MMOLL), help=('The measurement units used in the Freestyle Libre reader (mmol/L or mg/dL).')) parser.add_argument( - '--timezone', '-tz', action='store', required=False, type=str, dest='tz', + '--timezone', '--tz', action='store', required=False, type=str, dest='tz', default='UTC', help=('The time zone for which the sensor is set to record dates.')) parser.add_argument(