From 1e9e1647809bc0bdeab22753d7e61a22e4030d07 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Thu, 22 Jul 2021 13:37:57 +0200 Subject: [PATCH] bindings: python iio.py: find_device() also use label When multiple devices with the same name exist, label is used to differentiate them. Update find_device to also support labels. Signed-off-by: Michael Hennerich --- bindings/python/iio.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bindings/python/iio.py b/bindings/python/iio.py index b7908da8a..9128bccd7 100644 --- a/bindings/python/iio.py +++ b/bindings/python/iio.py @@ -1406,18 +1406,18 @@ def clone(self): """ return Context(_clone(self._context)) - def find_device(self, name_or_id): + def find_device(self, name_or_id_or_label): """ - Find a IIO device by its name or ID. + Find a IIO device by its name, ID or label. - :param name_or_id: type=str - The name or ID of the device to find + :param name_or_id_or_label: type=str + The name, ID or label of the device to find returns: type=iio.Device or type=iio.Trigger The IIO Device """ - return next((x for x in self.devices if name_or_id in [x.name, x.id]), None,) + return next((x for x in self.devices if name_or_id_or_label in [x.name, x.id, x.label]), None,) name = property( lambda self: self._name, None, None, "Name of this IIO context.\n\ttype=str"