Prevent the precommit hooks from complaining

This commit is contained in:
effective-light 2020-08-10 03:18:10 -04:00 committed by Peter F. Patel-Schneider
parent b98033d558
commit 00ea128775
7 changed files with 14 additions and 17 deletions

View File

@ -36,9 +36,9 @@ import logging
from . import listener, status # noqa: F401
from .base import DeviceUnreachable, NoReceiver, NoSuchDevice # noqa: F401
from .common import strhex # noqa: F401
from .device import Device # noqa: F401
from .hidpp20 import FeatureCallError, FeatureNotSupported # noqa: F401
from .receiver import Receiver # noqa: F401
from .device import Device # noqa: F401
_DEBUG = logging.DEBUG
_log = logging.getLogger(__name__)

View File

@ -95,11 +95,13 @@ def receivers():
for d in _hid.enumerate(receiver_usb_id):
yield d
def wired_devices():
for device_usb_id in _WIRED_DEVICE_IDS:
for dev in _hid.enumerate(device_usb_id):
yield dev
def notify_on_receivers_glib(callback):
"""Watch for matching devices and notifies the callback on the GLib thread."""
_hid.monitor_glib(callback, *_RECEIVER_USB_IDS)

View File

@ -99,11 +99,7 @@ _ex100_receiver = lambda product_id: {
'ex100_wpid_fix': True
}
_wired_device = lambda product_id: {
'vendor_id': 0x046d,
'product_id': product_id,
'usb_interface': 2
}
_wired_device = lambda product_id: {'vendor_id': 0x046d, 'product_id': product_id, 'usb_interface': 2}
# standard Unifying receivers (marked with the orange Unifying logo)
UNIFYING_RECEIVER_C52B = _unifying_receiver(0xc52b)
@ -181,6 +177,7 @@ WIRED_DEVICES = (
WIRED_DEVICE_C091,
)
def product_information(usb_id):
if isinstance(usb_id, str):
usb_id = int(usb_id, 16)

View File

@ -22,6 +22,7 @@ _R = _hidpp10.REGISTERS
#
#
class Device(object):
read_register = _hidpp10.read_register
@ -76,8 +77,7 @@ class Device(object):
if receiver:
if link_notification is not None:
self.online = not bool(ord(link_notification.data[0:1]) & 0x40)
self.wpid = _strhex(link_notification.data[2:3]
+ link_notification.data[1:2])
self.wpid = _strhex(link_notification.data[2:3] + link_notification.data[1:2])
# assert link_notification.address == (0x04
# if unifying else 0x03)
kind = ord(link_notification.data[0:1]) & 0x0F
@ -118,8 +118,7 @@ class Device(object):
device_info = self.receiver.read_register(_R.receiver_info, 0x04)
if device_info is None:
_log.error('failed to read Nano wpid for device %d of %s', number, receiver)
raise _base.NoSuchDevice(number=number,
receiver=receiver, error='read Nano wpid')
raise _base.NoSuchDevice(number=number, receiver=receiver, error='read Nano wpid')
self.wpid = _strhex(device_info[3:5])
self._power_switch = '(' + _('unknown') + ')'
@ -322,7 +321,6 @@ class Device(object):
def request(self, request_id, *params, no_reply=False):
return _base.request(self.handle, self.number, request_id, *params, no_reply=no_reply)
def feature_request(self, feature, function=0x00, *params, no_reply=False):
if self.protocol >= 2.0:
return _hidpp20.feature_request(self, feature, function, *params, no_reply=no_reply)
@ -352,8 +350,8 @@ class Device(object):
__bool__ = __nonzero__ = lambda self: self.wpid is not None and self.number in self.receiver
def __str__(self):
return '<Device(%d,%s,%s,%s)>' % (self.number,
self.wpid or self.product_id,
self.name or self.codename or '?', self.serial)
return '<Device(%d,%s,%s,%s)>' % (
self.number, self.wpid or self.product_id, self.name or self.codename or '?', self.serial
)
__unicode__ = __repr__ = __str__

View File

@ -24,12 +24,11 @@ import errno as _errno
from logging import INFO as _INFO
from logging import getLogger
from .device import Device
from . import base as _base
from . import hidpp10 as _hidpp10
from .base_usb import product_information as _product_information
from .common import strhex as _strhex
from .device import Device
_log = getLogger(__name__)
del getLogger

View File

@ -109,6 +109,7 @@ def _receivers(dev_path=None):
_log.exception('opening ' + str(dev_info))
_sys.exit('%s: error: %s' % (NAME, str(e)))
def _wired_devices(dev_path=None):
from logitech_receiver import Device
from logitech_receiver.base import wired_devices

View File

@ -21,9 +21,9 @@ from __future__ import absolute_import, division, print_function, unicode_litera
from logitech_receiver import hidpp10 as _hidpp10
from logitech_receiver import hidpp20 as _hidpp20
from logitech_receiver import receiver as _receiver
from logitech_receiver import settings_templates as _settings_templates
from logitech_receiver.common import NamedInt as _NamedInt
from logitech_receiver import receiver as _receiver
def _print_receiver(receiver):