From bc2d1a0ee33acb339a20e6ffcd4e5e7a28fa260d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sun, 7 Jul 2019 22:10:14 +0100 Subject: fslibre: expose patient name if the device knows it. This includes extension of the base info command to report this when asked on the command line. --- glucometerutils/common.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'glucometerutils/common.py') diff --git a/glucometerutils/common.py b/glucometerutils/common.py index a258e4b..4af2001 100644 --- a/glucometerutils/common.py +++ b/glucometerutils/common.py @@ -8,7 +8,7 @@ import enum import textwrap try: - from typing import Sequence, Text + from typing import Optional, Sequence, Text except ImportError: pass @@ -131,6 +131,7 @@ class MeterInfo: version_info = attr.ib(default=()) # type: Sequence[Text] native_unit = attr.ib( default=Unit.MG_DL, validator=attr.validators.in_(Unit)) # type: Unit + patient_name = attr.ib(default=None) # type: Optional[Text] def __str__(self): version_information_string = 'N/A' @@ -138,7 +139,7 @@ class MeterInfo: version_information_string = '\n '.join( self.version_info).strip() - return textwrap.dedent("""\ + base_output = textwrap.dedent("""\ {model} Serial Number: {serial_number} Version Information: @@ -147,3 +148,9 @@ class MeterInfo: """).format(model=self.model, serial_number=self.serial_number, version_information_string=version_information_string, native_unit=self.native_unit.value) + + if self.patient_name != None: + base_output += 'Patient Name: {patient_name}\n'.format( + patient_name=self.patient_name) + + return base_output -- cgit v1.2.3