From e72b02d84e7f67cdf6107862ad580e951a5bbda1 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 21 Feb 2020 10:45:40 +0100 Subject: format code with black --- glucometerutils/support/hiddevice.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'glucometerutils/support/hiddevice.py') diff --git a/glucometerutils/support/hiddevice.py b/glucometerutils/support/hiddevice.py index b44e5c7..ad8f3a6 100644 --- a/glucometerutils/support/hiddevice.py +++ b/glucometerutils/support/hiddevice.py @@ -45,33 +45,36 @@ class HidDevice: # type: (Optional[Text]) -> None if None in (self.USB_VENDOR_ID, self.USB_PRODUCT_ID) and not device: raise exceptions.CommandLineError( - '--device parameter is required, should point to a /dev/hidraw ' - 'device node representing the meter.') + "--device parameter is required, should point to a /dev/hidraw " + "device node representing the meter." + ) # 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) + message="Path %s does not exist." % device + ) # If the user passed a device, try opening it. if device: - self.handle_ = open(device, 'w+b') # type: Optional[BinaryIO] + self.handle_ = open(device, "w+b") # type: Optional[BinaryIO] else: self.handle_ = None - logging.info( - 'No --device parameter provided, using hidapi library.') + logging.info("No --device parameter provided, using hidapi library.") try: import hid + self.hidapi_handle_ = hid.device() - self.hidapi_handle_.open( - self.USB_VENDOR_ID, self.USB_PRODUCT_ID) + self.hidapi_handle_.open(self.USB_VENDOR_ID, self.USB_PRODUCT_ID) except ImportError: raise exceptions.ConnectionFailed( - message='Missing requied "hidapi" module.') + message='Missing requied "hidapi" module.' + ) except OSError as e: raise exceptions.ConnectionFailed( - message='Unable to connect to meter: %s.' % e) + message="Unable to connect to meter: %s." % e + ) def _write(self, report): # type: (bytes) -> None @@ -95,5 +98,4 @@ class HidDevice: if self.handle_: return bytes(self.handle_.read(size)) - return bytes(self.hidapi_handle_.read( - size, timeout_ms=self.TIMEOUT_MS)) + return bytes(self.hidapi_handle_.read(size, timeout_ms=self.TIMEOUT_MS)) -- cgit v1.2.3