Handle status maps and status transitions easily.
status-map is available on PyPI:
$ pip install status-mapDefine your status map by creating a dict containing all the status and its possible transitions.
E.g. we can define a task workflow as follows:
from status_map import StatusMap
status_map = StatusMap({
'todo': ['doing'],
'doing': ['todo', 'done'],
'done': [], # assuming a task once finished can't go back to other status
})We can validate if a status transition is valid:
>> status_map.validate_transition(from_status='todo', to_status='done')
Traceback (most recent call last):
...
status_map.exceptions.TransitionNotFound: transition from todo to done not foundPassing an inexistent status raises an exception:
>> status_map.validate_transition('todo', 'foo')
Traceback (most recent call last):
...
status_map.exceptions.StatusNotFound: to status foo not foundThe validation raises a different exception if the to_status has already appeared before:
>> status_map.validate_transition('done', 'todo')
Traceback (most recent call last):
...
status_map.exceptions.RepeatedTransition: transition from done to todo should have happened in the pastWe welcome contributions of many forms, for example:
- Code (by submitting pull requests)
- Documentation improvements
- Bug reports and feature requests
We use poetry to manage dependencies, so make sure you have it installed.
Roll up your virtual enviroment using your favorite tool and install development dependencies:
$ poetry installInstall pre-commit hooks:
$ pre-commit installRun tests by evoking pytest:
$ pytestThat's it! You're ready from development.