Result types¶
-
class
whalesong.results.
BaseResultMixin
(result_id, *, fn_map=None)¶ Bases:
abc.ABC
,typing.Awaitable
Base result mixin.
-
result_id: str
Result unique identifier.
-
fn_map: Callable[[dict], Union[BaseModel, dict]]
Mapping function used to map result.
Parameters: -
map
(data)¶ Maps data from browser to an object if fn_map function is defined.
Parameters: data ( dict
) – Data from browser.Return type: ~T Returns: Mapped object.
-
await
set_final_result
(data)¶
-
await
set_error_result
(data)¶
-
-
class
whalesong.results.
Result
(result_id, *, fn_map=None)¶ Bases:
whalesong.results.BaseResultMixin
,_asyncio.Future
Result of command. It is a subtype of
asyncio.Future
, so in order to get result value you must await it.value = await result
Parameters:
-
class
whalesong.results.
BasePartialResult
(result_id, *, fn_map=None)¶ Bases:
whalesong.results.BaseResultMixin
,typing.AsyncIterable
-
await
set_partial_result
(data)¶
-
cancel
()¶
-
await
-
class
whalesong.results.
BaseIteratorResult
(result_id, *, fn_map=None)¶ Bases:
whalesong.results.BasePartialResult
Base iterable result.
-
class
whalesong.results.
IteratorResult
(result_id, *, fn_map=None)¶ Bases:
whalesong.results.BaseIteratorResult
Iterator result. It is used as result of command which returns a list of object.
Warning
It is an async iterator.
How to use
async for item in result_iterator: print(item)
-
map
(data)¶ Maps data from browser to an object if fn_map function is defined.
Parameters: data – Data from browser. Return type: ~T Returns: Mapped object.
-
-
class
whalesong.results.
MonitorResult
(result_id, *, fn_map=None)¶ Bases:
whalesong.results.BaseIteratorResult
Monitor result. It is used as result of monitor command. It is a infinite iterator. Each change on object or field it is monitoring will be a new item on iterator.
Warning
It is an async iterator.
How to use
async for item_changed in monitor: print(item_changed)
-
add_callback
(fn)¶ Add a callback to be called each time object or field change.
Parameters: fn ( Callable
[[~T],Awaitable
[Any
]]) – Callback function
-
start_monitor
()¶ Starts automatic monitor iteration. Useful when callback functions are defined.
-
-
class
whalesong.results.
ResultManager
¶ Bases:
object
-
remove_result
(result_id)¶ Return type: Union
[Result
[~T],IteratorResult
[~T],MonitorResult
[~T],None
]
-
request_result
(result_class)¶ Return type: ~TypeResult
-
request_iterator_result
()¶ Return type: IteratorResult
[~T]
-
request_monitor_result
()¶ Return type: MonitorResult
[~T]
-
cancel_result
(result_id)¶
-
cancel_all
()¶
-
await
set_final_result
(result_id, data)¶
-
await
set_error_result
(result_id, data)¶
-
await
set_partial_result
(result_id, data)¶
-
get_iterators
()¶ Return type: List
[IteratorResult
[~T]]
-
get_monitors
()¶ Return type: List
[MonitorResult
[~T]]
-