fluidity-sm

State machine implementation for Python objects
Download

fluidity-sm Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Publisher Name:
  • Rodrigo Manhaes
  • Publisher web site:
  • https://github.com/nsi-iff/

fluidity-sm Tags


fluidity-sm Description

State machine implementation for Python objects fluidity-sm is a state machine implementation for Python objects.How to useA very simple example taken from specs:from fluidity import StateMachine, state, transitionclass SimpleMachine(StateMachine): initial_state = 'created' state('created') state('waiting') state('processed') state('canceled') transition(from_='created', event='queue', to='waiting') transition(from_='waiting', event='process', to='processed') transition(from_=, event='cancel', to='canceled')For demonstrating more advanced capabilities, a "slightly more complex example" from AASM, the Ruby's most popular state machine implementation, is reproduced below, using Fluidity:from fluidity import StateMachine, state, transitionclass Relationship(StateMachine): initial_state = lambda relationship: relationship.strictly_for_fun() and 'intimate' or 'dating' state('dating', enter='make_happy', exit='make_depressed') state('intimate', enter='make_very_happy', exit='never_speak_again') state('married', enter='give_up_intimacy', exit='buy_exotic_car_and_buy_a_combover') transition(from_='dating', event='get_intimate', to='intimate', guard='drunk') transition(from_=, event='get_married', to='married', guard='willing_to_give_up_manhood') def strictly_for_fun(self): pass def drunk(self): pass def willing_to_give_up_manhood(self): return True def make_happy(self): pass def make_depressed(self): pass def make_very_happy(self): pass def never_speak_again(self): pass def give_up_intimacy(self): pass def buy_exotic_car_and_buy_a_combover(self): passHow to run testsJust run:make testfor install all test dependencies (Should-DSL and Specloud, at the moment) and run the tests. Fluidity itself has no dependencies. Requirements: · Python


fluidity-sm Related Software