pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.49k stars 524 forks source link

Example for .is_<substate>() for HSM with nonstandard separator? #500

Closed alterscape closed 3 years ago

alterscape commented 3 years ago

First of all, thank you for this library.

It isn't clear to me how the auto-generated model.is_<state>() methods for HSM substates are named in the case of non-standard separator characters. I am using a non-standard separator, -, because I'm working in a code base where snakecase is strongly desired for all methods. However, I think this is breaking the generation of is methods, because is_superstate_name-substate_name is, of course, not a legal Python identifier.

I could use camel case or some other scheme, but I'd strongly prefer not to...

aleneum commented 3 years ago

The current version (0.8.6) of transitions only supports root state checks (with allow_substates) and the generic model.state == C_2_a approach. In f3c8ce8 I added support for FunctionWrappers for state check. Previously, they had only been used for auto transitions. I documented this feature in the HSM section of the README. Let me know if that is what you were looking for.

aleneum commented 3 years ago

I am closing this since there has not been feedback in about 14 days. If your issue persists, feel free to comment anyway and I will reopen the issue if necessary.