Add method to filter devices

This commit is contained in:
clerie 2022-06-19 14:45:26 +02:00
parent 82378e0bd7
commit 405f71f621
2 changed files with 17 additions and 0 deletions

View File

@ -147,6 +147,20 @@ class OMMClient2:
d = self.get_device(ppn) d = self.get_device(ppn)
return self.detach_user_device(d.uid, ppn) return self.detach_user_device(d.uid, ppn)
def find_devices(self, filter):
"""
Get all devices matching a filter
:param filter: function taking one parameter which is a device, returns True to keep, False to discard
Usage::
>>> c.find_devices(lambda d: d.relType == mitel_ommclient2.types.PPRelTypeType("Unbound"))
"""
for d in self.get_devices():
if filter(d):
yield d
def get_account(self, id): def get_account(self, id):
""" """

View File

@ -72,6 +72,9 @@ class EnumType:
def __repr__(self): def __repr__(self):
return "{}({})".format(self.__class__.__name__, repr(self.value)) return "{}({})".format(self.__class__.__name__, repr(self.value))
def __eq__(self, other):
return isinstance(other, type(self)) and self.value == other.value
class CallForwardStateType(EnumType): class CallForwardStateType(EnumType):
VALUES = [ VALUES = [