{"id":37072223,"url":"https://github.com/ahawker/decorstate","last_synced_at":"2026-01-14T08:28:37.010Z","repository":{"id":62567363,"uuid":"42218212","full_name":"ahawker/decorstate","owner":"ahawker","description":"Simple \"state machines\" with Python decorators.","archived":false,"fork":false,"pushed_at":"2017-06-08T03:25:36.000Z","size":39,"stargazers_count":12,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T14:09:40.185Z","etag":null,"topics":["python","python-decorators","state-machine"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahawker.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2015-09-10T02:53:52.000Z","updated_at":"2024-03-05T12:13:13.000Z","dependencies_parsed_at":"2022-11-03T16:30:37.592Z","dependency_job_id":null,"html_url":"https://github.com/ahawker/decorstate","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/ahawker/decorstate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahawker%2Fdecorstate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahawker%2Fdecorstate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahawker%2Fdecorstate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahawker%2Fdecorstate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahawker","download_url":"https://codeload.github.com/ahawker/decorstate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahawker%2Fdecorstate/sbom","scorecard":{"id":171583,"data":{"date":"2025-08-11","repo":{"name":"github.com/ahawker/decorstate","commit":"50d666b0e5a258a74c2d58442bb51ca034a7e809"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-16T16:39:41.489Z","repository_id":62567363,"created_at":"2025-08-16T16:39:41.489Z","updated_at":"2025-08-16T16:39:41.489Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28414023,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T08:16:59.381Z","status":"ssl_error","status_checked_at":"2026-01-14T08:13:45.490Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["python","python-decorators","state-machine"],"created_at":"2026-01-14T08:28:36.427Z","updated_at":"2026-01-14T08:28:36.979Z","avatar_url":"https://github.com/ahawker.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# decorstate\n\n[![Build Status](https://travis-ci.org/ahawker/decorstate.svg?branch=master)](https://travis-ci.org/ahawker/decorstate)\n[![Test Coverage](https://codeclimate.com/github/ahawker/decorstate/badges/coverage.svg)](https://codeclimate.com/github/ahawker/decorstate/coverage)\n[![Code Climate](https://codeclimate.com/github/ahawker/decorstate/badges/gpa.svg)](https://codeclimate.com/github/ahawker/decorstate)\n[![Issue Count](https://codeclimate.com/github/ahawker/decorstate/badges/issue_count.svg)](https://codeclimate.com/github/ahawker/decorstate)\n\n[![PyPI Version](https://badge.fury.io/py/decorstate.svg)](https://badge.fury.io/py/decorstate)\n[![PyPI Versions](https://img.shields.io/pypi/pyversions/decorstate.svg)](https://pypi.python.org/pypi/decorstate)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/decorstate.svg)](https://pypi.python.org/pypi/decorstate)\n\nBuild dumb little \"state machines\" with Python decorators.\n\n### Installation\n\nTo install decorstate from [pip](https://pypi.python.org/pypi/pip):\n```bash\n    $ pip install decorstate\n```\n\nTo install decorstate from source:\n```bash\n    $ git clone git@github.com:ahawker/decorstate.git\n    $ cd decorstate\n    $ python setup.py install\n```\n\n### Usage\n\nHow do I use this pile?\n\n```python\nimport decorstate\n\nclass Switch(object):\n    state = 'off'\n\n    @decorstate.transition('off', 'on')\n    def on(self, *args, **kwargs):\n        print 'You turned me on!'\n\n    @decorstate.transition('on', 'off')\n    def off(self, *args, **kwargs):\n        print 'You turned me off!'\n\n\u003e\u003e\u003e switch = Switch()\n\u003e\u003e\u003e switch.state\n'off'\n\u003e\u003e\u003e switch.on()\nYou turned me on!\n'on'\n\u003e\u003e\u003e switch.off()\nYou turned me off!\n'off'\n```\n\nA switch? Really? How lame.\n\n\n```python\nimport decorstate\n\nclass BrokenSwitch(object):\n    state = 'off'\n\n    @decorstate.transition('off', 'on')\n    def on(self, *args, **kwargs):\n        print 'You turned me on!'\n\n    @decorstate.transition('on', 'off')\n    def off(self, *args, **kwargs):\n        print 'You turned me off? Nah!'\n\n    @off.guard\n    def off(self, *args, **kwargs):\n        print 'Ha! I laugh at your feeble attempt!'\n\n\u003e\u003e\u003e broken_switch = BrokenSwitch()\n\u003e\u003e\u003e broken_switch.state\n'off'\n\u003e\u003e\u003e broken_switch.on()\nYou turned me on!\n'on'\n\u003e\u003e\u003e broken_switch.off()\nHa! I laugh at your feeble attempt!\n'on'\n\u003e\u003e\u003e broken_switch.state\n'on'\n\u003e\u003e\u003e broken_switch.off()\nHa! I laugh at your feeble attempt!\n'on'\n\u003e\u003e\u003e broken_switch.state\n'on'\n```\n\nA broken switch? Yawn.\n\n\n```python\nimport decorstate\n\nclass InstantOffSwitch(object):\n    state = 'off'\n\n    @decorstate.transition('off', 'off')\n    def on(self, *args, **kwargs):\n        print 'You turned me on!'\n\n    @decorstate.transition('on', 'off')\n    def off(self, *args, **kwargs):\n        print 'You turned me off!'\n\n    @on.after\n    def on(self, *args, **kwargs):\n        print 'Ha! No light for you!'\n\n\u003e\u003e\u003e instant_off_switch = InstantOffSwitch()\n\u003e\u003e\u003e instant_off_switch.state\n'off'\n\u003e\u003e\u003e instant_off_switch.on()\nYou turned me on!\nHa! No light for you!\n'off'\n\u003e\u003e\u003e instant_off_switch.state\n'off'\n```\n\nWell, that's kinda mean.\n\n\n```python\nimport decorstate\nimport random\n\nclass IoTSwitch(object):\n    state = 'off'\n\n    @decorstate.transition('off', 'off')\n    def on(self, *args, **kwargs):\n        print 'You turned me on? Maybe...'\n\n    @decorstate.transition('on', 'off')\n    def off(self, *args, **kwargs):\n        print 'You turned me off? Maybe...'\n\n    @on.guard\n    def on(self, *args, **kwargs):\n        return self.coin_flip()\n\n    @off.guard\n    def off(self, *args, **kwargs):\n        return not self.coin_flip()\n\n    @staticmethod\n    def coin_flip():\n        return random.randint(1, 2) == 1\n\n\u003e\u003e\u003e iot_switch = IoTSwitch()\n\u003e\u003e\u003e iot_switch.state\n'off'\n\u003e\u003e\u003e iot_switch.on()\n'off'\n\u003e\u003e\u003e iot_switch.on()\n'off'\n\u003e\u003e\u003e iot_switch.on()\n'off'\n\u003e\u003e\u003e iot_switch.on()\nYou turned me on? Maybe...\n'on'\n\u003e\u003e\u003e iot_switch.off()\n'on'\n\u003e\u003e\u003e iot_switch.off()\n'on'\n\u003e\u003e\u003e iot_switch.off()\n'on'\n\u003e\u003e\u003e iot_switch.off()\n'on'\n\u003e\u003e\u003e iot_switch.off()\nYou turned me off? Maybe...\n'off'\n```\n\nHey now, why you hating? Internet powered light switches are next level shit. My living room has its own twitter feed.\n\n\n### Why?\n\nI was interesting in doing something a bit more complex using the Python [descriptor protocol](https://docs.python.org/2/howto/descriptor.html).\n\n### TODO?\n\nRandom thoughts and musing about potential changes/features.\n\n*  Consider adding the @machine decorator back as currently, you cannot use the \"state\", \"transition\" and \"transition_event\" attributes until the first transition has been performed since they are lazy created.\n*  Add event handler that fires only when \"entering\" a state and not when you perform multiple transitions but stay in the same state.\n\n### License\n\n[Apache 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahawker%2Fdecorstate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahawker%2Fdecorstate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahawker%2Fdecorstate/lists"}