summaryrefslogtreecommitdiffstats
path: root/glucometerutils/support
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2020-03-14 19:13:55 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.com>2020-03-14 19:13:55 +0100
commit9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94 (patch)
treeebb59348f88a455cdc06b87aa8da821637dc4e55 /glucometerutils/support
parentExpand line length in Emacs to match black. (diff)
downloadglucometerutils-9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94.tar
glucometerutils-9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94.tar.gz
glucometerutils-9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94.tar.bz2
glucometerutils-9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94.tar.lz
glucometerutils-9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94.tar.xz
glucometerutils-9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94.tar.zst
glucometerutils-9fb0f80e84f752e3b3c4ae5e1071a6edcbf56b94.zip
Diffstat (limited to 'glucometerutils/support')
-rw-r--r--glucometerutils/support/contourusb.py10
-rw-r--r--glucometerutils/support/freestyle.py12
-rw-r--r--glucometerutils/support/hiddevice.py6
-rw-r--r--glucometerutils/support/lifescan.py6
4 files changed, 14 insertions, 20 deletions
diff --git a/glucometerutils/support/contourusb.py b/glucometerutils/support/contourusb.py
index 3b0dc80..9afb79d 100644
--- a/glucometerutils/support/contourusb.py
+++ b/glucometerutils/support/contourusb.py
@@ -180,14 +180,14 @@ class ContourHidDevice(hiddevice.HidDevice):
if recno != self.currecno:
raise FrameError(
- "Bad recno, got %r expected %r" % (recno, self.currecno), frame
+ f"Bad recno, got {recno!r} expected {self.currecno!r}", frame
)
- checksum = self.checksum(match.group("check"))
- if checksum != match.group("checksum"):
+ calculated_checksum = self.checksum(match.group("check"))
+ received_checksum = match.group("checksum")
+ if calculated_checksum != received_checksum:
raise FrameError(
- "Checksum error: got %s expected %s"
- % (match.group("checksum"), checksum),
+ f"Checksum error: received {received_checksum} expected {calculated_checksum}",
frame,
)
diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py
index 341e978..86c53d0 100644
--- a/glucometerutils/support/freestyle.py
+++ b/glucometerutils/support/freestyle.py
@@ -152,8 +152,7 @@ class FreeStyleHidDevice(hiddevice.HidDevice, driver_base.GlucometerDriver, ABC)
response = self._read_response()
if not _is_init_reply(response):
raise exceptions.ConnectionFailed(
- "Connection error: unexpected message %02x:%s"
- % (response[0], response[1].hex())
+ f"Connection error: unexpected message %{response[0]:02x}:{response[1].hex()}"
)
def disconnect(self):
@@ -235,8 +234,7 @@ class FreeStyleHidDevice(hiddevice.HidDevice, driver_base.GlucometerDriver, ABC)
if message_type != self.TEXT_REPLY_CMD:
raise exceptions.InvalidResponse(
- "Message type %02x does not match expectations: %r"
- % (message_type, content)
+ f"Message type {message_type:02x}: content does not match expectations: {content!r}"
)
full_content += content
@@ -317,10 +315,8 @@ class FreeStyleHidDevice(hiddevice.HidDevice, driver_base.GlucometerDriver, ABC)
# The format used by the FreeStyle devices is not composable based on
# standard strftime() (namely it includes no leading zeros), so we need
# to build it manually.
- date_cmd = "$date,{month},{day},{year}".format(
- month=date.month, day=date.day, year=(date.year - 2000)
- )
- time_cmd = "$time,{hour},{minute}".format(hour=date.hour, minute=date.minute)
+ date_cmd = f"$date,{date.month},{date.day},{date.year - 2000}"
+ time_cmd = f"$time,{date.hour},{date.minute}"
self._send_text_command(bytes(date_cmd, "ascii"))
self._send_text_command(bytes(time_cmd, "ascii"))
diff --git a/glucometerutils/support/hiddevice.py b/glucometerutils/support/hiddevice.py
index ad8f3a6..43461e7 100644
--- a/glucometerutils/support/hiddevice.py
+++ b/glucometerutils/support/hiddevice.py
@@ -52,9 +52,7 @@ class HidDevice:
# If the user passed a device path that does not exist, raise an
# error. This is to avoid writing to a file instead of to a device node.
if device and not os.path.exists(device):
- raise exceptions.ConnectionFailed(
- message="Path %s does not exist." % device
- )
+ raise exceptions.ConnectionFailed(message=f"Path {device} does not exist.")
# If the user passed a device, try opening it.
if device:
@@ -73,7 +71,7 @@ class HidDevice:
)
except OSError as e:
raise exceptions.ConnectionFailed(
- message="Unable to connect to meter: %s." % e
+ message=f"Unable to connect to meter: {e}."
)
def _write(self, report):
diff --git a/glucometerutils/support/lifescan.py b/glucometerutils/support/lifescan.py
index 9340e49..1c329c6 100644
--- a/glucometerutils/support/lifescan.py
+++ b/glucometerutils/support/lifescan.py
@@ -11,7 +11,7 @@ class MissingChecksum(exceptions.InvalidResponse):
def __init__(self, response):
super(MissingChecksum, self).__init__(
- "Response is missing checksum: %s" % response
+ f"Response is missing checksum: {response}"
)
@@ -20,13 +20,13 @@ class InvalidSerialNumber(exceptions.Error):
def __init__(self, serial_number):
super(InvalidSerialNumber, self).__init__(
- "Serial number %s is invalid." % serial_number
+ f"Serial number {serial_number} is invalid."
)
class MalformedCommand(exceptions.InvalidResponse):
def __init__(self, message):
- super(MalformedCommand, self).__init__("Malformed command: %s" % message)
+ super(MalformedCommand, self).__init__(f"Malformed command: {message}")
def crc_ccitt(data):