Fix treatment entries.

This commit is contained in:
Timothy Allen 2018-05-10 23:14:42 +02:00
parent f2fd1a0acd
commit c8796bf210
1 changed files with 5 additions and 3 deletions

View File

@ -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(