Skip to content

Commit

Permalink
bindings: python iio.py: find_device() also use label
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mhennerich authored and pcercuei committed Jul 22, 2021
1 parent f28b405 commit 1e9e164
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions bindings/python/iio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 1e9e164

Please sign in to comment.