summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.com>2020-03-26 19:56:13 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-26 20:00:32 +0100
commit9433599de3d9c8e10a9985e3c40a7eb35eeb784d (patch)
treee78c28234f22713e1d9a0ca0bc5f55a658a5e602
parentUpdate the local Emacs config to match the black/isort/flake8 configs. (diff)
downloadglucometerutils-9433599de3d9c8e10a9985e3c40a7eb35eeb784d.tar
glucometerutils-9433599de3d9c8e10a9985e3c40a7eb35eeb784d.tar.gz
glucometerutils-9433599de3d9c8e10a9985e3c40a7eb35eeb784d.tar.bz2
glucometerutils-9433599de3d9c8e10a9985e3c40a7eb35eeb784d.tar.lz
glucometerutils-9433599de3d9c8e10a9985e3c40a7eb35eeb784d.tar.xz
glucometerutils-9433599de3d9c8e10a9985e3c40a7eb35eeb784d.tar.zst
glucometerutils-9433599de3d9c8e10a9985e3c40a7eb35eeb784d.zip
-rw-r--r--glucometerutils/common.py2
-rw-r--r--glucometerutils/drivers/fsprecisionneo.py6
-rw-r--r--glucometerutils/drivers/otultraeasy.py2
-rw-r--r--glucometerutils/drivers/otverio2015.py2
-rw-r--r--glucometerutils/drivers/otverioiq.py4
-rw-r--r--glucometerutils/drivers/td4277.py4
-rw-r--r--glucometerutils/drivers/tests/test_contourusb.py1
-rw-r--r--glucometerutils/drivers/tests/test_td4277.py2
-rwxr-xr-xglucometerutils/glucometer.py2
-rw-r--r--glucometerutils/support/contourusb.py13
-rw-r--r--glucometerutils/support/freestyle.py6
-rwxr-xr-xreversing_tools/abbott/extract_freestyle.py3
-rw-r--r--setup.py7
13 files changed, 24 insertions, 30 deletions
diff --git a/glucometerutils/common.py b/glucometerutils/common.py
index 5999eb9..2e0c45a 100644
--- a/glucometerutils/common.py
+++ b/glucometerutils/common.py
@@ -165,7 +165,7 @@ class MeterInfo:
"""
)
- if self.patient_name != None:
+ if self.patient_name is not None:
base_output += f"Patient Name: {self.patient_name}\n"
return base_output
diff --git a/glucometerutils/drivers/fsprecisionneo.py b/glucometerutils/drivers/fsprecisionneo.py
index 379bdf4..3009c7b 100644
--- a/glucometerutils/drivers/fsprecisionneo.py
+++ b/glucometerutils/drivers/fsprecisionneo.py
@@ -45,10 +45,10 @@ _NeoReading = collections.namedtuple(
"value",
# Extra trailing and so-far-unused fields; so discard them:
# * for blood glucose: 10 unknown trailing fields
- #'unknown3', 'unknown4', 'unknown5', 'unknown6', 'unknown7',
- #'unknown8', 'unknown9', 'unknown10', 'unknown11', 'unknown12',
+ # 'unknown3', 'unknown4', 'unknown5', 'unknown6', 'unknown7',
+ # 'unknown8', 'unknown9', 'unknown10', 'unknown11', 'unknown12',
# * for blood ketone: 2 unknown trailing fields
- #'unknown3', 'unknown4',
+ # 'unknown3', 'unknown4',
),
)
diff --git a/glucometerutils/drivers/otultraeasy.py b/glucometerutils/drivers/otultraeasy.py
index ba8067f..41e2acd 100644
--- a/glucometerutils/drivers/otultraeasy.py
+++ b/glucometerutils/drivers/otultraeasy.py
@@ -212,7 +212,7 @@ class Device(serial.SerialDevice, driver_base.GlucometerDriver):
def _set_device_datetime(self, date):
response = self._send_request(
_DATETIME_REQUEST,
- {"request_type": "write", "timestamp": date,},
+ {"request_type": "write", "timestamp": date},
_DATETIME_RESPONSE,
)
return response.timestamp
diff --git a/glucometerutils/drivers/otverio2015.py b/glucometerutils/drivers/otverio2015.py
index fee84f0..3882d70 100644
--- a/glucometerutils/drivers/otverio2015.py
+++ b/glucometerutils/drivers/otverio2015.py
@@ -150,7 +150,7 @@ class Device(driver_base.GlucometerDriver):
"""
try:
request = request_format.build(request_obj)
- request_raw = _PACKET.build({"data": {"value": {"message": request,}}})
+ request_raw = _PACKET.build({"data": {"value": {"message": request}}})
logging.debug("Request sent: %s", binascii.hexlify(request_raw))
self.scsi_.write10(lba, 1, request_raw)
diff --git a/glucometerutils/drivers/otverioiq.py b/glucometerutils/drivers/otverioiq.py
index 24327ef..69f88de 100644
--- a/glucometerutils/drivers/otverioiq.py
+++ b/glucometerutils/drivers/otverioiq.py
@@ -106,7 +106,7 @@ class Device(serial.SerialDevice, driver_base.GlucometerDriver):
self.buffered_reader_ = construct.Rebuffered(_PACKET, tailcutoff=1024)
def _send_packet(self, message):
- pkt = _PACKET.build({"data": {"value": {"message": message,}}})
+ pkt = _PACKET.build({"data": {"value": {"message": message}}})
logging.debug("sending packet: %s", binascii.hexlify(pkt))
self.serial_.write(pkt)
@@ -158,7 +158,7 @@ class Device(serial.SerialDevice, driver_base.GlucometerDriver):
return response.timestamp
def _set_device_datetime(self, date):
- self._send_request(_WRITE_RTC_REQUEST, {"timestamp": date,}, _COMMAND_SUCCESS)
+ self._send_request(_WRITE_RTC_REQUEST, {"timestamp": date}, _COMMAND_SUCCESS)
# The device does not return the new datetime, so confirm by calling
# READ RTC again.
diff --git a/glucometerutils/drivers/td4277.py b/glucometerutils/drivers/td4277.py
index 106166e..31901db 100644
--- a/glucometerutils/drivers/td4277.py
+++ b/glucometerutils/drivers/td4277.py
@@ -147,7 +147,7 @@ class Device(serial.SerialDevice, driver_base.GlucometerDriver):
logging.debug("received packet: %r", response)
if validate_response and response.data.value.command != command:
- raise InvalidResponse(response)
+ raise exceptions.InvalidResponse(response)
return response.data.value.command, response.data.value.message
@@ -189,7 +189,7 @@ class Device(serial.SerialDevice, driver_base.GlucometerDriver):
assert date.year >= 2000
day_struct = _DAY_BITSTRUCT.build(
- {"year": date.year - 2000, "month": date.month, "day": date.day,}
+ {"year": date.year - 2000, "month": date.month, "day": date.day}
)
day_word = construct.Int16ub.parse(day_struct)
diff --git a/glucometerutils/drivers/tests/test_contourusb.py b/glucometerutils/drivers/tests/test_contourusb.py
index 3b8b547..27cd06a 100644
--- a/glucometerutils/drivers/tests/test_contourusb.py
+++ b/glucometerutils/drivers/tests/test_contourusb.py
@@ -41,7 +41,6 @@ class TestContourUSB(absltest.TestCase):
def test_parse_header_record(self):
- _HEADER_RECORD_RE = contourusb._HEADER_RECORD_RE
_RECORD_FORMAT = contourusb._RECORD_FORMAT
header_record_decoded = self.header_record.decode()
diff --git a/glucometerutils/drivers/tests/test_td4277.py b/glucometerutils/drivers/tests/test_td4277.py
index fbd4aa2..0545ff3 100644
--- a/glucometerutils/drivers/tests/test_td4277.py
+++ b/glucometerutils/drivers/tests/test_td4277.py
@@ -8,9 +8,7 @@
import datetime
from absl.testing import parameterized
-from glucometerutils import exceptions
from glucometerutils.drivers import td4277
-from glucometerutils.support import lifescan
class TestTD4277Nexus(parameterized.TestCase):
diff --git a/glucometerutils/glucometer.py b/glucometerutils/glucometer.py
index 31cfdc0..b5bc9bb 100755
--- a/glucometerutils/glucometer.py
+++ b/glucometerutils/glucometer.py
@@ -166,7 +166,7 @@ def main():
else:
print(device.get_datetime())
elif args.action == "patient":
- if args.set_name != None:
+ if args.set_name is not None:
try:
device.set_patient_name(args.set_name)
except NotImplementedError:
diff --git a/glucometerutils/support/contourusb.py b/glucometerutils/support/contourusb.py
index 6cd9442..876c534 100644
--- a/glucometerutils/support/contourusb.py
+++ b/glucometerutils/support/contourusb.py
@@ -11,16 +11,10 @@ http://protocols.ascensia.com/Programming-Guide.aspx
"""
-import csv
import datetime
-import logging
import re
-from typing import Dict, Iterator, List, Optional, Text, Tuple
+from typing import Dict, List, Optional, Text, Tuple
-import construct
-
-from glucometerutils import exceptions
-from glucometerutils.exceptions import InvalidResponse
from glucometerutils.support import driver_base, hiddevice
# regexr.com/4k6jb
@@ -88,7 +82,8 @@ class ContourHidDevice(driver_base.GlucometerDriver):
while True:
data = self._hid_session.read()
dstr = data
- result.append(dstr[4 : data[3] + 4])
+ data_end_idx = data[3] + 4
+ result.append(dstr[4:data_end_idx])
if data[3] != self.blocksize - 4:
break
@@ -308,7 +303,7 @@ class ContourHidDevice(driver_base.GlucometerDriver):
result = self.checkframe(data[stx:])
tometer = "\x06"
self.state = self.mode_data
- except FrameError as e:
+ except FrameError:
tometer = "\x15" # Couldn't parse, <NAK>
else:
# Got something we don't understand, <NAK> it
diff --git a/glucometerutils/support/freestyle.py b/glucometerutils/support/freestyle.py
index b1eb2d2..c77282b 100644
--- a/glucometerutils/support/freestyle.py
+++ b/glucometerutils/support/freestyle.py
@@ -12,7 +12,6 @@ import csv
import datetime
import logging
import re
-from abc import ABC
from typing import AnyStr, Callable, Iterator, List, Optional, Text, Tuple
import construct
@@ -185,7 +184,8 @@ class FreeStyleHidSession:
if not encrypted or message_type in _ALWAYS_UNENCRYPTED_MESSAGES:
message_length = usb_packet[1]
- message_content = usb_packet[2 : 2 + message_length]
+ message_end_idx = 2 + message_length
+ message_content = usb_packet[2:message_end_idx]
else:
message_content = usb_packet[1:]
@@ -340,7 +340,7 @@ class FreeStyleHidDevice(driver_base.GlucometerDriver):
except UnicodeDecodeError:
raise ValueError("Only ASCII-safe names are tested working")
- result = self._session.send_text_command(b"$ptname," + encoded_name)
+ self._session.send_text_command(b"$ptname," + encoded_name)
def get_datetime(self):
# type: () -> datetime.datetime
diff --git a/reversing_tools/abbott/extract_freestyle.py b/reversing_tools/abbott/extract_freestyle.py
index 8e1c0d2..0f21d88 100755
--- a/reversing_tools/abbott/extract_freestyle.py
+++ b/reversing_tools/abbott/extract_freestyle.py
@@ -170,8 +170,9 @@ def main():
message = packet.payload[1:]
else:
message_length = packet.payload[1]
+ message_end_idx = 2 + message_length
message_type = f" {message_type:02x}"
- message = packet.payload[2 : 2 + message_length]
+ message = packet.payload[2:message_end_idx]
print(
usbmon.chatter.dump_bytes(
diff --git a/setup.py b/setup.py
index b04ea77..b0be489 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,8 @@
from setuptools import find_packages, setup
-import setuptools_scm # Ensure it's present.
+# Ensure it's present.
+import setuptools_scm # noqa: F401
extras_require = {
# These are all the drivers' dependencies. Optional dependencies are
@@ -43,8 +44,8 @@ extras_require["all"] = all_require
setup(
python_requires="~=3.7",
packages=find_packages(exclude=["test", "udev"]),
- data_files=[("lib/udev/rules", ["udev/69-glucometerutils.rules"]),],
- install_requires=["attrs",],
+ data_files=[("lib/udev/rules", ["udev/69-glucometerutils.rules"])],
+ install_requires=["attrs"],
extras_require=extras_require,
entry_points={"console_scripts": ["glucometer=glucometerutils.glucometer:main"]},
)