{"id":13576732,"url":"https://github.com/pgularski/pysm","last_synced_at":"2025-04-13T06:36:48.432Z","repository":{"id":62583545,"uuid":"57854157","full_name":"pgularski/pysm","owner":"pgularski","description":"Versatile and flexible Python State Machine library","archived":false,"fork":false,"pushed_at":"2024-07-16T10:43:21.000Z","size":331,"stargazers_count":76,"open_issues_count":6,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-24T09:46:55.910Z","etag":null,"topics":["finite-state-machine","fsm","fsm-library","hsm","micropython","micropython-esp32","mit","mit-license","python"],"latest_commit_sha":null,"homepage":"http://pysm.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgularski.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-05-01T22:19:42.000Z","updated_at":"2025-03-05T01:52:12.000Z","dependencies_parsed_at":"2024-01-17T07:07:27.308Z","dependency_job_id":"9868f80f-4054-49f9-b440-f5d4be24e71e","html_url":"https://github.com/pgularski/pysm","commit_stats":{"total_commits":138,"total_committers":3,"mean_commits":46.0,"dds":"0.021739130434782594","last_synced_commit":"32cc06c893f4a5146c4f0542d03886909dda18a6"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fpysm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fpysm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fpysm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgularski%2Fpysm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgularski","download_url":"https://codeload.github.com/pgularski/pysm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248675303,"owners_count":21143763,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["finite-state-machine","fsm","fsm-library","hsm","micropython","micropython-esp32","mit","mit-license","python"],"created_at":"2024-08-01T15:01:13.289Z","updated_at":"2025-04-13T06:36:48.401Z","avatar_url":"https://github.com/pgularski.png","language":"Python","readme":"pysm - Python State Machine\n---------------------------\n\nVersatile and flexible Python State Machine library.\n\n\n.. image:: https://travis-ci.org/pgularski/pysm.svg?branch=master\n    :target: https://travis-ci.org/pgularski/pysm\n\n.. image:: https://coveralls.io/repos/github/pgularski/pysm/badge.svg?branch=master\n    :target: https://coveralls.io/github/pgularski/pysm?branch=master\n\n.. image:: https://api.codacy.com/project/badge/Grade/6f18f01639c242a0b83280a52245539d\n    :target: https://www.codacy.com/app/pgularski/pysm?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=pgularski/pysm\u0026amp;utm_campaign=Badge_Grade\n\n.. image:: https://landscape.io/github/pgularski/pysm/master/landscape.svg?style=flat\n    :target: https://landscape.io/github/pgularski/pysm/master\n    :alt: Code Health\n\n.. image:: https://readthedocs.org/projects/pysm/badge/?version=latest\n    :target: http://pysm.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\n\nImplement simple and complex state machines\n------------------------------------------\n\nIt can do simple things like this:\n\n.. image:: https://cloud.githubusercontent.com/assets/3026621/15031178/bf5efb2a-124e-11e6-9748-0b5a5be60a30.png\n\nOr somewhat more complex like that:\n\n.. image:: https://cloud.githubusercontent.com/assets/3026621/15031148/ad955f06-124e-11e6-865e-c7e3340f14cb.png\n\n\nPython State Machine\n--------------------\n\n`The State Pattern \u003chttps://en.wikipedia.org/wiki/State_pattern\u003e`_\nsolves many problems, untangles the code and saves one's sanity.\nYet.., it's a bit rigid and doesn't scale. The goal of this library is to give\nyou a close to the State Pattern simplicity with much more flexibility. And,\nif needed, the full state machine functionality, including `FSM\n\u003chttps://en.wikipedia.org/wiki/Finite-state_machine\u003e`_, `HSM\n\u003chttps://en.wikipedia.org/wiki/UML_state_machine\n#Hierarchically_nested_states\u003e`_, `PDA\n\u003chttps://en.wikipedia.org/wiki/Pushdown_automaton\u003e`_ and other tasty things.\n\n\nGoals\n-----\n\n* Provide a State Pattern-like behavior with more flexibility (see\n  `Documentation \u003chttp://pysm.readthedocs.io/en/latest/examples.html\u003e`_ for\n  examples)\n* Be explicit and don't add any magic code to objects that use pysm\n* Handle directly any kind of event or input (not only strings) - parsing\n  strings is cool again!\n* Keep it simple, even for someone who's not very familiar with the FSM\n  terminology\n\n\nFeatures\n--------\n\n* Finite State Machine (FSM)\n* Hierarchical State Machine (HSM) with Internal/External/Local transitions\n* Pushdown Automaton (PDA)\n* Transition callbacks - action, before, after\n* State hooks - enter, exit, and other event handlers\n* Entry and exit actions are associated with states, not transitions\n* Events may be anything as long as they're hashable\n* States history and transition to previous states\n* Conditional transitions (if/elif/else-like logic)\n* Explicit behaviour (no method or attribute is added to the object containing a state machine)\n* No need to extend a class with State Machine class (composition over inheritance)\n* Fast (even with hundreds of transition rules)\n* Not too many pythonisms, so that it's easily portable to other languages (ie. `JavaScript \u003chttps://github.com/pgularski/smjs\u003e`_).\n* Micropython support\n\n\nInstallation\n------------\n\nInstall pysm from `PyPI \u003chttps://pypi.python.org/pypi/pysm/\u003e`_::\n\n    pip install pysm\n\nor clone the `Github pysm repository \u003chttps://github.com/pgularski/pysm/\u003e`_::\n\n    git clone https://github.com/pgularski/pysm\n    cd pysm\n    python setup.py install\n\n\nDocumentation\n-------------\n\nRead the docs for API documentation and examples - http://pysm.readthedocs.io/\n\nSee Unit Tests to see it working and extensively tested.\n\nMicropython support\n-------------------\nThe library works with pyboards!::\n\n   import upip\n   upip.install('upysm')\n\n\nLinks\n-----\n* `Documentation \u003chttp://pysm.readthedocs.io\u003e`_\n* `Installation \u003chttp://pysm.readthedocs.io/en/latest/installing.html\u003e`_\n* `Github \u003chttps://github.com/pgularski/pysm\u003e`_\n* `Issues \u003chttps://github.com/pgularski/pysm/issues\u003e`_\n* `Examples \u003chttp://pysm.readthedocs.io/en/latest/examples.html\u003e`_\n","funding_links":[],"categories":["Python","Libraries"],"sub_categories":["Python"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgularski%2Fpysm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgularski%2Fpysm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgularski%2Fpysm/lists"}