shep

Multi-state key stores using bit masks for python3
git clone git://git.defalsify.org/shep.git
Log | Files | Refs | LICENSE

kanban.py (1849B)


      1 from shep.state import State
      2 
      3 
      4 # we don't like "NEW" as the default label for a new item in the queue, so we change it to BACKLOG
      5 State.set_default_state('backlog')
      6 
      7 # define all the valid states
      8 st = State(5)
      9 st.add('pending')
     10 st.add('blocked')
     11 st.add('doing')
     12 st.add('review')
     13 st.add('finished')
     14 
     15 # define a couple of states that give a bit more context to progress; something is blocked before starting development or something is blocked during development...
     16 st.alias('startblock', st.BLOCKED, st.PENDING)
     17 st.alias('doingblock', st.BLOCKED, st.DOING)
     18 
     19 
     20 # create the foo key which will forever languish in backlog
     21 k = 'foo'
     22 st.put(k)
     23 foo_state = st.state(k)
     24 foo_state_name = st.name(foo_state)
     25 foo_contents_r = st.get('foo')
     26 print('{} {} {}'.format(k, foo_state_name, foo_contents_r))
     27 
     28 
     29 # Create bar->baz and advance it from backlog to pending
     30 k = 'bar'
     31 bar_contents = 'baz'
     32 st.put(k, contents=bar_contents)
     33 
     34 st.next(k)
     35 bar_state = st.state(k)
     36 bar_state_name = st.name(bar_state)
     37 bar_contents_r = st.get('bar')
     38 print('{} {} {}'.format(k, bar_state_name, bar_contents_r))
     39 
     40 # Create inky->pinky and move to doing then doing-blocked
     41 k = 'inky'
     42 inky_contents = 'pinky'
     43 st.put(k, contents=inky_contents)
     44 inky_state = st.state(k)
     45 st.move(k, st.DOING)
     46 st.set(k, st.BLOCKED)
     47 inky_state = st.state(k)
     48 inky_state_name = st.name(inky_state)
     49 inky_contents_r = st.get('inky')
     50 print('{} {} {}'.format(k, inky_state_name, bar_contents_r))
     51 
     52 # then replace the content
     53 # note that replace could potentially mean some VCS below
     54 inky_new_contents = 'blinky'
     55 st.replace(k, inky_new_contents)
     56 inky_contents_r = st.get('inky')
     57 print('{} {} {}'.format(k, inky_state_name, inky_contents_r))
     58 
     59 # so now move to review
     60 st.move(k, st.REVIEW)
     61 inky_state = st.state(k)
     62 inky_state_name = st.name(inky_state)
     63 print('{} {} {}'.format(k, inky_state_name, inky_contents_r))
     64