Классы Yostate
- pydantic model yostate.locators.Locator[исходный код]
- Config:
allow_mutation: bool = True
extra: str = forbid
validate_all: bool = True
validate_assignment: bool = True
- field params: dict[str, Any] [Optional]
- field state_class_locator: str [Required]
- pydantic model yostate.locators.FrozenLocator[исходный код]
- Config:
allow_mutation: bool = False
- pydantic model yostate.router.Route[исходный код]
- Config:
allow_mutation: bool = False
validate_all: bool = True
- field state_class_locator: str [Required]
- field title: str = ''
- class yostate.router.Router(decorators=None, state_class_locator_validators=(<function validate_state_class_locator>, ))[исходный код]
Базовые классы:
dict
[str
,Route
]Index of registered state classes.
- Параметры:
- state_class_locator_validators: tuple[Callable[[str], str]]
- register(state_class_locator, *, title='')[исходный код]
Register a State with specified locator.
- Параметры:
state_class_locator (str) –
title (str) –
- Тип результата:
Type[BaseState]
- create_state(locator)[исходный код]
Create new serializable State.
- pydantic model yostate.states.BaseState[исходный код]
Base class for all states of state machine.
Fill free to inherite custom state class from BaseState with adding new attributes to Pydantic model scheme.
- Config:
allow_mutation: bool = False
extra: str = ignore
keep_untouched: tuple = (<class „functools.cached_property“>,)
validate_all: bool = True
- field state_class_locator: str [Required]
Path-like string specifies how to find required State class. Will be initialized by router on state instance creation.
- async aenter_state()[исходный код]
Run any custom logic on state enter.
Can return state object to force state machine switching to another state.
- Тип результата:
Locator | None
- async aexit_state(state_class_transition)[исходный код]
Run any custom logic on state exit.
State machine switching to another state is not available from this method.
- Параметры:
state_class_transition (bool) –
- Тип результата:
None
- async aprocess(event)[исходный код]
Run any custom logic to process event.
Can return state object to force state machine switching to another state.
- Параметры:
event (Any) –
- Тип результата:
Locator | None
- enter_state()[исходный код]
Run any custom logic on state enter.
Can return state object to force state machine switching to another state.
- Тип результата:
Locator | None
- exit_state(state_class_transition)[исходный код]
Run any custom logic on state exit.
State machine switching to another state is not available from this method.
- Параметры:
state_class_transition (bool) –
- Тип результата:
None
- process(event)[исходный код]
Run any custom logic to process event.
Can return state object to force state machine switching to another state.
- Параметры:
event (Any) –
- Тип результата:
Locator | None
- final class yostate.sync_crawler.Crawler(router, max_transition_length=20)[исходный код]
Базовые классы:
object
- Параметры:
router (Router) –
max_transition_length (int) –
- max_transition_length: int = 20
- restore(locator, ignore_errors=False)[исходный код]
Восстанавливает положение краулера в прежнем состоянии.
Используйте метод restore чтобы восстановить положение краулера в том состоянии, где он ранее прервал свою работу. Вызов метода restore отличается от switch_to тем, что не приводит к запуску кода в методе BaseState.enter_state и не запускает процесс переходов по состояниям.
- Параметры:
locator (Locator) –
ignore_errors (bool) –
- Тип результата:
None
- detach()[исходный код]
- Тип результата:
None
- process(event)[исходный код]
Обрабатывает поступившее событие.
- Параметры:
event (Any) –
- Тип результата:
None
- switch_to(locator)[исходный код]
Переводит краулер в новое состояние и следует далее по цепочке переходов до упора.
В краулер встроена защиты от зацикливания. Она ограничивает максимальную длину цепочки переходов.
- Параметры:
locator (Locator) –
- Тип результата:
None
- property attached: bool