Coder Social home page Coder Social logo

status-map's Introduction

status-map

version-badge pyversion-badge license-badge CI-badge cov-badge

Handle status maps and status transitions easily.

How to use

Install

status-map is available on PyPI:

$ pip install status-map

Basic Usage

Define 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 found

Passing 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 found

The 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 past

How to contribute

We welcome contributions of many forms, for example:

  • Code (by submitting pull requests)
  • Documentation improvements
  • Bug reports and feature requests

Setting up for local development

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 install

Install pre-commit hooks:

$ pre-commit install

Run tests by evoking pytest:

$ pytest

That's it! You're ready from development.

status-map's People

Contributors

lamenezes avatar rafaelcassau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.