Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State feature: Tags #230

Closed
aleneum opened this issue Jun 27, 2017 · 0 comments
Closed

State feature: Tags #230

aleneum opened this issue Jun 27, 2017 · 0 comments

Comments

@aleneum
Copy link
Member

aleneum commented Jun 27, 2017

Allows to add tags to a state and test for tags with state.is_<tag_name>. See: states.py

Keywords

  • tags (list, optional) -- assigns tags to a state

Example Usage

from transitions import Machine
from transitions.extensions.states import add_state_features, Tags


@add_state_features(Tags)
class CustomMachine(Machine):
    pass

states = [{"name": "A", "tags": ["initial", "success", "error_state"]}]
m = CustomMachine(states=states, initial='A')
s = m.get_state(m.state)

print(s.is_initial)  # >>> True
print(s.is_success)  # >>> True
print(s.is_error_state)  # >>> True
print(s.is_not_available)  # >>> False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant