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:
parent
9ad9ed0680
commit
e96e1b6d6c
@ -163,18 +163,20 @@ class MustBeOfType:
|
|||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return 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
|
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:
|
for item in lst:
|
||||||
if getattr(item, attribute) == value:
|
if getattr(item, attribute) == value:
|
||||||
return item
|
return item
|
||||||
raise ValueError(f'Item with {attribute}=="{value}" not found in list {str(lst)[:100]}')
|
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
|
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]
|
return [item for item in lst if getattr(item, attribute) == value or value is None]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user