1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-03 01:17:56 +03:00

Upgrading VMware an fixing up things

This commit is contained in:
Adolfo Gómez García 2024-06-21 20:13:34 +02:00
parent 9ad9ed0680
commit e96e1b6d6c
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23

View File

@ -163,18 +163,20 @@ class MustBeOfType:
def __repr__(self) -> str:
return self.__str__()
def search_item_by_attr(lst: list[T], attribute: str, value: typing.Any) -> T:
def search_item_by_attr(lst: list[T], attribute: str, value: typing.Any, **kwargs: typing.Any) -> T:
"""
Returns an item from a list of items
kwargs are not used, just to let use it as partial on fixtures
"""
for item in lst:
if getattr(item, attribute) == value:
return item
raise ValueError(f'Item with {attribute}=="{value}" not found in list {str(lst)[:100]}')
def filter_list_by_attr(lst: list[T], attribute: str, value: typing.Any) -> list[T]:
def filter_list_by_attr(lst: list[T], attribute: str, value: typing.Any, **kwargs: typing.Any) -> list[T]:
"""
Returns a list of items from a list of items
kwargs are not used, just to let use it as partial on fixtures
"""
return [item for item in lst if getattr(item, attribute) == value or value is None]