base: Turn filter_products_of_interest into a public function

Related #2273
This commit is contained in:
MattHag 2024-12-29 01:07:58 +01:00 committed by Peter F. Patel-Schneider
parent 5cf7cbfd5d
commit 5d86c74df4
2 changed files with 4 additions and 4 deletions

View File

@ -199,7 +199,7 @@ def receivers():
yield from hidapi.enumerate(_filter_receivers) yield from hidapi.enumerate(_filter_receivers)
def _filter_products_of_interest( def filter_products_of_interest(
bus_id: int, vendor_id: int, product_id: int, hidpp_short: bool = False, hidpp_long: bool = False bus_id: int, vendor_id: int, product_id: int, hidpp_short: bool = False, hidpp_long: bool = False
) -> dict[str, Any] | None: ) -> dict[str, Any] | None:
"""Check that this product is of interest and if so return the device record for further checking""" """Check that this product is of interest and if so return the device record for further checking"""
@ -219,7 +219,7 @@ def _filter_products_of_interest(
def receivers_and_devices(): def receivers_and_devices():
"""Enumerate all the receivers and devices directly attached to the machine.""" """Enumerate all the receivers and devices directly attached to the machine."""
yield from hidapi.enumerate(_filter_products_of_interest) yield from hidapi.enumerate(filter_products_of_interest)
def notify_on_receivers_glib(glib: GLib, callback: Callable): def notify_on_receivers_glib(glib: GLib, callback: Callable):
@ -230,7 +230,7 @@ def notify_on_receivers_glib(glib: GLib, callback: Callable):
glib glib
GLib instance. GLib instance.
""" """
return hidapi.monitor_glib(glib, callback, _filter_products_of_interest) return hidapi.monitor_glib(glib, callback, filter_products_of_interest)
def open_path(path) -> int: def open_path(path) -> int:

View File

@ -71,7 +71,7 @@ def test_filter_receivers_unknown():
], ],
) )
def test_filter_products_of_interest(product_id, bus, hidpp_short, hidpp_long, expected): def test_filter_products_of_interest(product_id, bus, hidpp_short, hidpp_long, expected):
receiver_info = base._filter_products_of_interest( receiver_info = base.filter_products_of_interest(
bus, bus,
LOGITECH_VENDOR_ID, LOGITECH_VENDOR_ID,
product_id, product_id,