diff options
author | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-12-12 21:35:37 +0100 |
---|---|---|
committer | Diego Elio Pettenò <flameeyes@flameeyes.eu> | 2018-12-12 21:35:37 +0100 |
commit | 6eae24cb3eee69461ff29fec9798bcd18083ea18 (patch) | |
tree | e6fdbf2461b1722a21c9bb2175327d26e3488cd9 | |
parent | sdcodefree: allows an arbitrary number of null-bytes before challenge. (diff) | |
download | glucometerutils-6eae24cb3eee69461ff29fec9798bcd18083ea18.tar glucometerutils-6eae24cb3eee69461ff29fec9798bcd18083ea18.tar.gz glucometerutils-6eae24cb3eee69461ff29fec9798bcd18083ea18.tar.bz2 glucometerutils-6eae24cb3eee69461ff29fec9798bcd18083ea18.tar.lz glucometerutils-6eae24cb3eee69461ff29fec9798bcd18083ea18.tar.xz glucometerutils-6eae24cb3eee69461ff29fec9798bcd18083ea18.tar.zst glucometerutils-6eae24cb3eee69461ff29fec9798bcd18083ea18.zip |
-rw-r--r-- | glucometerutils/common.py | 36 | ||||
-rw-r--r-- | setup.py | 3 |
2 files changed, 21 insertions, 18 deletions
diff --git a/glucometerutils/common.py b/glucometerutils/common.py index ba4f018..16115c0 100644 --- a/glucometerutils/common.py +++ b/glucometerutils/common.py @@ -10,6 +10,8 @@ import collections import enum import textwrap +import attr + from glucometerutils import exceptions class Unit(enum.Enum): @@ -117,24 +119,22 @@ class KetoneReading(_ReadingBase): self.timestamp, self.get_value_as(unit), self.measure_method.value, self.comment) - -_MeterInfoBase = collections.namedtuple( - '_MeterInfoBase', ['model', 'serial_number', 'version_info', 'native_unit']) - -class MeterInfo(_MeterInfoBase): - def __new__(cls, model, serial_number='N/A', version_info=(), - native_unit=Unit.MG_DL): - """Construct a meter information object. - - Args: - model: (string) Human-readable model name, depending on driver. - serial_number: (string) Optional serial number to identify the device. - version_info: (list(string)) Optional hardware/software version information. - native_unit: (Unit) Native unit of the device for display. - """ - return super(MeterInfo, cls).__new__( - cls, model=model, serial_number=serial_number, version_info=version_info, - native_unit=native_unit) +@attr.s +class MeterInfo: + """General information aobut the meter, such as model, serial number and unit. + + Attributes: + model: Human readable model name, chosen by the driver. + serial_number: Serial number identified for the reader (or N/A if not + available in the protocol.) + version_info: List of strings with any version information available about + the device. It can include hardware and software version. + native_unite: One of the Unit values to identify the meter native unit. + """ + model = attr.ib() + serial_number = attr.ib(default='N/A') + version_info = attr.ib(default=()) + native_unit = attr.ib(default=Unit.MG_DL, validator=attr.validators.in_(Unit)) def __str__(self): version_information_string = 'N/A' @@ -44,6 +44,9 @@ setup( data_files = [ ('lib/udev/rules', ['udev/69-glucometerutils.rules']), ], + install_require = [ + 'attrs', + ], tests_require = test_required, extras_require = { # These are all the drivers' dependencies. Optional dependencies are |