{ "info": { "author": "Rodrigo Manh\u00c3\u00a3es", "author_email": "rmanhaes@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2.4", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Topic :: Software Development :: Libraries" ], "description": "Fluidity\n========\n\nState machine implementation for Python objects.\n\n\nHow to use\n----------\n\nA very simple example taken from specs::\n\n from fluidity import StateMachine, state, transition\n\n class SimpleMachine(StateMachine):\n\n initial_state = 'created'\n\n state('created')\n state('waiting')\n state('processed')\n state('canceled')\n\n transition(from_='created', event='queue', to='waiting')\n transition(from_='waiting', event='process', to='processed')\n transition(from_=['waiting', 'created'], event='cancel', to='canceled')\n\n\n\"A slightly more complex example\"\n---------------------------------\n\nFor demonstrating more advanced capabilities, a \"slightly more complex example\" from `AASM `_, the Ruby's most popular state machine implementation, is reproduced below, using Fluidity::\n\n\n from fluidity import StateMachine, state, transition\n\n class Relationship(StateMachine):\n initial_state = lambda relationship: relationship.strictly_for_fun() and 'intimate' or 'dating'\n state('dating', enter='make_happy', exit='make_depressed')\n state('intimate', enter='make_very_happy', exit='never_speak_again')\n state('married', enter='give_up_intimacy', exit='buy_exotic_car_and_buy_a_combover')\n\n transition(from_='dating', event='get_intimate', to='intimate', guard='drunk')\n transition(from_=['dating', 'intimate'], event='get_married', to='married', guard='willing_to_give_up_manhood')\n\n def strictly_for_fun(self): pass\n def drunk(self): pass\n def willing_to_give_up_manhood(self): return True\n def make_happy(self): pass\n def make_depressed(self): pass\n def make_very_happy(self): pass\n def never_speak_again(self): pass\n def give_up_intimacy(self): pass\n def buy_exotic_car_and_buy_a_combover(self): pass\n\n\nStates\n------\n\nA Fluidity state machine must have one initial state and at least two states.\n\nA state may have enter and exit callbacks, for running some code on state enter\nand exit, respectively. These params can be method names (as strings),\ncallables, or lists of method names or callables.\n\n\nTransitions\n-----------\n\nTransitions lead the machine from a state to another. Transitions must have\n*from\\_*, *to*, and *action* parameters. *from\\_* is one or more (as list) states\nfrom which the transition can be started. *to* is the state to which the\ntransition will lead the machine. *event* is the method that have to be called\nto launch the transition. This method is automatically created by the Fluidity\nengine.\n\nA transition can have optional *action* and *guard* parameters. *action* is a\nmethod (or callable) that will be called when transition is launched. If\nparameters are passed to the event method, they are passed to the *action*\nmethod, if it accepts these parameters. *guard* is a method (or callable) that\nis called to allow or deny the transition, depending on the result of its\nexecution. Both \"action\" and *guard* can be lists.\n\nThe same event can be in multiple transitions, going to different states, having\ntheir respective guards as selectors. For the transitions having the same event,\nonly one guard should return a true value at a time.\n\n\nIndividuation\n-------------\n\nStates and transitions are defined in a class-wide mode. However, one can define\nstates and transitions for individual objects. For example, having \"door\" as a\nstate machine::\n\n door.add_state('broken')\n door.add_transition(from_='closed', event='crack', to='broken')\n\n\nThese additions only affect the target object.\n\n\nHow to install\n--------------\n\nJust run::\n\n pip install fluidity-sm\n\n\n**Note**: the Pypi package is called *fluidity-sm*, not *fluidity*.\n\n\nHow to run tests\n----------------\n\nJust run::\n\n make test\n\nfor install all test dependencies (`Should-DSL `_\nand `Specloud `_, at the moment) and\nrun the tests. Fluidity itself has no dependencies.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nsi-iff/fluidity", "keywords": "state machine python dsl", "license": "MIT License", "maintainer": null, "maintainer_email": null, "name": "fluidity-sm", "package_url": "https://pypi.org/project/fluidity-sm/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/fluidity-sm/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/nsi-iff/fluidity" }, "release_url": "https://pypi.org/project/fluidity-sm/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Fluidity: state machine implementation for Python objects", "version": "0.2.1" }, "last_serial": 792080, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "43ce339fa3726c8775d90ef2230baaf2", "sha256": "8291bdc831b5c85a0b7769c63a7536f70a408ddb52806fc141a614e064aaff30" }, "downloads": -1, "filename": "fluidity-sm-0.1.0.tar.gz", "has_sig": false, "md5_digest": "43ce339fa3726c8775d90ef2230baaf2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4005, "upload_time": "2011-05-11T20:40:09", "url": "https://files.pythonhosted.org/packages/9b/38/14733bebcd35cbf5d7ff9947b12adfad3841c84478f13cae3f0a82717417/fluidity-sm-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "21a941fee8127b85d6a592758b848d55", "sha256": "52067d10901a20a024ea59cc7979e520cac78ad89ad7592b7d53f2c43d0cbc3a" }, "downloads": -1, "filename": "fluidity-sm-0.2.0.tar.gz", "has_sig": false, "md5_digest": "21a941fee8127b85d6a592758b848d55", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5871, "upload_time": "2011-09-03T17:59:22", "url": "https://files.pythonhosted.org/packages/9a/6f/09c64ef26fb989f93a844753cd585c76e4e400e158bab32e5def6347fb13/fluidity-sm-0.2.0.tar.gz" } ], "0.2.1": [] }, "urls": [] }